rust_ev_crypto_primitives 0.8.4

Crypto Primitives necessary for E-Voting Applications.
Documentation
// Copyright © 2023 Denis Morel

// This program is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
// later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details.
//
// You should have received a copy of the GNU General Public License and
// a copy of the GNU General Public License along with this program. If not, see
// <https://www.gnu.org/licenses/>.

//! Module to wrap the openssl library for crypto functions

mod aes;
mod argon2;
mod certificate;
mod hash;
mod rand;
mod signature;

use aes::AESError;
pub use aes::{Decrypter, Encrypter, CRYPTER_TAG_SIZE};
pub use argon2::*;
pub use certificate::*;
pub use hash::*;
pub(crate) use rand::*;
pub use signature::*;

use openssl::error::ErrorStack;
use thiserror::Error;

#[derive(Error, Debug)]
#[error(transparent)]
/// Error in the basis crypto methods
pub struct BasisCryptoError(#[from] BasisCryptoErrorRepr);

// Enum with the type of error generated by openSSL_wrapper
#[derive(Error, Debug)]
enum BasisCryptoErrorRepr {
    #[error("Error in argon2")]
    Argon2(#[from] Argon2Error),
    #[error("Error in generating random bytes")]
    RandomError { source: ErrorStack },
    #[error(transparent)]
    HashError(#[from] HashError),
    #[error(transparent)]
    AESError(#[from] AESError),
    #[error(transparent)]
    CertificateError(#[from] CertificateError),
    #[error(transparent)]
    SignatureError(#[from] SignatureError),
    #[error("Input too small, since the tag size is 16")]
    TooSmallInput,
}