projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Change md2_end prototype. Remove a unneeded memcpy in md2_end. Add comments.
[bertos.git]
/
algos
/
md2.c
diff --git
a/algos/md2.c
b/algos/md2.c
index 9b8ae63e2eb20d796e0e29203cc87ffdb08bd787..338005c40c05937ad91716d771979f37d9285d46 100755
(executable)
--- a/
algos/md2.c
+++ b/
algos/md2.c
@@
-13,6
+13,9
@@
/*#*
*#* $Log$
/*#*
*#* $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.
*#*
*#* 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_diges
t)
+
uint8_t *md2_end(Md2Context *contex
t)
{
{
+
uint8_t buf[CONFIG_MD2_BLOCK_LEN];
/*
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);
/*
*/
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);
*/
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.
*/
*/
- m
emcpy(msg_digest, context->state
, CONFIG_MD2_BLOCK_LEN);
+ m
d2_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.
}
}