X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilccrypt%2Fblowfish.c;h=c1b11b29fe268371f1e2df7d26e0dd9580adc22a;hb=e7b6c157b80152bf9fb9266e6bdd93f9fb0db776;hp=355d64a87f5b2911d72e7c8455188bd750411711;hpb=40f8443d8d3a6577336ee66d18e04d9ac4d956bb;p=silc.git diff --git a/lib/silccrypt/blowfish.c b/lib/silccrypt/blowfish.c index 355d64a8..c1b11b29 100644 --- a/lib/silccrypt/blowfish.c +++ b/lib/silccrypt/blowfish.c @@ -37,29 +37,28 @@ #include "blowfish_internal.h" #include "blowfish.h" -/* +/* * SILC Crypto API for Blowfish */ /* Sets the key for the cipher. */ -SILC_CIPHER_API_SET_KEY(blowfish) +SILC_CIPHER_API_SET_KEY(blowfish_cbc) { blowfish_set_key((BlowfishContext *)context, (unsigned char *)key, keylen); return TRUE; } -/* Sets the string as a new key for the cipher. The string is first - hashed and then used as a new key. */ +/* Sets IV for the cipher. */ -SILC_CIPHER_API_SET_KEY_WITH_STRING(blowfish) +SILC_CIPHER_API_SET_IV(blowfish_cbc) { - return 1; + } /* Returns the size of the cipher context. */ -SILC_CIPHER_API_CONTEXT_LEN(blowfish) +SILC_CIPHER_API_CONTEXT_LEN(blowfish_cbc) { return sizeof(BlowfishContext); } @@ -67,7 +66,7 @@ SILC_CIPHER_API_CONTEXT_LEN(blowfish) /* Encrypts with the cipher in CBC mode. Source and destination buffers maybe one and same. */ -SILC_CIPHER_API_ENCRYPT_CBC(blowfish) +SILC_CIPHER_API_ENCRYPT(blowfish_cbc) { SilcUInt32 tiv[4]; int i; @@ -92,7 +91,7 @@ SILC_CIPHER_API_ENCRYPT_CBC(blowfish) /* Decrypts with the cipher in CBC mode. Source and destination buffers maybe one and same. */ -SILC_CIPHER_API_DECRYPT_CBC(blowfish) +SILC_CIPHER_API_DECRYPT(blowfish_cbc) { SilcUInt32 tmp[4], tmp2[4], tiv[4]; int i; @@ -108,9 +107,9 @@ SILC_CIPHER_API_DECRYPT_CBC(blowfish) blowfish_decrypt((BlowfishContext *)context, tmp, tmp2, 16); SILC_CBC_DEC_POST(tmp2, dst, src, tmp, tiv); } - + SILC_CBC_PUT_IV(tiv, iv); - + return TRUE; } @@ -383,7 +382,7 @@ static u32 bf_sbox[256 * 4] = 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6, }; -/* +/* * Round loop unrolling macros, S is a pointer to a S-Box array * organized in 4 SilcUInt32s at a row. */ @@ -400,7 +399,7 @@ static u32 bf_sbox[256 * 4] = /* * The blowfish encipher, processes 64-bit blocks. - * NOTE: This function MUSTN'T respect endianess + * NOTE: This function MUSTN'T respect endianess */ int blowfish_encrypt(BlowfishContext *ctx, @@ -526,7 +525,7 @@ int blowfish_set_key(BlowfishContext *ctx, for (i = 0; i < 16 + 2; i += 2) { blowfish_encrypt(ctx, data, data, 8); - + P[i] = data[0]; P[i + 1] = data[1]; }