smartpgp-cli: set KDF-DO

This commit is contained in:
Arnaud Fontaine 2018-02-09 10:53:10 +01:00
parent c60c4d7c32
commit e720a23417
3 changed files with 20 additions and 0 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,
'set-kdf': CardConnectionContext.cmd_set_kdf,
}
def read_pin_interactive(name):

View File

@ -341,3 +341,10 @@ def decrypt_aes(connection, msg):
(nres,sw1,sw2) = _raw_send_apdu(connection,"Receiving decrypted chunk",apdu)
res = res + nres
return (res,sw1,sw2)
def put_kdf_do(connection, kdf_do):
prefix = [0x00, 0xDA, 0x00, 0xF9]
data = kdf_do
apdu = assemble_with_len(prefix, data)
_raw_send_apdu(connection,"Put KDF-DO",apdu)

View File

@ -297,3 +297,15 @@ class CardConnectionContext:
f.write(data)
f.close()
def cmd_set_kdf(self):
if self.input is None:
print "No input KDF-DO"
return
f = open(self.input, 'r')
kdf_do = f.read()
kdf_do = [ord(c) for c in kdf_do]
f.close()
self.connect()
self.verify_admin_pin()
put_kdf_do(self.connection, kdf_do)