Differences From Artifact [210a4456e6]:
- File
src/OFMD5Hash.m
— part of check-in
[23dc2c7ff8]
at
2014-09-01 10:47:15
on branch trunk
— OF{MD5,SHA1}Hash: Zero _buffer when done
This way, possibly sensitive information is discarded from memory as
soon as possible. (user: js, size: 4654) [annotate] [blame] [check-ins using]
To Artifact [8c6a093adf]:
- File
src/OFMD5Hash.m
— part of check-in
[46af1252a5]
at
2014-09-01 11:08:43
on branch trunk
— Add OFSHA256Hash
Took me some time to figure out the RFC is buggy and SSIG0(t-15) should
be SSIG0(W(t-15))... (user: js, size: 4648) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
23 24 25 26 27 28 29 | #import "OFHashAlreadyCalculatedException.h" #define F(a, b, c) (((a) & (b)) | (~(a) & (c))) #define G(a, b, c) (((a) & (c)) | ((b) & ~(c))) #define H(a, b, c) ((a) ^ (b) ^ (c)) #define I(a, b, c) ((b) ^ ((a) | ~(c))) | | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #import "OFHashAlreadyCalculatedException.h" #define F(a, b, c) (((a) & (b)) | (~(a) & (c))) #define G(a, b, c) (((a) & (c)) | ((b) & ~(c))) #define H(a, b, c) ((a) ^ (b) ^ (c)) #define I(a, b, c) ((b) ^ ((a) | ~(c))) static const uint32_t table[] = { 0xD76AA478, 0xE8C7B756, 0x242070DB, 0xC1BDCEEE, 0xF57C0FAF, 0x4787C62A, 0xA8304613, 0xFD469501, 0x698098D8, 0x8B44F7AF, 0xFFFF5BB1, 0x895CD7BE, 0x6B901122, 0xFD987193, 0xA679438E, 0x49B40821, 0xF61E2562, 0xC040B340, 0x265E5A51, 0xE9B6C7AA, 0xD62F105D, 0x02441453, 0xD8A1E681, 0xE7D3FBC8, |
︙ | ︙ | |||
88 89 90 91 92 93 94 | const uint_fast8_t a = (4 - (i & 3)) & 3; \ const uint_fast8_t b = (a + 1) & 3; \ const uint_fast8_t c = (a + 2) & 3; \ const uint_fast8_t d = (a + 3) & 3; \ const uint_fast8_t r = rotateBits[(i % 4) + (i / 16) * 4]; \ \ new[a] += f(new[b], new[c], new[d]) + \ | | | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | const uint_fast8_t a = (4 - (i & 3)) & 3; \ const uint_fast8_t b = (a + 1) & 3; \ const uint_fast8_t c = (a + 2) & 3; \ const uint_fast8_t d = (a + 3) & 3; \ const uint_fast8_t r = rotateBits[(i % 4) + (i / 16) * 4]; \ \ new[a] += f(new[b], new[c], new[d]) + \ buffer[wordOrder[i]] + table[i]; \ new[a] = OF_ROL(new[a], r); \ new[a] += new[b]; \ } for (; i < 16; i++) LOOP_BODY(F) for (; i < 32; i++) |
︙ | ︙ |