MCPcopy Create free account
hub / github.com/secdev/scapy / MS_CHAP2_ChallengeResponse

Function MS_CHAP2_ChallengeResponse

scapy/layers/radius.py:1460–1479  ·  view source on GitHub ↗

rfc 2759 sect 8.5

(Challenge, PasswordHash)

Source from the content-addressed store, hash-verified

1458
1459
1460def 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
1482def MS_CHAP2_GenerateAuthenticatorResponse(HashNT,

Callers 1

Calls 2

Cipher_DES_ECBClass · 0.90
encryptMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…