From a5c68f1e55ab389a3472f761664021fe684935f2 Mon Sep 17 00:00:00 2001 From: asterix Date: Wed, 31 Jan 2007 13:51:57 +0000 Subject: [PATCH] Write md2_compute function. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@747 38d2e660-2303-0410-9eaa-f027e97ec537 --- algos/md2.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/algos/md2.c b/algos/md2.c index 13be3f22..9f4099da 100755 --- a/algos/md2.c +++ b/algos/md2.c @@ -13,8 +13,8 @@ /*#* *#* $Log$ - *#* Revision 1.3 2007/01/31 10:31:04 asterix - *#* Write md2_pad funtion. + *#* Revision 1.4 2007/01/31 13:51:57 asterix + *#* Write md2_compute function. *#* *#* Revision 1.2 2007/01/30 17:31:44 asterix *#* Add function prototypes. @@ -57,7 +57,7 @@ static uint8_t md2_perm[256] = /** * Pad function. Fill input array with unsigned char until * lenght of block is equal to CONFIG_MD2_BLOCK_LEN. - * + * */ static void md2_pad(void *block, size_t len_pad) { @@ -72,7 +72,50 @@ static void md2_pad(void *block, size_t len_pad) static void md2_compute(void *state, void *checksum, void *block) { + int t=0; + uint8_t compute_array[CONFIG_MD2_BLOCK_LEN * 3]; + + /* + * Copy state and checksum context in compute array. + */ + memcpy(compute_array, state, CONFIG_MD2_BLOCK_LEN); + memcpy(compute_array + CONFIG_MD2_BLOCK_LEN, state, CONFIG_MD2_BLOCK_LEN); + + /* + * Fill compute array with state XOR block + */ + for(int i=0; i< CONFIG_MD2_BLOCK_LEN; i++) + compute_array[i + (CONFIG_MD2_BLOCK_LEN * 2)] = state[i] ^ block[i]; + + /* + * Encryt block. + */ + for(i=0; i