Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ac:laboratoare:09 [2024/12/15 06:14]
dimitrie.valu [5. Transaction authentication (2p)]
ac:laboratoare:09 [2024/12/15 06:42] (current)
dimitrie.valu
Line 321: Line 321:
 </​note>​ </​note>​
  
-<​hidden>​ +<solution -hidden>​ 
-==== Getting ​data from your card ====+We should allow students to select the data somewhat arbitrarily as it's not **entirely** provided in the exercises above, as per the minimum spec mentioned in EMV Book 2, page 87, section 8.1.1, table 28.
  
-First, get pyscard from +<code python> 
-[[https://​pypi.python.org/​pypi/​pyscard|here]].+from Crypto.Cipher import DES3 
 +from Crypto.Util.Padding import pad
  
-Then, install pyscard ​(check the readme). Do the following ​(as root)+master_key = bytes.fromhex("​79610497EFCB67E5546EF8CEBCB05D85"​) 
-  * Install pcsclite-dev:​ +aip = bytes.fromhex("​1000"​)
-<​code>​ +
-sudo apt-get install libpcsclite-dev +
-</​code>​ +
-  * Only if the above doesn'​t work, then install these packages: +
-<​code>​ +
-#apt-get install swig libudev-dev git autoconf libtool libsystemd-dev flex +
-</​code>​ +
-  * Get and install Pyscard from [[https://​pypi.python.org/​pypi/​pyscard|here]] +
-<​code>​ +
-#python setup.py build_ext install +
-</​code>​ +
-  * Install Pyserial +
-<​code>​ +
-#sudo pip install pyserial +
-</​code>​ +
-If this doesn'​t work, then get pyserial from [[https://​pypi.python.org/​pypi/​pyserial#​downloads|here]] +
-  * Install pcsc related libs: +
-<​code>​ +
-sudo apt-get install libusb-dev libusb++-0.1-4v5 libccid pcscd libpcsclite1 +
-</​code>​ +
-  * Only if desired, additional tools can be installed from here: +
-<​code>​ +
-#apt-get install libpcsc-perl +
-#apt-get install pcsc-tools  +
-</​code>​ +
-See details [[http://​support.gemalto.com/​fileadmin/​user_upload/​IAM/​FAQ/​How_to_install_the_PC-Link_reader_on_Linux.pdf|here]].+
  
 +# concatenation of amount authorised and amount other,
 +# terminal country code, transaction currency code,
 +# transaction date, transaction type,
 +# unpredictable number, given AIP and the ATC
 +# we aren't given the terminal verification results,
 +# so I assumed that it's gonna be 5 * b'​00'​
 +transaction_data = bytes.fromhex(
 +        "​00000000000000000000000008000000000000000000000034000000000000000010000134"​
 +        ) # from task 5
  
 +# 3DES block size is 8 bytes
 +padded_data = pad(transaction_data,​ 8)
  
-Files for accessing card data [[https://​ocw.cs.pub.ro/​courses/​_media/​ac/​laboratoare/​sclink.zip|here]]+# 3DES encryption 
-</hidden>+cipher = DES3.new(master_key,​ DES3.MODE_ECB) 
 +mac = cipher.encrypt(padded_data) 
 + 
 +mac = mac.hex() 
 +print(mac) 
 +</​code>​ 
 +</solution>
  
ac/laboratoare/09.1734236066.txt.gz · Last modified: 2024/12/15 06:14 by dimitrie.valu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0