diff options
Diffstat (limited to 'utils')
-rwxr-xr-x | utils/last_gasp_default_pin | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/utils/last_gasp_default_pin b/utils/last_gasp_default_pin index 8a91b8a..4dd1d54 100755 --- a/utils/last_gasp_default_pin +++ b/utils/last_gasp_default_pin @@ -44,6 +44,7 @@ generates the default. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter +from binascii import hexlify from os import urandom from Crypto.Protocol.KDF import PBKDF2 from Crypto.Hash import SHA256, HMAC @@ -65,9 +66,6 @@ args = parser.parse_args() def HMAC_SHA256(pin, salt): return HMAC.new(pin, salt, SHA256).digest() -def hexify(value): - return ", ".join("0x%02x" % ord(v) for v in value) - salt = urandom(16) pin = PBKDF2(password = args.pin, @@ -76,7 +74,7 @@ pin = PBKDF2(password = args.pin, count = args.iterations, prf = HMAC_SHA256) -print '''\ +print('''\ /* * Automatically generated by a script, do not edit. */ @@ -86,5 +84,5 @@ static const hal_ks_pin_t hal_last_gasp_pin = {{ {{{pin}}}, {{{salt}}} }};'''.format(iterations = args.iterations, - pin = hexify(pin), - salt = hexify(salt)) + pin = ", ".join(hexlify(v) for v in pin), + salt = ", ".join(hexlify(v) for v in salt))) |