pub fn new() -> Result<Self> {
        // Generate a new master key. We'll store this *wrapped with `key`*.
        let master_key = Key::new_random()?;
        // Encrypt the auth token with the master key. This is so we can decrypt
        // it later, and verify we get the right result, to guarantee we have
        // the right master key.
        let (nonce, ciphertext) = master_key.encrypt(&AUTH_TOKEN_CONTENTS, None)?;

        Ok(KeyStore {
            master_key: Some(master_key),
            token_nonce: nonce,
            token: ciphertext,
            wrapped_keys: Vec::new(),
        })
    }
/// Construct a new KeyStore. A new master key is generated from scratch.
///
/// Note that, before this KeyStore can be meaningfully persisted, you need
/// to wrap the master key with at least one key, via `add_key`.
Construct a new KeyStore. A new master key is generated from scratch.
Note that, before this KeyStore can be meaningfully persisted, you need
to wrap the master key with at least one key, via `add_key`.
Construct a new KeyStore . A new master key is generated from scratch . Note that before this KeyStore can be meaningfully persisted you need to wrap the master key with at least one key via ` add_key ` .
pub fn new() -> Result<Self> {
        // Generate a new master key. We'll store this *wrapped with `key`*.
        let master_key = Key::new_random()?;
        // Encrypt the auth token with the master key. This is so we can decrypt
        // it later, and verify we get the right result, to guarantee we have
        // the right master key.
        let (nonce, ciphertext) = master_key.encrypt(&AUTH_TOKEN_CONTENTS, None)?;
        Ok(KeyStore {
            master_key: Some(master_key),
            token_nonce: nonce,
            token: ciphertext,
            wrapped_keys: Vec::new(),
        })
    }
pub fn new ( ) -> Result < Self > { // Generate a new master key. We'll store this *wrapped with `key`*. let master_key = Key :: new_random ( ) ? ; // Encrypt the auth token with the master key. This is so we can decrypt // it later, and verify we get the right result, to guarantee we have // the right master key. let ( nonce , ciphertext ) = master_key . encrypt ( & AUTH_TOKEN_CONTENTS , None ) ? ; Ok ( KeyStore { master_key : Some ( master_key ) , token_nonce : nonce , token : ciphertext , wrapped_keys : Vec :: new ( ) , } ) }
Construct a new KeyStore.
Construct a new KeyStore .