fix: error in reference
This commit is contained in:
parent
331ed1750f
commit
9133601088
1 changed files with 21 additions and 18 deletions
|
@ -37,7 +37,8 @@ void md2_checksum(size_t len, uint8_t* buf) {
|
||||||
for (int i = 0; i < len / 16; i++) {
|
for (int i = 0; i < len / 16; i++) {
|
||||||
for (int j = 0; j < 16; j++) {
|
for (int j = 0; j < 16; j++) {
|
||||||
u_int8_t c = buf[i * 16 + j];
|
u_int8_t c = buf[i * 16 + j];
|
||||||
l = buf[len + j] = PI_SUBST[c ^ l];
|
// reference is wrong. It says: Set C[j] to S[c xor L]. But it should be:
|
||||||
|
l = buf[len + j] ^= PI_SUBST[c ^ l];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,6 +55,8 @@ void md2_hash(size_t len, const uint8_t buf[len], uint8_t out[16]) {
|
||||||
uint8_t* newBuf = calloc(len + 16, sizeof(uint8_t));
|
uint8_t* newBuf = calloc(len + 16, sizeof(uint8_t));
|
||||||
memcpy(newBuf, buf, len - paddingNeeded);
|
memcpy(newBuf, buf, len - paddingNeeded);
|
||||||
|
|
||||||
|
printBuf(len + 16, newBuf);
|
||||||
|
|
||||||
while (paddingNeeded > 0) {
|
while (paddingNeeded > 0) {
|
||||||
newBuf[len - paddingNeeded] = originalPadding;
|
newBuf[len - paddingNeeded] = originalPadding;
|
||||||
paddingNeeded--;
|
paddingNeeded--;
|
||||||
|
|
Loading…
Reference in a new issue