fn encrypt_expiry(
        &self,
        expiry: u64,
        iv: &[u8],
    ) -> Result<([u8; PAYLOAD_LEN], [u8; TAG_LEN]), Error> {
        // Create Nonce object from initialization vector.
        let nonce = Nonce::from_slice(iv);
        // Convert expiry u64 value into bytes.
        let mut expiry_as_bytes = expiry.to_le_bytes();

        let tag = self
            .cipher
            .encrypt_in_place_detached(nonce, self.aad.as_bytes(), &mut expiry_as_bytes)
            .map_err(|_| Error::TokenEncryption)?;

        // Tag must be of size `TAG_LEN`.
        let tag_as_bytes: [u8; TAG_LEN] = tag
            .as_slice()
            .try_into()
            .map_err(|_| Error::TokenEncryption)?;

        Ok((expiry_as_bytes, tag_as_bytes))
    }
/// Encrypt expiry using AES-GCM block cipher and return payload and tag obtained.
Encrypt expiry using AES-GCM block cipher and return payload and tag obtained.
Encrypt expiry using AES - GCM block cipher and return payload and tag obtained .
fn encrypt_expiry(
        &self,
        expiry: u64,
        iv: &[u8],
    ) -> Result<([u8; PAYLOAD_LEN], [u8; TAG_LEN]), Error> {
        // Create Nonce object from initialization vector.
        let nonce = Nonce::from_slice(iv);
        // Convert expiry u64 value into bytes.
        let mut expiry_as_bytes = expiry.to_le_bytes();
        let tag = self
            .cipher
            .encrypt_in_place_detached(nonce, self.aad.as_bytes(), &mut expiry_as_bytes)
            .map_err(|_| Error::TokenEncryption)?;
        // Tag must be of size `TAG_LEN`.
        let tag_as_bytes: [u8; TAG_LEN] = tag
            .as_slice()
            .try_into()
            .map_err(|_| Error::TokenEncryption)?;
        Ok((expiry_as_bytes, tag_as_bytes))
    }
fn encrypt_expiry ( & self , expiry : u64 , iv : & [ u8 ] , ) -> Result < ( [ u8 ; PAYLOAD_LEN ] , [ u8 ; TAG_LEN ] ) , Error > { // Create Nonce object from initialization vector. let nonce = Nonce :: from_slice ( iv ) ; // Convert expiry u64 value into bytes. let mut expiry_as_bytes = expiry . to_le_bytes ( ) ; let tag = self . cipher . encrypt_in_place_detached ( nonce , self . aad . as_bytes ( ) , & mut expiry_as_bytes ) . map_err ( | _ | Error :: TokenEncryption ) ? ; // Tag must be of size `TAG_LEN`. let tag_as_bytes : [ u8 ; TAG_LEN ] = tag . as_slice ( ) . try_into ( ) . map_err ( | _ | Error :: TokenEncryption ) ? ; Ok ( ( expiry_as_bytes , tag_as_bytes ) ) }
Encrypt expiry using AES-GCM block cipher and return payload and tag obtained.
Encrypt expiry using AES - GCM block cipher and return payload and tag obtained .
&self
expiry
u64
iv
&[u8]
&self
expiry
u64
iv
&[u8]