Progetto

Generale

Profilo

Actions

UsoDiOpenPGPCard » Cronologia » Versione 4

« Precedente | Versione 4/31 (diff) | Successivo »
Elena Grandi, 19-10-2016 11:56


Uso di OpenPGP Card

L'OpenPGP Card è una smartcard sulla quale si possono salvare in modo sicuro ed usare le sottochiavi segrete usate da GnuPG per crittografia, firma ed anche autenticazione; ne esistono versioni tradizionali, oppure implementate in un dispositivo USB. In ogni caso si possono caricare nuove chiavi sulla scheda, ma non si possono estrarre (per via software) quelle salvate ed è la scheda stessa ad effettuare le operazioni crittografiche.

L'obiettivo che si vuole ottenere è di non avere materiale crittografico segreto sui computer, in modo che un attaccante remoto non possa impossessarsene, mantenendo comunque la comodità di poter usare le chiavi sulla stessa macchina di uso comune. Per farlo si dovrà avere una chiave principale di lunga durata conservata offline ed usata solo saltuariamente per operazioni di gestione della chiave stessa (creazione di nuove sottochiavi, modifica delle scadenze, firma di altre chiavi per la Web Of Trust) e delle sottochiavi da usare quotidianamente, conservate sulla card.

Ll'OpenPGP Card permette di caricare tre sottochiavi con finalità di crittografia, firma ed autenticazione: le prime due si usano normalmente tramite GnuPG, la terza può essere usata per l'autenticazione ssh tramite gpg-agent.

prerequisiti

Tutte le versioni di GnuPG supportano l'uso di base delle OpenPGP Card, ma per meglio sfruttarne le capacità è meglio usare la versione 2.1 (modern), specialmente in fase di creazione della chiave e delle sue sottochiavi.

Nel caso si voglia usare poi la Card per autenticazione ssh con versioni precedenti di GnuPG è necessario installare anche gpg-agent (in 2.1 usato di default).

Per il supporto della Card è poi necessario installare PC/SC Lite.

Sotto distribuzioni debian o derivate (che già preinstallano gnupg e openssh-client) i pacchetti da installare sono quindi:

apt install pcscd gnupg-agent

creazione della chiave

Innanzitutto bisogna creare una chiave principale che verrà associata alla nostra identità; questa dovrà essere da almeno 4096 bit per garantirle sufficiente longevità, dato che la sua sostituzione comporta un nuovo ingresso nella Web of Trust.

Ovviamente, se si ha già una chiave gpg da 4096 bit si può saltare questo passaggio ed usare quella.

Innanzitutto, configurare gpg per l'uso di SHA2 aggiungendo le seguenti righe a ~/.gnupg/gpg.conf:

personal-digest-preferences SHA256
cert-digest-algo SHA256
default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed

Quindi generare una nuova chiave: notare l'uso di gpg versione 2.1 e la dimensione a 4096 bit (per il resto si sono accettate le scelte di default oppure inseriti i propri dati).

$ gpg --full-gen-key 
gpg (GnuPG) 2.1.15; Copyright (C) 2016 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
Your selection? 1
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 4096
Requested keysize is 4096 bits
Please specify how long the key should be valid.
         0 = key does not expire
      <n>  = key expires in n days
      <n>w = key expires in n weeks
      <n>m = key expires in n months
      <n>y = key expires in n years
Key is valid for? (0) 
Key does not expire at all
Is this correct? (y/N) y

GnuPG needs to construct a user ID to identify your key.

Real name: Random User
Email address: random@example.org
Comment: 
You selected this USER-ID:
    "Random User <random@example.org>" 

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
gpg: key 3E0EE5BAC50DF7C1 marked as ultimately trusted
gpg: directory '/home/random/.gnupg/openpgp-revocs.d' created
gpg: revocation certificate stored as '/home/valhalla/.gnupg/openpgp-revocs.d/19DB75A75734ABBEDB1124163E0EE5BAC50DF7C1.rev'
public and secret key created and signed.

pub   rsa4096 2016-10-19 [SC]
      19DB75A75734ABBEDB1124163E0EE5BAC50DF7C1
      19DB75A75734ABBEDB1124163E0EE5BAC50DF7C1
uid                      Random User <random@example.org>
sub   rsa4096 2016-10-19 [E]

creazione delle sottochiavi

spostamento delle chiavi sulla Card

configurazione di ssh

Aggiornato da Elena Grandi oltre 7 anni fa · 4 revisions