X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Frijndael-api-fst.c;h=b55df797b55a0ba112ef4a14b458058c13917ef2;hb=1a2869593e115e4a6c74aaa0b23ca612357403ce;hp=b7053a5b7cd9e8d322dc496331b14ecbe7bd0836;hpb=b1d63f6a62e094b90cd900923b5537ea985aba30;p=gnulib.git diff --git a/lib/rijndael-api-fst.c b/lib/rijndael-api-fst.c index b7053a5b7..b55df797b 100644 --- a/lib/rijndael-api-fst.c +++ b/lib/rijndael-api-fst.c @@ -1,5 +1,5 @@ /* rijndael-api-fst.c --- Rijndael cipher implementation. - * Copyright (C) 2005 Free Software Foundation, Inc. + * Copyright (C) 2005, 2006 Free Software Foundation, Inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -25,9 +25,7 @@ * http://www.iaik.tu-graz.ac.at/research/krypto/AES/old/~rijmen/rijndael/rijndael-fst-3.0.zip */ -#ifdef HAVE_CONFIG_H -# include -#endif +#include /** * rijndael-api-fst.c @@ -244,7 +242,7 @@ rijndaelBlockEncrypt (rijndaelCipherInstance *cipher, ((uint32_t *) block)[3] = ((uint32_t *) input)[3] ^ ((uint32_t *) iv)[3]; rijndaelEncrypt (key->rk, key->Nr, block, outBuffer); - iv = outBuffer; + memcpy (cipher->IV, outBuffer, 16); input += 16; outBuffer += 16; } @@ -327,7 +325,7 @@ rijndaelPadEncrypt (rijndaelCipherInstance *cipher, ((uint32_t *) block)[3] = ((uint32_t *) input)[3] ^ ((uint32_t *) iv)[3]; rijndaelEncrypt (key->rk, key->Nr, block, outBuffer); - iv = outBuffer; + memcpy (cipher->IV, outBuffer, 16); input += 16; outBuffer += 16; } @@ -342,6 +340,7 @@ rijndaelPadEncrypt (rijndaelCipherInstance *cipher, block[i] = (char) padLen ^ iv[i]; } rijndaelEncrypt (key->rk, key->Nr, block, outBuffer); + memcpy (cipher->IV, outBuffer, 16); break; default: @@ -360,10 +359,10 @@ rijndaelBlockDecrypt (rijndaelCipherInstance *cipher, size_t i, k, t, numBlocks; char block[16], *iv; - if (cipher == NULL || - key == NULL || - cipher->mode != RIJNDAEL_MODE_CFB1 - && key->direction == RIJNDAEL_DIR_ENCRYPT) + if (cipher == NULL + || key == NULL + || (cipher->mode != RIJNDAEL_MODE_CFB1 + && key->direction == RIJNDAEL_DIR_ENCRYPT)) { return RIJNDAEL_BAD_CIPHER_STATE; }