smartpgp-cli: get KDF-DO

This commit is contained in:
Arnaud Fontaine 2018-02-09 10:56:51 +01:00
parent e720a23417
commit 4796f6ea78
3 changed files with 18 additions and 1 deletions

View File

@ -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,
}

View File

@ -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)

View File

@ -308,4 +308,14 @@ class CardConnectionContext:
self.connect()
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()