-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchallenge15.py
More file actions
31 lines (27 loc) · 1.04 KB
/
challenge15.py
File metadata and controls
31 lines (27 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
# PKCS#7 padding validation
from utils import ans_check
from padding import pkcs7_unpad
# --------------------------------------------------------
# ---------------------- functions -----------------------
# --------------------------------------------------------
# --------------------------------------------------------
# ------------------------- main -------------------------
# --------------------------------------------------------
def main():
# case1
ans_check(b"ICE ICE BABY", pkcs7_unpad(b"ICE ICE BABY\x04\x04\x04\x04"))
# case2
try:
ans_check(b"ICE ICE BABY\x05\x05\x05\x05", pkcs7_unpad(b"ICE ICE BABY\x05\x05\x05\x05"))
except ValueError as err:
print(err)
ans_check(err.args[1], b"ICE ICE BABY\x05\x05\x05\x05")
# case3
try:
ans_check(b"ICE ICE BABY\x01\x02\x03\x04", pkcs7_unpad(b"ICE ICE BABY\x01\x02\x03\x04"))
except ValueError as err:
print(err)
ans_check(err.args[1], b"ICE ICE BABY\x01\x02\x03\x04")
if __name__ == "__main__":
main()