From ea6674d9de9ca1aa6771e7a8545438c2d8f2410e Mon Sep 17 00:00:00 2001 From: jow Date: Tue, 4 May 2010 21:00:14 +0000 Subject: [generic-2.4] add OCF 20100325 support to brcm-2.4 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@21357 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../files/crypto/ocf/kirkwood/cesa/AES/mvAesApi.c | 312 +++++++++++++++++++++ 1 file changed, 312 insertions(+) create mode 100644 target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/AES/mvAesApi.c (limited to 'target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/AES/mvAesApi.c') diff --git a/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/AES/mvAesApi.c b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/AES/mvAesApi.c new file mode 100644 index 000000000..b432dc6e6 --- /dev/null +++ b/target/linux/generic-2.4/files/crypto/ocf/kirkwood/cesa/AES/mvAesApi.c @@ -0,0 +1,312 @@ +/* rijndael-api-ref.c v2.1 April 2000 + * Reference ANSI C code + * authors: v2.0 Paulo Barreto + * Vincent Rijmen, K.U.Leuven + * v2.1 Vincent Rijmen, K.U.Leuven + * + * This code is placed in the public domain. + */ +#include "mvOs.h" + +#include "mvAes.h" +#include "mvAesAlg.h" + + +/* Defines: + Add any additional defines you need +*/ + +#define MODE_ECB 1 /* Are we ciphering in ECB mode? */ +#define MODE_CBC 2 /* Are we ciphering in CBC mode? */ +#define MODE_CFB1 3 /* Are we ciphering in 1-bit CFB mode? */ + + +int aesMakeKey(MV_U8 *expandedKey, MV_U8 *keyMaterial, int keyLen, int blockLen) +{ + MV_U8 W[MAXROUNDS+1][4][MAXBC]; + MV_U8 k[4][MAXKC]; + MV_U8 j; + int i, rounds, KC; + + if (expandedKey == NULL) + { + return AES_BAD_KEY_INSTANCE; + } + + if (!((keyLen == 128) || (keyLen == 192) || (keyLen == 256))) + { + return AES_BAD_KEY_MAT; + } + + if (keyMaterial == NULL) + { + return AES_BAD_KEY_MAT; + } + + /* initialize key schedule: */ + for(i=0; i