aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2020-05-25 19:33:38 -0400
committerRob Austein <sra@hactrn.net>2020-05-25 19:33:38 -0400
commit1cd42f6d3332e1edf78b06bd7dcf51f5a1a7bb23 (patch)
tree1eca75f12e53763e223856d46bc1ab4224079086 /utils
parentaab1cf4d694b4d4fefa77f02b4c42d7683a2f43f (diff)
Untested conversion to support Python 3
Diffstat (limited to 'utils')
-rwxr-xr-xutils/last_gasp_default_pin10
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)))