python - Pycrypto AES-CTR implementation -
python - Pycrypto AES-CTR implementation -
i new python , pycrypto. trying implement aes-ctr. check programme right ciphering tried utilize test sequences nist sp 800-38a standard (section f.5). not right result. doing wrong?
from crypto.cipher import aes crypto.utils import counter ctrkey="2b7e151628aed2a6abf7158809cf4f3c" ctr=counter.new(128, initial_value=int("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff",16)) cipherctr=aes.new(ctrkey, aes.mode_ctr, counter=ctr) print(cipherctr.encrypt("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff".decode("hex")).encode("hex"))
result:
0008007df81ad564b9aadd6b883fef16
but expected result (ciphertext) is:
874d6191b620e3261bef6864990db6ce
in nist sp 800-38a standard (section f.5.1), input ctr-aes128 encryption operation called plaintext not input block.
if utilize plaintext (6bc1bee22e409f96e93d7e117393172a
) right result, ciphertext 874d6191b620e3261bef6864990db6ce
.
python encryption cryptography aes pycrypto
Comments
Post a Comment