AES test modified.
git-svn-id: https://pdfminerr.googlecode.com/svn/trunk/pdfminer@69 1aa58f4a-7d42-0410-adbc-911cccaed67cpull/1/head
parent
68eb528ff8
commit
2694de9521
|
@ -690,7 +690,7 @@ rcon = [
|
||||||
# 128-bit blocks, Rijndael never uses more than 10 rcon values
|
# 128-bit blocks, Rijndael never uses more than 10 rcon values
|
||||||
]
|
]
|
||||||
|
|
||||||
if sys.maxint == 2147483647:
|
if len(pack('L',0)) == 4:
|
||||||
# 32bit
|
# 32bit
|
||||||
def GETU32(x): return unpack('>L', x)[0]
|
def GETU32(x): return unpack('>L', x)[0]
|
||||||
def PUTU32(x): return pack('>L', x)
|
def PUTU32(x): return pack('>L', x)
|
||||||
|
@ -1056,11 +1056,13 @@ class RijndaelEncryptor(object):
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
# test
|
# test
|
||||||
key = 'ousamanomimiwarobanomimi12345678' # 32bytes
|
key = '00010203050607080A0B0C0D0F101112'.decode('hex')
|
||||||
plaintext = 'TakeyabuYaketa!?' # 16bytes
|
plaintext = '506812A45F08C889B97F5980038B8359'.decode('hex')
|
||||||
e = RijndaelEncryptor(key)
|
ciphertext = 'D8F532538289EF7D06B506A4FD5BE9C9'.decode('hex')
|
||||||
ciphertext = e.encrypt(plaintext)
|
e = RijndaelEncryptor(key, 128)
|
||||||
d = RijndaelDecryptor(key)
|
text = e.encrypt(plaintext)
|
||||||
|
assert text == ciphertext
|
||||||
|
d = RijndaelDecryptor(key, 128)
|
||||||
text = d.decrypt(ciphertext)
|
text = d.decrypt(ciphertext)
|
||||||
assert text == plaintext
|
assert text == plaintext
|
||||||
return 0
|
return 0
|
||||||
|
|
Loading…
Reference in New Issue