File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# coding: utf-8
22from __future__ import unicode_literals , print_function
33
4+ import base64
5+ import binascii
46import time
57import logging
68import os
@@ -121,7 +123,6 @@ def prompt_key():
121123 key = prompt ('Key: ' ,
122124 is_password = Condition (lambda cli : hidden [0 ]),
123125 key_bindings_registry = key_bindings_manager .registry )
124- #need base32 to hex conversion
125126 return key
126127
127128 def prompt_pin ():
@@ -201,6 +202,14 @@ def mprompt():
201202 only_key .setslot (slot_id , MessageField .DELAY3 , data [3 ])
202203 elif data [2 ] == 'type' :
203204 only_key .setslot (slot_id , MessageField .TFATYPE , data [3 ])
205+ elif data [2 ] == 'googletotpkey' :
206+ totpkey = prompt_key ()
207+ totpkey = base64 .b32decode (totpkey )
208+ totpkey = binascii .hexlify (totpkey )
209+ # pad with zeros for even digits
210+ totpkey = totpkey .zfill (len (totpkey ) + len (totpkey ) % 2 )
211+ payload = [int (totpkey [i : i + 2 ], 16 ) for i in range (0 , len (totpkey ), 2 )]
212+ only_key .setslot (slot_id , MessageField .TOTPKEY , payload )
204213 elif data [2 ] == 'totpkey' :
205214 totpkey = prompt_key ()
206215 only_key .setslot (slot_id , MessageField .TOTPKEY , totpkey )
You can’t perform that action at this time.
0 commit comments