Skip to content

Commit

Permalink
jcoptool: DES needs now an explicit IV value
Browse files Browse the repository at this point in the history
  • Loading branch information
doegox committed Jan 13, 2013
1 parent 1e7f673 commit 3e79672
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions jcoptool.py
Expand Up @@ -434,7 +434,7 @@ def decode_gp_registry_data(data, padding, filter):
session_pad= '000000000000000000000000'
derivation_data= '0182' + card_sc_sequence_counter + session_pad
# create encryption object with ENC key
e_enc= DES3.new(card.ToBinary(enc_key),DES3.MODE_CBC)
e_enc= DES3.new(card.ToBinary(enc_key),DES3.MODE_CBC,'\x00'*8)
enc_s_key= e_enc.encrypt(card.ToBinary(derivation_data))
# data for cryptograms
card_cryptogram_source= host_challenge + card_sc_sequence_counter + card_challenge
Expand All @@ -449,12 +449,12 @@ def decode_gp_registry_data(data, padding, filter):

# cryptogram checks out, so we can use session key
# create encryption object with ENC Session key
s_enc= DES3.new(enc_s_key,DES3.MODE_CBC)
s_enc= DES3.new(enc_s_key,DES3.MODE_CBC,'\x00'*8)

# authenticate to card
host_cryptogram= card.DES3MAC(card.ToBinary(host_cryptogram_source), enc_s_key, '')
# create encryption object with MAC key
e_enc= DES3.new(card.ToBinary(mac_key),DES3.MODE_CBC)
e_enc= DES3.new(card.ToBinary(mac_key),DES3.MODE_CBC,'\x00'*8)
# create C-MAC session key
derivation_data= '0101' + card_sc_sequence_counter + session_pad
cmac_s_key= e_enc.encrypt(card.ToBinary(derivation_data))
Expand Down

0 comments on commit 3e79672

Please sign in to comment.