* imported original ECRYPT submissions after first automatic cleanup.
/* ecrypt-ssyn-ae.c */
/* *** Please do not edit this file. *** */
#include "ecrypt-ssyn-ae.h"
#ifdef ECRYPT_USES_DEFAULT_ALL_IN_ONE
/*
* Default implementation of all-in-one authenticated
* encryption/decryption of (short) packets.
*/
#ifdef ECRYPT_HAS_SINGLE_PACKET_FUNCTION
void ECRYPT_AE_process_packet(
int action,
ECRYPT_AE_ctx* ctx,
const u8* iv,
const u8* aad,
u32 aadlen,
const u8* input,
u8* output,
u32 msglen,
u8* mac)
{
u8 previous[ECRYPT_SYNCLENGTH];
ECRYPT_AE_ivsetup(ctx, previous, iv);
#ifdef ECRYPT_SUPPORTS_AAD
ECRYPT_AE_authenticate_bytes(ctx, previous, aad, aadlen);
#endif
#ifdef ECRYPT_HAS_SINGLE_BYTE_FUNCTION
ECRYPT_AE_process_bytes(action, ctx, previous, input, output, msglen);
#else
if (action == 0)
ECRYPT_AE_encrypt_bytes(ctx, previous, input, output, msglen);
else
ECRYPT_AE_decrypt_bytes(ctx, previous, input, output, msglen);
#endif
ECRYPT_AE_finalize(ctx, mac);
}
#else
void ECRYPT_AE_encrypt_packet(
ECRYPT_AE_ctx* ctx,
const u8* iv,
const u8* aad,
u32 aadlen,
const u8* plaintext,
u8* ciphertext,
u32 msglen,
u8* mac)
{
u8 previous[ECRYPT_SYNCLENGTH];
ECRYPT_AE_ivsetup(ctx, previous, iv);
#ifdef ECRYPT_SUPPORTS_AAD
ECRYPT_AE_authenticate_bytes(ctx, previous, aad, aadlen);
#endif
ECRYPT_AE_encrypt_bytes(ctx, previous, plaintext, ciphertext, msglen);
ECRYPT_AE_finalize(ctx, mac);
}
void ECRYPT_AE_decrypt_packet(
ECRYPT_AE_ctx* ctx,
const u8* iv,
const u8* aad,
u32 aadlen,
const u8* ciphertext,
u8* plaintext,
u32 msglen,
u8* mac)
{
u8 previous[ECRYPT_SYNCLENGTH];
ECRYPT_AE_ivsetup(ctx, previous, iv);
#ifdef ECRYPT_SUPPORTS_AAD
ECRYPT_AE_authenticate_bytes(ctx, previous, aad, aadlen);
#endif
ECRYPT_AE_decrypt_bytes(ctx, previous, ciphertext, plaintext, msglen);
ECRYPT_AE_finalize(ctx, mac);
}
#endif
#endif
|
eSTREAM Project Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |