| 1 | |
|---|
| 2 | OpenSC supports the Cryptoflex cards beginning with version 0.5.0. |
|---|
| 3 | |
|---|
| 4 | Cryptoflex specific features can be tested with cryptoflex-tool. |
|---|
| 5 | Due to the publicly available datasheets, cryptoflex-tool also includes |
|---|
| 6 | a PKCS #15 structure generator. At the moment all the encoded information |
|---|
| 7 | is hardcoded in the source file, but editing the structures should |
|---|
| 8 | be pretty straightforward. |
|---|
| 9 | |
|---|
| 10 | Here are the steps to PKCS #15 structure generation: |
|---|
| 11 | |
|---|
| 12 | WARNING: You should be using a very safe terminal when issuing the |
|---|
| 13 | following commands. |
|---|
| 14 | |
|---|
| 15 | 0. If you don't have a Cryptoflex 16k, you will have to add the ATR of |
|---|
| 16 | your card manually to the flex_atrs structure at the top of card-flex.c. |
|---|
| 17 | The ATR can be found with 'opensc-tool -a' command. You should mail |
|---|
| 18 | the ATR string to <juha.yrjola@iki.fi>, so it can be added in the |
|---|
| 19 | official distribution. |
|---|
| 20 | |
|---|
| 21 | 1. Verify the AAK key and CHV2: |
|---|
| 22 | |
|---|
| 23 | $ opensc-explorer |
|---|
| 24 | OpenSC Explorer version 0.5.0 |
|---|
| 25 | Connecting to card in reader Towitoko Chipdrive Micro 0 0... |
|---|
| 26 | Using card driver: Schlumberger Multiflex/Cryptoflex |
|---|
| 27 | OpenSC [3F00]> ver KEY1 01:02:03:04:05:06:07:08 # replace these |
|---|
| 28 | Code correct. |
|---|
| 29 | OpenSC [3F00]> ver CHV2 31:32:33:34:00:00:00:00 # with your own values |
|---|
| 30 | Code correct. |
|---|
| 31 | |
|---|
| 32 | 2. Create the CHV2 file, if not present: |
|---|
| 33 | |
|---|
| 34 | $ cryptoflex-tool -P 2 |
|---|
| 35 | Connecting to card in reader Towitoko Chipdrive Micro 0 0... |
|---|
| 36 | Using card driver: Schlumberger Multiflex/Cryptoflex |
|---|
| 37 | Please enter CHV2: 1234 |
|---|
| 38 | Please enter PUK for CHV2: 12345678 |
|---|
| 39 | |
|---|
| 40 | 3. Create the PKCS #15 structure |
|---|
| 41 | |
|---|
| 42 | $ cryptoflex-tool -C |
|---|
| 43 | Connecting to card in reader Towitoko Chipdrive Micro 0 0... |
|---|
| 44 | Using card driver: Schlumberger Multiflex/Cryptoflex |
|---|
| 45 | Please enter CHV1 (key 1): 1234 |
|---|
| 46 | Please enter PUK for CHV1 (key 1): 12345678 |
|---|
| 47 | Please enter CHV1 (key 2): 5678 |
|---|
| 48 | Please enter PUK for CHV1 (key 2): 12345678 |
|---|
| 49 | |
|---|
| 50 | 4. Generate two 1024-bit RSA key pairs with openssl: |
|---|
| 51 | |
|---|
| 52 | $ openssl genrsa -out key1.pem 1024 |
|---|
| 53 | Generating RSA private key, 1024 bit long modulus |
|---|
| 54 | ...........++++++ |
|---|
| 55 | ...++++++ |
|---|
| 56 | e is 65537 (0x10001) |
|---|
| 57 | $ openssl genrsa -out key2.pem 1024 |
|---|
| 58 | Generating RSA private key, 1024 bit long modulus |
|---|
| 59 | .....................++++++ |
|---|
| 60 | ....++++++ |
|---|
| 61 | e is 65537 (0x10001) |
|---|
| 62 | |
|---|
| 63 | 5. Create the files to hold the keys on the card: |
|---|
| 64 | |
|---|
| 65 | $ cryptoflex-tool -a 5015 -c 1 |
|---|
| 66 | $ cryptoflex-tool -a 4b02 -c 1 |
|---|
| 67 | |
|---|
| 68 | 6. Store the key pairs on the card: |
|---|
| 69 | |
|---|
| 70 | $ cryptoflex-tool -a 5015 -p key1.pem -s -v # (enter CHV1 for key 1) |
|---|
| 71 | $ cryptoflex-tool -a 4b02 -p key2.pem -s -v # (enter CHV1 for key 2) |
|---|
| 72 | |
|---|
| 73 | 6a. Check if the keys are working: |
|---|
| 74 | |
|---|
| 75 | $ pkcs15-crypt -i <plaintext-file> -o <signed-data> -s --pkcs1 |
|---|
| 76 | Connecting to card in reader Towitoko Chipdrive Micro 0 0... |
|---|
| 77 | Trying to find a PKCS#15 compatible card... |
|---|
| 78 | Found OpenSC Test Card! |
|---|
| 79 | Enter PIN [Authentication PIN]: |
|---|
| 80 | PIN code correct. |
|---|
| 81 | |
|---|
| 82 | 7. Create two certificates with openssl. Name them cert1.crt and cert2.crt.This process is not in the scope |
|---|
| 83 | of this document. |
|---|
| 84 | |
|---|
| 85 | 8. Store the DER-encoded certificates on the card (this process will be |
|---|
| 86 | automated in the future): |
|---|
| 87 | |
|---|
| 88 | $ opensc-explorer |
|---|
| 89 | OpenSC Explorer version 0.5.0 |
|---|
| 90 | Connecting to card in reader Towitoko Chipdrive Micro 0 0... |
|---|
| 91 | Using card driver: Schlumberger Multiflex/Cryptoflex |
|---|
| 92 | OpenSC [3F00]> cd 5015 |
|---|
| 93 | OpenSC [3F00/5015]> create 4301 <size of cert1.crt> |
|---|
| 94 | OpenSC [3F00/5015]> create 4302 <size of cert2.crt> |
|---|
| 95 | OpenSC [3F00/5015]> put 4301 cert1.crt |
|---|
| 96 | OpenSC [3F00/5015]> put 4302 cert2.crt |
|---|
| 97 | |
|---|