diff options
Diffstat (limited to 'test/tpm_test/genvectors.py')
-rwxr-xr-x[-rw-r--r--] | test/tpm_test/genvectors.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/test/tpm_test/genvectors.py b/test/tpm_test/genvectors.py index 593a6aab71..85c9b8a200 100644..100755 --- a/test/tpm_test/genvectors.py +++ b/test/tpm_test/genvectors.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# -*- coding: utf-8 -*- # Copyright 2016 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -6,9 +7,9 @@ """Module for generating AES test vectors.""" from binascii import b2a_hex as b2a -from Crypto.Cipher import AES from itertools import izip_longest import os +from Crypto.Cipher import AES modes = { AES.MODE_CBC: 'CBC', @@ -17,7 +18,7 @@ modes = { } template = \ -''' +""" <crypto_test name="AES:{mode}{key_bits} {test_num}"> <clear_text format="hex"> {pt} @@ -32,11 +33,14 @@ template = \ {iv} </iv> </crypto_test> -''' +""" def h2be(v): - # Convert input big-endian byte-string to 4-byte segmented - # little-endian words. Pad-bytes (if necessary) are the empty string. + """Convert input big-endian byte-string to 4-byte segmented + + Convert input big-endian byte-string to 4-byte segmented + little-endian words. Pad-bytes (if necessary) are the empty string. + """ word = [iter(v)] * 4 return ''.join([ ''.join(b[::-1]) for b in izip_longest(*word, fillvalue='') @@ -73,5 +77,3 @@ for mode in [AES.MODE_CBC, AES.MODE_CFB, AES.MODE_OFB]: key=b2a(h2be(key)), ct=b2a(h2be(ct[:actual_pt_len])), iv=b2a(h2be(iv))), - - |