rfc 2759 sect 8.5
(Challenge, PasswordHash)
| 1458 | |
| 1459 | |
| 1460 | def MS_CHAP2_ChallengeResponse(Challenge, PasswordHash): |
| 1461 | """ |
| 1462 | rfc 2759 sect 8.5 |
| 1463 | """ |
| 1464 | ZPasswordHash = int.from_bytes( |
| 1465 | PasswordHash + b"\x00" * (-len(PasswordHash) % 21), |
| 1466 | "big", |
| 1467 | ) |
| 1468 | |
| 1469 | # Add !FAKE! DES parity bits because cryptography requires them (then drops them) |
| 1470 | ZPasswordHashParity = b"" |
| 1471 | for _ in range(24): |
| 1472 | val, ZPasswordHash = (ZPasswordHash & 0x7F), (ZPasswordHash >> 7) |
| 1473 | ZPasswordHashParity = struct.pack("B", val << 1) + ZPasswordHashParity |
| 1474 | |
| 1475 | return ( |
| 1476 | Cipher_DES_ECB(ZPasswordHashParity[0:8]).encrypt(Challenge) + |
| 1477 | Cipher_DES_ECB(ZPasswordHashParity[8:16]).encrypt(Challenge) + |
| 1478 | Cipher_DES_ECB(ZPasswordHashParity[16:24]).encrypt(Challenge) |
| 1479 | ) |
| 1480 | |
| 1481 | |
| 1482 | def MS_CHAP2_GenerateAuthenticatorResponse(HashNT, |
no test coverage detected
searching dependent graphs…