smartpgp-cli: get KDF-DO
This commit is contained in:
parent
e720a23417
commit
4796f6ea78
@ -46,6 +46,7 @@ VALID_COMMANDS={
|
||||
'put-aes-key': CardConnectionContext.cmd_put_aes_key,
|
||||
'encrypt-aes': CardConnectionContext.cmd_encrypt_aes,
|
||||
'decrypt-aes': CardConnectionContext.cmd_decrypt_aes,
|
||||
'get-kdf': CardConnectionContext.cmd_get_kdf,
|
||||
'set-kdf': CardConnectionContext.cmd_set_kdf,
|
||||
}
|
||||
|
||||
|
@ -348,3 +348,9 @@ def put_kdf_do(connection, kdf_do):
|
||||
data = kdf_do
|
||||
apdu = assemble_with_len(prefix, data)
|
||||
_raw_send_apdu(connection,"Put KDF-DO",apdu)
|
||||
|
||||
|
||||
def get_kdf_do(connection):
|
||||
apdu = [0x00, 0xCA, 0x00, 0xF9, 0x00]
|
||||
(data,sw1,sw2) = _raw_send_apdu(connection,"Get KDF-DO",apdu)
|
||||
return (data,sw1,sw2)
|
||||
|
@ -309,3 +309,13 @@ class CardConnectionContext:
|
||||
self.verify_admin_pin()
|
||||
put_kdf_do(self.connection, kdf_do)
|
||||
|
||||
def cmd_get_kdf(self):
|
||||
if self.output is None:
|
||||
print "No output file"
|
||||
return
|
||||
self.connect()
|
||||
(kdf_do,_,_) = get_kdf_do(self.connection)
|
||||
kdf_do = "".join([chr(c) for c in kdf_do])
|
||||
with open(self.output, 'w') as f:
|
||||
f.write(kdf_do)
|
||||
f.close()
|
||||
|
Loading…
Reference in New Issue
Block a user