/* ecrypt-sync.c */ /* *** Please do not edit this file. *** */ #include "ecrypt-sync.h" /**************************************************************/ /**************************************************************/ /* added by Larry Bugbee, June 9, 2007 */ int getCtxSize() { return sizeof(ECRYPT_ctx); } #ifdef ECRYPT_BUFFER_BYTES /* Dragon */ #define CHUNK_SIZE ECRYPT_BUFFER_BYTES #elif ECRYPT_BLOCKLENGTH /* all but Dragon */ #define CHUNK_SIZE ECRYPT_BLOCKLENGTH #else #define CHUNK_SIZE 0 #endif int getChunkSize() { return CHUNK_SIZE; } int isValidKeySize(int straw) { /* in bits */ int i = 0; for (i=0; ECRYPT_KEYSIZE(i) <= ECRYPT_MAXKEYSIZE; ++i) if (straw == ECRYPT_KEYSIZE(i)) return 1; return 0; } int isValidIVSize(int straw) { /* in bits */ int i = 0; for (i=0; ECRYPT_IVSIZE(i) <= ECRYPT_MAXIVSIZE; ++i) if (straw == ECRYPT_IVSIZE(i)) return 1; return 0; } /**************************************************************/ /**************************************************************/ #ifdef ECRYPT_USES_DEFAULT_ALL_IN_ONE /* * Default implementation of all-in-one encryption/decryption of * (short) packets. */ #ifdef ECRYPT_HAS_SINGLE_PACKET_FUNCTION void ECRYPT_process_packet( int action, ECRYPT_ctx* ctx, const u8* iv, const u8* input, u8* output, u32 msglen) { ECRYPT_ivsetup(ctx, iv); #ifdef ECRYPT_HAS_SINGLE_BYTE_FUNCTION ECRYPT_process_bytes(action, ctx, input, output, msglen); #else if (action == 0) ECRYPT_encrypt_bytes(ctx, input, output, msglen); else ECRYPT_decrypt_bytes(ctx, input, output, msglen); #endif } #else void ECRYPT_encrypt_packet( ECRYPT_ctx* ctx, const u8* iv, const u8* plaintext, u8* ciphertext, u32 msglen) { ECRYPT_ivsetup(ctx, iv); ECRYPT_encrypt_bytes(ctx, plaintext, ciphertext, msglen); } void ECRYPT_decrypt_packet( ECRYPT_ctx* ctx, const u8* iv, const u8* ciphertext, u8* plaintext, u32 msglen) { ECRYPT_ivsetup(ctx, iv); ECRYPT_decrypt_bytes(ctx, ciphertext, plaintext, msglen); } #endif #endif