diff --git a/Cargo.toml b/Cargo.toml index 69c9633..607370d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cas-lib" -version = "0.2.53" +version = "0.2.54" edition = "2021" description = "Core lib for CAS" license = "Apache-2.0" diff --git a/src/asymmetric/cas_rsa.rs b/src/asymmetric/cas_rsa.rs index 1d1ef99..5d121f2 100644 --- a/src/asymmetric/cas_rsa.rs +++ b/src/asymmetric/cas_rsa.rs @@ -13,8 +13,8 @@ use super::types::{CASRSAEncryption, RSAKeyPairResult}; pub struct CASRSA; impl CASRSAEncryption for CASRSA { - // Generates an RSA key pair of the specified size. - // The key size must be at of a supported kind like 1024, 2048, 4096 bits. + /// Generates an RSA key pair of the specified size. + /// The key size must be at of a supported kind like 1024, 2048, 4096 bits. fn generate_rsa_keys(key_size: usize) -> RSAKeyPairResult { // TODO: do a check for key_size, if it is too small, return an error let mut rng: OsRng = OsRng; @@ -34,8 +34,8 @@ impl CASRSAEncryption for CASRSA { result } - // Generates an RSA key pair of the specified size on the threadpool. - // The key size must be at of a supported kind like 1024, 2048, 4096 bits. + /// Generates an RSA key pair of the specified size on the threadpool. + /// The key size must be at of a supported kind like 1024, 2048, 4096 bits. fn generate_rsa_keys_threadpool(key_size: usize) -> RSAKeyPairResult { let (sender, receiver) = mpsc::channel(); rayon::spawn(move || { @@ -46,8 +46,8 @@ impl CASRSAEncryption for CASRSA { thread_result } - // Sign the given hash with the provided private key of the RSA key pair. - // The parameter `hash` doesn't necessarily have to be a hash, it can be any data that you want to sign. + /// Sign the given hash with the provided private key of the RSA key pair. + /// The parameter `hash` doesn't necessarily have to be a hash, it can be any data that you want to sign. fn sign(private_key: String, hash: Vec) -> Vec { let private_key = RsaPrivateKey::from_pkcs8_pem(&private_key).unwrap(); let signed_data = private_key @@ -56,10 +56,10 @@ impl CASRSAEncryption for CASRSA { signed_data } - // Sign the given hash with the provided private key of the RSA key pair on the threadpool. - // The parameter `hash` doesn't necessarily have to be a hash, it can be any data that you want to sign. - // Returns the signed data as a byte vector. - // This is useful for signing data in a non-blocking way. + /// Sign the given hash with the provided private key of the RSA key pair on the threadpool. + /// The parameter `hash` doesn't necessarily have to be a hash, it can be any data that you want to sign. + /// Returns the signed data as a byte vector. + /// This is useful for signing data in a non-blocking way. fn sign_threadpool(private_key: String, hash: Vec) -> Vec { let (sender, receiver) = mpsc::channel(); rayon::spawn(move || { @@ -70,9 +70,9 @@ impl CASRSAEncryption for CASRSA { signed_data } - // Verify the signature of the given hash with the provided public key of the RSA key pair. - // The parameter `hash` doesn't necessarily have to be a hash, it can be any data that you want to verify. - // Returns true if the signature is valid, false otherwise. + /// Verify the signature of the given hash with the provided public key of the RSA key pair. + /// The parameter `hash` doesn't necessarily have to be a hash, it can be any data that you want to verify. + /// Returns true if the signature is valid, false otherwise. fn verify(public_key: String, hash: Vec, signature: Vec) -> bool { let public_key = RsaPublicKey::from_pkcs1_pem(&public_key).unwrap(); let verified = public_key.verify(Pkcs1v15Sign::new_unprefixed(), &hash, &signature); @@ -83,9 +83,9 @@ impl CASRSAEncryption for CASRSA { } } - // Verify the signature of the given hash with the provided public key of the RSA key pair on the threadpool. - // The parameter `hash` doesn't necessarily have to be a hash, it can be any data that you want to verify. - // Returns true if the signature is valid, false otherwise. + /// Verify the signature of the given hash with the provided public key of the RSA key pair on the threadpool. + /// The parameter `hash` doesn't necessarily have to be a hash, it can be any data that you want to verify. + /// Returns true if the signature is valid, false otherwise. fn verify_threadpool(public_key: String, hash: Vec, signed_text: Vec) -> bool { let (sender, receiver) = mpsc::channel(); rayon::spawn(move || { diff --git a/src/symmetric/aes.rs b/src/symmetric/aes.rs index b63d4cb..036463b 100644 --- a/src/symmetric/aes.rs +++ b/src/symmetric/aes.rs @@ -18,13 +18,13 @@ pub struct CASAES256; impl CASAES256Encryption for CASAES256 { - // Generates an AES256 key from a vector + /// Generates an AES256 key from a vector fn key_from_vec(key_slice: Vec) -> Vec { let result = Key::::from_slice(&key_slice).to_vec(); result } - // Generates an AES256 key from a vector on the threadpool + /// Generates an AES256 key from a vector on the threadpool fn key_from_vec_threadpool(key_slice: Vec) -> Vec { let (sender, receiver) = mpsc::channel(); rayon::spawn(move || { @@ -137,13 +137,13 @@ impl CASAES256Encryption for CASAES256 { impl CASAES128Encryption for CASAES128 { - // Generates an AES128 key from a vector + /// Generates an AES128 key from a vector fn key_from_vec(key_slice: Vec) -> Vec { let result = Key::::from_slice(&key_slice).to_vec(); result } - // Generates an AES128 key from a vector on the threadpool + /// Generates an AES128 key from a vector on the threadpool fn key_from_vec_threadpool(key_slice: Vec) -> Vec { let (sender, receiver) = mpsc::channel(); rayon::spawn(move || {