ADATA

From Crypto++ Wiki
Jump to: navigation, search

ADATA is a generic term to indicate the 'additional authenticated data' which is usually encountered in discussions of cipher modes such as CCM and GCM. When operating the cipher in an authenticated encryption mode, the construction affords authentication assurances over the ADATA. ADATA is also referred to as non-confidential data. ADATA is also referred to a header (HDR) data in some test vectors and implementations. The counterpart to ADATA is PDATA.

Crypto++ objects which derive from AuthenticatedEncryptionFilter offer authenticated encryption. The ADATA is accessible through the "AAD" side channel.

GCM< AES >::Encryption e;
e.SetKeyWithIV( key, sizeof(key), iv, sizeof(iv) );
...

AuthenticatedEncryptionFilter ef( e,
    new StringSink( cipher )
); // AuthenticatedEncryptionFilter

// AuthenticatedEncryptionFilter::ChannelPut
//  defines two channels: "" (empty) and "AAD"
//   channel "" is encrypted and authenticated
//   channel "AAD" is authenticated
ef.ChannelPut( "AAD", adata.data(), adata.size() );
ef.ChannelMessageEnd("AAD");