Crate message_verifier

source ·
Expand description

Message Verifier library compatible with Rails’ MessageVerifier and MessageEncryptor.

A Small Example

Please refer to the README and repo for more examples.

 extern crate message_verifier;

 use message_verifier::{Verifier, Encryptor, AesHmacEncryptor, DerivedKeyParams};

 fn main() {
     let key_base = "helloworld";
     let salt = "test salt";
     let sign_salt = "test signed salt";

     let verifier = Verifier::new(key_base);

     //let dkp = DerivedKeyParams::default();
     //let encryptor = AesHmacEncryptor::new(key_base, salt, sign_salt, dkp).unwrap();

     let message = "{\"key\":\"value\"}";

     println!("{}", verifier.generate(message).expect("Verifier failed"));
     //println!("{}", encryptor.encrypt_and_sign(message).expect("Encryptor failed"));
 }

Structs

  • AesGcmEncryptor struct; similiar to ActiveSupport::MessageEncryptor
  • AesHmacEncryptor struct; similiar to ActiveSupport::MessageEncryptor
  • Key derivation parameters for PBKDF2 function.
  • The Error type.
  • Verifier struct; similiar to ActiveSupport::MessageVerifier.

Enums

  • The kind of an error.
  • Encryption cipher key options. Only AES with 256, 192 or 128 bits is supported.

Traits

  • Encryptor trait; similiar to ActiveSupport::MessageEncryptor. Implemented by AesHmacEncryptor and AesGcmEncryptor.
  • Additional methods for Result, for easy interaction with this crate.

Functions

  • Create one or more PBKDF2 derived keys using a secret, some key parameters and one or more salts.

Type Aliases

  • Convenient wrapper around std::Result.