Don't Re-use Cipher Key For Mac

Posted on
DonKey

Note When combining a MAC with unauthenticated encryption mode, prefer to first encrypt the message and then MAC the ciphertext. The alternative is to MAC the plaintext, which depending on exact usage can suffer serious security issues.

For a detailed discussion of this issue see the paper “The Order of Encryption and Authentication for Protecting Communications” by Hugo Krawczyk The Botan MAC computation is split into five stages. Instantiate the MAC algorithm. Set the secret key. Process IV. Process data. Finalize the MAC computation. Class MessageAuthenticationCode std::string name ( ) const Returns a human-readable string of the name of this algorithm.

Void clear ( ) Clear the key. clone ( ) const Return a newly allocated object of the same type as this one. Void setkey ( const uint8t. key, sizet length ) Set the shared MAC key for the calculation. This function has to be called before the data is processed.

Don't Reuse Cipher Key For Mac Free

Bool validkeylength (sizet length ) const This function returns true if and only if length is a valid keylength for the algorithm. Sizet minimumkeylength ( ) const Return the smallest key length (in bytes) that is acceptable for the algorithm.

Sizet maximumkeylength ( ) const Return the largest key length (in bytes) that is acceptable for the algorithm. Void start ( const uint8t. nonce, sizet noncelen ) Set the IV for the MAC calculation. Note that not all MAC algorithms require an IV. If an IV is required, the function has to be called before the data is processed. For algorithms that don’t require it, the call can be omitted, or else called with noncelen of zero. Void update ( const uint8t.

input, sizet length ) Process the passed data. Void update ( const securevector & in ) Process the passed data. Bonus macrs. Void update (uint8t in ) Process a single byte. Void final (uint8t. out ) Complete the MAC computation and write the calculated tag to the passed byte array.

Securevector final ( ) Complete the MAC computation and return the calculated tag. Bool verifymac ( const uint8t. mac, sizet length ) Finalize the current MAC computation and compare the result to the passed mac. Returns true, if the verification is successful and false otherwise.