29.01.2015 Views

Applications & SmartCard : JavaCard - Identification - LIFL

Applications & SmartCard : JavaCard - Identification - LIFL

Applications & SmartCard : JavaCard - Identification - LIFL

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Javacard.Security<br />

• Key<br />

Base interface for all keys<br />

• DESKey<br />

Contains an 8/16/24 byte key<br />

• single / 2 keys triple DES / 3 keys triple DES operations<br />

Declaration :<br />

Javacard.Security<br />

Example<br />

private Cipher myDESAlgo;<br />

private DESKey myDESKey;<br />

• DSAKey<br />

Base interface for the DSA algorithms<br />

• private and public key implementations<br />

http://www.lifl.fr/~grimaud/Cours<br />

<strong>JavaCard</strong> System & Framework 69<br />

http://www.lifl.fr/~grimaud/Cours<br />

<strong>JavaCard</strong> System & Framework 70<br />

Initialisation :<br />

Javacard.Security<br />

Example<br />

// produce/select the algo<br />

myDESAlgo = Cipher.getInstance(<br />

Cipher.ALG_DES_ECB_NOPAD,<br />

false);<br />

// produce the key<br />

myDESKey = (DESKey)KeyBuilder.buildKey(<br />

KeyBuilder.TYPE_DES,<br />

KeyBuilder.LENGTH_DES3_2KEY,<br />

false);<br />

// init the key<br />

myDESKey.setKey(<br />

buffer,<br />

dataOffset);<br />

Use :<br />

Javacard.Security<br />

Example<br />

// DES encryption<br />

// initialize algorithm with default key<br />

myDESAlgo.init(<br />

myDESKey,<br />

Cipher.MODE_ENCRYPT);<br />

// compute DES on data<br />

myDESAlgo.doFinal(<br />

buffer,<br />

(short)ISO7816.OFFSET_CDATA,<br />

count,<br />

buffer,<br />

(short)0);<br />

http://www.lifl.fr/~grimaud/Cours<br />

<strong>JavaCard</strong> System & Framework 71<br />

http://www.lifl.fr/~grimaud/Cours<br />

<strong>JavaCard</strong> System & Framework 72

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!