tech:notes_carte_a_puce_-_smart_card
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| tech:notes_carte_a_puce_-_smart_card [2025/03/24 15:06] – créée - modification externe 127.0.0.1 | tech:notes_carte_a_puce_-_smart_card [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # Notes carte à puce - smart card | ||
| + | |||
| + | Voir : | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | x509 | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | Coté serveur : | ||
| + | * Nginx / PHP : http:// | ||
| + | |||
| + | Python: | ||
| + | * https:// | ||
| + | |||
| + | ~~~bash | ||
| + | sudo aptitude install pcscd libpcsclite1 pcsc-tools | ||
| + | sudo aptitude install openct opensc | ||
| + | ~~~ | ||
| + | |||
| + | Test your Token | ||
| + | ~~~bash | ||
| + | opensc-tool -lv | ||
| + | openct-tool list | ||
| + | pcsc_scan | ||
| + | ~~~ | ||
| + | |||
| + | Voir aussi : | ||
| + | * https:// | ||
| + | |||
| + | How can I distinguish a Nitrokey HSM 1 from an Nitrokey HSM 2? | ||
| + | |||
| + | FIXME | ||
| + | Use | ||
| + | ~~~bash | ||
| + | opensc-tool --list-algorithms | ||
| + | ~~~ | ||
| + | |||
| + | ## Outils | ||
| + | |||
| + | * opensc-tool | ||
| + | * pkcs11-tool | ||
| + | * pkcs15-tool | ||
| + | * pkcs15-init | ||
| + | * cardos-tool | ||
| + | |||
| + | ## Install - Vérif - Drivers | ||
| + | |||
| + | ~~~bash | ||
| + | pkcs11-tool --module opensc-pkcs11.so -L | ||
| + | ~~~ | ||
| + | |||
| + | ## OpenSSL | ||
| + | |||
| + | List the available slots. | ||
| + | ~~~Nash | ||
| + | pkcs11-tool --list-slots | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | FIXME | ||
| + | ~~~bash | ||
| + | openssl req -engine pkcs11 -new -key slot_X-id_XXXX -keyform engine -x509 -out cert.pem -text | ||
| + | ~~~ | ||
| + | |||
| + | where X is the appropriate slot number and XXXX is the slot ID, e.g. "... -key slot_5-id_c6f280080fb0ed1ebff0480a01d00a98a1b3b89a ..." | ||
| + | |||
| + | ## GPG | ||
| + | |||
| + | Reset to factory defaults: | ||
| + | Make sure GnuPG agent is started, if not: | ||
| + | ~~~bash | ||
| + | eval $(gpg-agent --daemon) | ||
| + | ~~~ | ||
| + | |||
| + | Send the reset commands: | ||
| + | ~~~bash | ||
| + | gpg-connect-agent < file | ||
| + | ~~~ | ||
| + | |||
| + | Where “file” contains: | ||
| + | ~~~ | ||
| + | hex | ||
| + | scd serialno | ||
| + | scd apdu 00 20 00 81 08 40 40 40 40 40 40 40 40 | ||
| + | scd apdu 00 20 00 81 08 40 40 40 40 40 40 40 40 | ||
| + | scd apdu 00 20 00 81 08 40 40 40 40 40 40 40 40 | ||
| + | scd apdu 00 20 00 81 08 40 40 40 40 40 40 40 40 | ||
| + | scd apdu 00 20 00 83 08 40 40 40 40 40 40 40 40 | ||
| + | scd apdu 00 20 00 83 08 40 40 40 40 40 40 40 40 | ||
| + | scd apdu 00 20 00 83 08 40 40 40 40 40 40 40 40 | ||
| + | scd apdu 00 20 00 83 08 40 40 40 40 40 40 40 40 | ||
| + | scd apdu 00 e6 00 00 | ||
| + | scd apdu 00 44 00 00 | ||
| + | /echo Reset complete | ||
| + | ~~~ | ||
| + | |||
| + | Source https:// | ||
| + | |||
| + | ## Autres | ||
| + | |||
| + | data objects (DF, EF) | ||
| + | |||
| + | ### pkcs | ||
| + | |||
| + | |||
| + | The three keys in the have these IDs: Singing key: 1, Decryption key: 2, Authentication: | ||
| + | |||
| + | Key generation via `pkcs15-init` | ||
| + | ~~~bash | ||
| + | pkcs15-init --delete-objects privkey, | ||
| + | ~~~ | ||
| + | |||
| + | The keyspec consist of the key type (only RSA is supported) and optinally a slash followed by the keysize in bits (defaults to 1024). E.g to generate a 1024-bit RSA key, use | ||
| + | `pkcs15-init -G rsa/1024 -a 01 -l testkey` | ||
| + | |||
| + | There is limitation: `pkcs15-init` requires new key length to be the same as existing key. To generate key with different key length, `openpgp-tool` is recommended. | ||
| + | |||
| + | `pkcs15-init` also requires to explicitly remove existing key/object. That’s why we have `--delete-objects privkey, | ||
| + | |||
| + | Source : https:// | ||
| + | |||
| + | |||
| + | Autres | ||
| + | ~~~bash | ||
| + | pkcs15-tool --dump | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | pkcs15-init --delete-objects privkey, | ||
| + | $ pkcs15-init --delete-objects privkey, | ||
| + | ~~~ | ||
| + | |||
| + | The two commands copy the key-certificate pair to the slot 2 (needed for decrypting emails) and slot 3 (needed for signing). | ||
| + | |||
| + | |||
| + | Autres - Génération paire de clefs pour s/mime | ||
| + | ~~~bash | ||
| + | #set +o history | ||
| + | export HISTCONTROL = ignorespace | ||
| + | | ||
| + | ~~~ | ||
| + | |||
| + | |||
