X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=algos%2Fmd2.c;fp=algos%2Fmd2.c;h=338005c40c05937ad91716d771979f37d9285d46;hb=4fbc2e2a3aa83de683dd440f9036ced5d5879071;hp=9b8ae63e2eb20d796e0e29203cc87ffdb08bd787;hpb=2d431f6b24f78f78ae0cf4de51a1b5a8bc63968d;p=bertos.git diff --git a/algos/md2.c b/algos/md2.c index 9b8ae63e..338005c4 100755 --- a/algos/md2.c +++ b/algos/md2.c @@ -13,6 +13,9 @@ /*#* *#* $Log$ + *#* Revision 1.10 2007/02/02 15:37:45 asterix + *#* Change md2_end prototype. Remove a unneeded memcpy in md2_end. Add comments. + *#* *#* Revision 1.9 2007/02/02 13:10:01 asterix *#* Fix some bugs in md2_pad and md2_update fuction. *#* @@ -196,36 +199,33 @@ void md2_update(Md2Context *context, void *_block_in, size_t block_len) } /** - * Ends MD2 message digest operation, writing the message digest and cleaning context. + * Ends an MD2 message digest operation. + * This fuction take an context and return a pointer + * to context state. + * + * \param context in input. + * \return a pointer to context state (message digest). */ -void md2_end(Md2Context *context, void *msg_digest) +uint8_t *md2_end(Md2Context *context) { + uint8_t buf[CONFIG_MD2_BLOCK_LEN]; /* - * Pad remaning context buffer. + * Fill remaning empty context buffer. */ md2_pad(buf, CONFIG_MD2_BLOCK_LEN - context->counter); /* - * Update context and checksum. + * Update context buffer and compute it. */ md2_update(context, buf, CONFIG_MD2_BLOCK_LEN - context->counter); - memcpy(buf, context->checksum, CONFIG_MD2_BLOCK_LEN); - - md2_update(context, buf, CONFIG_MD2_BLOCK_LEN); - /* - * Copy first CONFIG_MD2_BLOCK_LEN byte of context's state - * in msg_digest. The msg_digest is the message digest of - * MD2 algorithm. + * Add context checksum to message input. */ - memcpy(msg_digest, context->state, CONFIG_MD2_BLOCK_LEN); + md2_update(context, context->checksum, CONFIG_MD2_BLOCK_LEN); - /* - * Clean the context. - */ - memset(context, 0, sizeof(context)); + return context->state; //return a pointer to message digest. }