Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

jcoptool/mifarekeys: DES needs now an explicit IV value, we can use r…

…fidiot.DES_IV
  • Loading branch information...
commit 36ec0c6c817a7a2e051d564c043a1bc54cbf0a51 1 parent c489ca3
@doegox doegox authored
Showing with 4 additions and 4 deletions.
  1. +3 −3 jcoptool.py
  2. +1 −1  mifarekeys.py
View
6 jcoptool.py
@@ -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,'\x00'*8)
+ e_enc= DES3.new(card.ToBinary(enc_key),DES3.MODE_CBC,card.DES_IV)
enc_s_key= e_enc.encrypt(card.ToBinary(derivation_data))
# data for cryptograms
card_cryptogram_source= host_challenge + card_sc_sequence_counter + card_challenge
@@ -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,'\x00'*8)
+ s_enc= DES3.new(enc_s_key,DES3.MODE_CBC,card.DES_IV)
# 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,'\x00'*8)
+ e_enc= DES3.new(card.ToBinary(mac_key),DES3.MODE_CBC,card.DES_IV)
# create C-MAC session key
derivation_data= '0101' + card_sc_sequence_counter + session_pad
cmac_s_key= e_enc.encrypt(card.ToBinary(derivation_data))
View
2  mifarekeys.py
@@ -116,7 +116,7 @@ def HexArray(data):
# build key MSB first
for n in range(len(newkeyA+newkeyB+newkeyA)-2,-2,-2):
deskeyABA += chr(int((newkeyA+newkeyB+newkeyA)[n:n + 2],16))
-des3= DES3.new(deskeyABA,DES.MODE_CBC)
+des3= DES3.new(deskeyABA,DES.MODE_CBC,'\0\0\0\0\0\0\0\0')
mifarePWD= des3.encrypt('\0\0\0\0\0\0\0\0')
# reverse LSB/MSB for final output
mifarePWDout= ''
Please sign in to comment.
Something went wrong with that request. Please try again.