Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Smith <brian@briansmith.org>2015-11-01 23:13:24 +0300
committerAdam Langley <agl@google.com>2015-11-03 05:04:38 +0300
commit00461cf201b66205653fd6159ae260f453738641 (patch)
tree656151ba243139bf71ee1cfa1712c7fb75ee4c60 /crypto/md4
parentecc2591b6cbb376dfa0ea1dfce35f1f172ffd0d5 (diff)
Improve crypto/digest/md32_common.h mechanism.
The documentation in md32_common.h is now (more) correct with respect to the most important details of the layout of |HASH_CTX|. The documentation explaining why sha512.c doesn't use md32_common.h is now more accurate as well. Before, the C implementations of HASH_BLOCK_DATA_ORDER took a pointer to the |HASH_CTX| and the assembly language implementations tool a pointer to the hash state |h| member of |HASH_CTX|. (This worked because |h| is always the first member of |HASH_CTX|.) Now, the C implementations take a pointer directly to |h| too. The definitions of |MD4_CTX|, |MD5_CTX|, and |SHA1_CTX| were changed to be consistent with |SHA256_CTX| and |SHA512_CTX| in storing the hash state in an array. This will break source compatibility with any external code that accesses the hash state directly, but will not affect binary compatibility. The second parameter of |HASH_BLOCK_DATA_ORDER| is now of type |const uint8_t *|; previously it was |void *| and all implementations had a |uint8_t *data| variable to access it as an array of bytes. This change paves the way for future refactorings such as automatically generating the |*_Init| functions and/or sharing one I-U-F implementation across all digest algorithms. Change-Id: I30513bb40b5f1d2c8932551d54073c35484b3f8b Reviewed-on: https://boringssl-review.googlesource.com/6401 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/md4')
-rw-r--r--crypto/md4/md4.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/crypto/md4/md4.c b/crypto/md4/md4.c
index 5ef9ae51..0a8ea1d6 100644
--- a/crypto/md4/md4.c
+++ b/crypto/md4/md4.c
@@ -64,18 +64,17 @@
int MD4_Init(MD4_CTX *md4) {
memset(md4, 0, sizeof(MD4_CTX));
- md4->A = 0x67452301UL;
- md4->B = 0xefcdab89UL;
- md4->C = 0x98badcfeUL;
- md4->D = 0x10325476UL;
+ md4->h[0] = 0x67452301UL;
+ md4->h[1] = 0xefcdab89UL;
+ md4->h[2] = 0x98badcfeUL;
+ md4->h[3] = 0x10325476UL;
return 1;
}
-void md4_block_data_order (MD4_CTX *md4, const void *p, size_t num);
+void md4_block_data_order(uint32_t *state, const uint8_t *data, size_t num);
#define DATA_ORDER_IS_LITTLE_ENDIAN
-#define HASH_LONG uint32_t
#define HASH_CTX MD4_CTX
#define HASH_CBLOCK 64
#define HASH_UPDATE MD4_Update
@@ -84,13 +83,13 @@ void md4_block_data_order (MD4_CTX *md4, const void *p, size_t num);
#define HASH_MAKE_STRING(c, s) \
do { \
uint32_t ll; \
- ll = (c)->A; \
+ ll = (c)->h[0]; \
(void) HOST_l2c(ll, (s)); \
- ll = (c)->B; \
+ ll = (c)->h[1]; \
(void) HOST_l2c(ll, (s)); \
- ll = (c)->C; \
+ ll = (c)->h[2]; \
(void) HOST_l2c(ll, (s)); \
- ll = (c)->D; \
+ ll = (c)->h[3]; \
(void) HOST_l2c(ll, (s)); \
} while (0)
#define HASH_BLOCK_DATA_ORDER md4_block_data_order
@@ -122,15 +121,14 @@ void md4_block_data_order (MD4_CTX *md4, const void *p, size_t num);
a = ROTATE(a, s); \
};
-void md4_block_data_order(MD4_CTX *c, const void *data_, size_t num) {
- const uint8_t *data = data_;
+void md4_block_data_order(uint32_t *state, const uint8_t *data, size_t num) {
uint32_t A, B, C, D, l;
uint32_t X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15;
- A = c->A;
- B = c->B;
- C = c->C;
- D = c->D;
+ A = state[0];
+ B = state[1];
+ C = state[2];
+ D = state[3];
for (; num--;) {
HOST_c2l(data, l);
@@ -217,9 +215,9 @@ void md4_block_data_order(MD4_CTX *c, const void *data_, size_t num) {
R2(C, D, A, B, X7, 11, 0x6ED9EBA1L);
R2(B, C, D, A, X15, 15, 0x6ED9EBA1L);
- A = c->A += A;
- B = c->B += B;
- C = c->C += C;
- D = c->D += D;
+ A = state[0] += A;
+ B = state[1] += B;
+ C = state[2] += C;
+ D = state[3] += D;
}
}