Introduzione
Il problema più annoso per l'utilizzatore della crittografia asimmetrica è la conservazione sicura della propria chiave privata
senza che questa rischi di essere compromessa, cadendo in mani avverse.
Per ovviare (almeno in parte) a questo problema, si può fare in modo che la chiave abbia una scadenza. In questo modo, se non si fosse in
grado di revocare la chiave (per qualsiasi motivo), questa diverrebbe automaticamente non più valida alla sua scadenza.
Questo, però, comporta qualche piccolo inconveniente: tutte le firme apposte alle chiavi altrui perderebbero valore allo scadere della
nostra chiave, a meno che essa venga rinnovata periodicamente. E, cosa ben peggiore, se noi non dovessimo rinnovarla,
ma ne generassimo una nuova, tutte le firme altrui, fatte alla nostra chiave, dovrebbero essere nuovamente apposte alla nuova chiave.
È però possibile creare una o più chiavi secondarie e fare in modo che siano solo queste ultime a scadere.
In questo modo, potremo firmare ciò che non deve scadere (es. certificazione delle chiavi altrui) con la chiave principale e ciò
che invece non ha problemi di durata (es. crittomessaggi) con una delle chiavi secondarie.
Alla scadenza delle chiavi secondarie, queste potranno essere sostituite, generandone di nuove, oppure semplicemente rinnovate, se si ha
garanzia che queste non siano state compromesse.
Dato che, però, la nostra chiave comprende anche la privata principale, nel momento in cui dovessimo aver sentore che la chiave possa
essere compromessa, avremmo il problema di doverla revocare, vanificando comunque tutto il lavoro fatto per il
Web-Of-Trust, invalidando
le firme apposte alle chiavi altrui e, soprattutto, quelle che gli altri hanno eventualmente apposto alla nostra.
Potremmo ovviare a questo problema, se disponessimo di una chiave principale che non soffre del problema della compromissione e una o più
chiavi secondarie sacrificabili (quindi, revocabili) da utilizzare invece quotidianamente.
Potrebbe esserci, ad esempio, l'esigenza di utilizzare le nostre chiavi in ambienti non prettamente sicuri (quali: Internet Point,
PC condivisi a scuola, lavoro, vacanza...), cercando di impedire che la nostra chiave possa essere in qualche modo compromessa
durante questo uso "non propriamente sicuro". In questi casi, quindi, una "chiave evento", creata con la
procedura che andremo a vedere, potrebbe semplificare il nostro lavoro, mantenendo il livello di sicurezza accettabile.
Le chiavi potranno quindi avere una validità limitata al tempo dell'evento (una settimana, un mese, ...) e diventeranno non
più valide allo scadere dell'evento (a meno che vengano rinnovate dal proprietario).
Inoltre, in casi estremi (furto dei dispositivi e/o dei supporti contenenti i portachiavi), non sarà necessario revocare
e ricreare per intero la coppia di chiavi, con le inevitabili spiacevoli conseguenze del caso.
Con GnuPG, tutto questo è possibile.
Con questa pagina non voglio dimostrare di aver scoperto l'acqua calda, ma solo spiegare come generare una coppia di chiavi sufficientemente sicura.
La tecnica proposta non è perciò la soluzione a tutti i problemi di conservazione delle chiavi, ma, più semplicemente, un ulteriore
rinforzo delle tecniche di conservazione sicura (che non deve però assolutamente spingerci ad abbassare il solito livello di guardia minimo).
Giusto per precisazione, le chiavi private create con questo metodo funzioneranno solo con GnuPG,
mentre, le relative chiavi pubbliche funzioneranno anche con PGP. In questo modo, potremo corrispondere con chiunque utilizzi un qualsiasi
prodotto che rispetti lo standard OpenPGP.
Procediamo...
Per prima cosa, faremo un bel backup dei nostri attuali portachiavi (in modo da non far danni) e sposteremo questi altrove, per poter partire con dei portachiavi nuovi.
T:\GnuPG>dir
Il volume nell'unità T è TJL73
Numero di serie del volume: 47C1-741C
Directory di T:\GnuPG
18/07/2007 10.10 <DIR> .
18/07/2007 10.10 <DIR> ..
18/07/2007 10.10 0 pubring.gpg
18/07/2007 10.10 0 secring.gpg
18/07/2007 10.10 40 trustdb.gpg
3 File 40 byte
2 Directory 123.456.789 byte disponibili
|
Creeremo quindi una nuova coppia di chiavi, con il comando "gpg --gen-key":
T:\GnuPG>gpg --gen-key
gpg (GnuPG) 1.4.8; Copyright (C) 2007 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.
Please select what kind of key you want:
(1) DSA and Elgamal (default)
(2) DSA (sign only)
(5) RSA (sign only)
Your selection?
|
Per il nostro esempio, creeremo una chiave DSA (sign only) (quella contrassegnata con il numero 2), ma
potrebbe andare bene anche un chiave RSA (sign only).
Your selection? 2
DSA keypair will have 1024 bits.
|
Ci verrà richiesto di dare una validità alla chiave primaria (che avrà sola funzione di firma).
La nostra chiave principale avrà validità illimitata (non avrà quindi scadenza).
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) 0
Key does not expire at all
Is this correct? (y/N) y
|
A questo punto, ci verrà richiesto di inserire i nostri dati (la UserID), la parola chiave (la Passphrase) e,
dopo aver confermato, verrà creata la nostra coppia di chiavi principale all'interno dei nostri portachiavi.
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
"Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"
Real name: Test Key
Email address: address@mail.invalid
Comment: No Comment
You selected this USER-ID:
"Test Key (No Comment) <address@mail.invalid>"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
You need a Passphrase to protect your secret key.
Enter passphrase: ***********************
Repeat passphrase: ***********************
gpg: NOTE: you should run 'diskperf -y' to enable the disk statistics
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: NOTE: you should run 'diskperf -y' to enable the disk statistics
gpg: key 1A2B3INV marked as ultimately trusted
public and secret key created and signed.
gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
pub 1024D/1A2B3INV 2007-07-18
Key fingerprint = XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX 1A2B 3INV
uid Test Key (No Comment) <address@mail.invalid>
Note that this key cannot be used for encryption. You may want to use
the command "--edit-key" to generate a subkey for this purpose.
|
Avremo quindi le nostre nuove chiavi, nel nostro nuovo portachiavi:
T:\GnuPG>dir
Il volume nell'unità T è TJL73
Numero di serie del volume: 47C1-741C
Directory di T:\GnuPG
18/07/2007 10.10 <DIR> .
18/07/2007 10.10 <DIR> ..
18/07/2007 10.10 570 pubring.bak
18/07/2007 10.10 570 pubring.gpg
18/07/2007 10.10 600 random_seed
18/07/2007 10.10 633 secring.gpg
18/07/2007 10.10 1.280 trustdb.gpg
5 File 3.653 byte
2 Directory 123.456.789 byte disponibili
|
Faremo un nuovo backup dei nuovi portachiavi, contenenti la sola coppia di chiavi abilitata alla firma
(questo portachiavi, sarà quello che utilizzeremo unicamente per firmare le chiavi dei nostri corrispondenti;
in questo modo, le nostre firme sulle chiavi altrui scadranno esclusivamente allo scadere della chiave del nostro corrispondente).
T:\GnuPG>md backup1
T:\GnuPG>copy *.gpg backup1
pubring.gpg
secring.gpg
trustdb.gpg
3 file copiati.
|
Ora si procederà con la creazione delle chiavi secondarie a validità limitata nel tempo
(con scadenza). Una per la firma ad uso quotidiano e l'altra per la cifratura.
Nel nostro esempio, verranno create, dapprima, una chiave RSA di 2048 bit, valida un anno, per la firma:
T:\GnuPG>gpg --edit-key 1A2B3INV
gpg (GnuPG) 1.4.8; Copyright (C) 2007 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.
Secret key is available.
pub 1024D/1A2B3INV created: 2007-07-18 expires: never usage: SC
trust: ultimate validity: ultimate
[ultimate] (1). Test Key (No Comment) <address@mail.invalid>
Command> addkey
Key is protected.
You need a passphrase to unlock the secret key for
user: "Test Key (No Comment) <address@mail.invalid>"
1024-bit DSA key, ID 1A2B3INV, created 2007-07-18
Please select what kind of key you want:
(2) DSA (sign only)
(4) Elgamal (encrypt only)
(5) RSA (sign only)
(6) RSA (encrypt only)
Your selection? 5
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 2048
Requested keysize is 2048 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) 1y
Key expires at 07/18/08 10:10:10
Is this correct? (y/N) y
Really create? (y/N) y
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: NOTE: you should run 'diskperf -y' to enable the disk statistics
...+++++
.+++++
pub 1024D/1A2B3INV created: 2007-07-18 expires: never usage: SC
trust: ultimate validity: ultimate
sub 2048R/8E9F0INV created: 2007-07-18 expires: 2008-07-18 usage: S
[ultimate] (1). Test Key (No Comment) <address@mail.invalid>
|
e, successivamente, una chiave Elgamal di 2048 per la cifratura, anch'essa valida un anno (al termine, salveremo le modifiche con il comando "save"):
Command> addkey
Key is protected.
You need a passphrase to unlock the secret key for
user: "Test Key (No Comment) <address@mail.invalid>"
1024-bit DSA key, ID 1A2B3INV, created 2007-07-18
Please select what kind of key you want:
(2) DSA (sign only)
(4) Elgamal (encrypt only)
(5) RSA (sign only)
(6) RSA (encrypt only)
Your selection? 4
ELG-E keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 2048
Requested keysize is 2048 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) 1y
Key expires at 18/07/2008 10:10:10
Is this correct? (y/N) y
Really create? (y/N) y
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: NOTE: you should run 'diskperf -y' to enable the disk statistics
pub 1024D/1A2B3INV created: 2007-07-18 expires: never usage: SC
trust: ultimate validity: ultimate
sub 2048R/8E9F0INV created: 2007-07-18 expires: 2008-07-18 usage: S
sub 2048g/7A8B9INV created: 2007-07-18 expires: 2008-07-18 usage: E
[ultimate] (1). Test Key (No Comment) <address@mail.invalid>
Command> save
|
Come si può vedere qui sopra, nel nostro esempio, avremo una chiave principale senza scadenza ("expires: never")
abilitata alla firma e alla certificazione ("usage: SC") e due chiavi secondarie, con durata di un anno
("expires: 2008-07-18"), la prima con funzionalità di firma ("usage: S")
e la seconda con funzionalità di cifratura ("usage: E").
Potremo quindi chiedere a GnuPG di mostrarci l'attuale situazione dei nostri portachiavi (e quindi delle nostre chiavi attuali), con i due comandi "gpg --list-keys" e "gpg --list-secret-keys":
T:\GnuPG>gpg --list-keys
t:/gnupg\pubring.gpg
--------------------
pub 1024D/1A2B3INV 2007-07-18
uid Test Key (No Comment) <address@mail.invalid>
sub 2048R/8E9F0INV 2007-07-18 [expires: 2008-07-18]
sub 2048g/7A8B9INV 2007-07-18 [expires: 2008-07-18]
T:\GnuPG>gpg --list-secret-keys
t:/gnupg\secring.gpg
--------------------
sec 1024D/1A2B3INV 2007-07-18
uid Test Key (No Comment) <address@mail.invalid>
ssb 2048R/8E9F0INV 2007-07-18
ssb 2048g/7A8B9INV 2007-07-18
|
Ora possiamo procedere all'esportazione delle nostre chiavi, con i seguenti tre comandi:
T:\GnuPG>gpg --output public.asc --armor --export 1A2B3INV
T:\GnuPG>gpg --output secret.asc --armor --export-secret-keys 1A2B3INV
T:\GnuPG>gpg --output subsecret.asc --armor --export-secret-subkeys 1A2B3INV
|
Otterremo, quindi, tre file ("public.asc", "secret.asc" e "subsecret.asc"):
T:\GnuPG>dir
Il volume nell'unità T è TJL73
Numero di serie del volume: 47C1-741C
Directory di T:\GnuPG
18/07/2007 10.10 <DIR> .
18/07/2007 10.10 <DIR> ..
18/07/2007 10.10 <DIR> backup1
18/07/2007 10.10 2.616 public.asc
18/07/2007 10.10 570 pubring.bak
18/07/2007 10.10 1.828 pubring.gpg
18/07/2007 10.10 600 random_seed
18/07/2007 10.10 3.770 secret.asc
18/07/2007 10.10 2.666 secring.gpg
18/07/2007 10.10 3.696 subsecret.asc
18/07/2007 10.10 1.280 trustdb.gpg
8 File 17.026 byte
3 Directory 123.456.789 byte disponibili
|
Il primo ("public.asc") conterrà le nostre chiavi pubbliche,
che andremo a distribuire ai nostri corrispondenti (direttamente, via WEB oppure tramite KeyServer);
il secondo ("secret.asc") conterrà tutte le nostre chiavi private,
che dovremo custodire gelosamente e che non dovranno mai essere divulgate a nessuno; il terzo file
("subsecret.asc"), conterrà anch'esso le nostre chiavi private,
con la sola differenza che non sarà presente la parte privata della chiave principale (anche questo file lo dovremo
custodire gelosamente e non lo dovremo mai divulgare a nessuno, ma a differenza del secondo, lo potremo
utilizzare nell'uso quotidiano).
Giusto per la cronaca, entrambi i file che contengono le chiavi private, contengono anche la parte pubblica.
Faremo un nuovo backup dei portachiavi (giusto per sicurezza, ma che al termine andremo ad eliminare):
T:\GnuPG>md backup2
T:\GnuPG>copy *.gpg backup2
pubring.gpg
secring.gpg
trustdb.gpg
3 file copiati.
|
e procederemo alla cancellazione delle chiavi dal nostro portachiavi (più avanti capiremo il perché):
T:\GnuPG>gpg --delete-secret-and-public-key 1A2B3INV
gpg (GnuPG) 1.4.8; Copyright (C) 2007 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.
sec 1024D/1A2B3INV 2007-07-18 Test Key (No Comment) <address@mail.invalid>
Delete this key from the keyring? (y/N) y
This is a secret key! - really delete? (y/N) y
pub 1024D/1A2B3INV 2007-07-18 Test Key (No Comment) <address@mail.invalid>
Delete this key from the keyring? (y/N) y
|
Al posto di questo comando, è altresì possibile cancellare direttamente i portachiavi, in modo da ripartire
con una situazione pulita in cui reimportare le chiavi (a vostra discrezione la scelta del metodo).
A questo punto, il nostro portachiavi non conterrà alcuna coppia di chiavi:
T:\GnuPG>gpg --list-keys
gpg: checking the trustdb
gpg: no ultimately trusted keys found
T:\GnuPG>gpg --list-secret-keys
T:\GnuPG>
|
Possiamo quindi procedere con la reimportazione di ciò che ora realmente ci interessa (il file "subsecret.asc"):
T:\GnuPG>gpg --import subsecret.asc
gpg: key 1A2B3INV: secret key imported
gpg: key 1A2B3INV: "Test Key (No Comment) <address@mail.invalid>" not changed
gpg: Total number processed: 1
gpg: imported: 1
gpg: secret keys read: 1
gpg: secret keys imported: 1
|
Richiedendo quindi l'attuale contenuto dei nostri portachiavi, otterremo:
T:\GnuPG>gpg --list-keys
t:/gnupg\pubring.gpg
--------------------
pub 1024D/1A2B3INV 2007-07-18
uid Test Key (No Comment) <address@mail.invalid>
sub 2048R/8E9F0INV 2007-07-18 [expires: 2008-07-18]
sub 2048g/7A8B9INV 2007-07-18 [expires: 2008-07-18]
T:\GnuPG>gpg --list-secret-keys
t:/gnupg\secring.gpg
--------------------
sec# 1024D/1A2B3INV 2007-07-18
uid Test Key (No Comment) <address@mail.invalid>
ssb 2048R/8E9F0INV 2007-07-18
ssb 2048g/7A8B9INV 2007-07-18
|
Come potrete notare, il cancelletto ("#") presente accanto alla dicitura "sec", indica che
la parte privata della chiave principale è mancante. Questa chiave non sarà utilizzabile per effettuare alcuna operazione per cui sia richiesta la privata principale (come,
ad esempio, firmare le chiavi altrui).
Ora sarà necessario assegnare nuovamente la fiducia alla nostra chiave, in modo da poterla utilizzare:
T:\GnuPG>gpg --edit-key 1A2B3INV
gpg (GnuPG) 1.4.8; Copyright (C) 2007 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.
Secret key is available.
pub 1024D/1A2B3INV created: 2007-07-18 expires: never usage: SC
trust: unknown validity: unknown
sub 2048R/8E9F0INV created: 2007-07-18 expires: 2008-07-18 usage: S
sub 2048g/7A8B9INV created: 2007-07-18 expires: 2008-07-18 usage: E
[ unknown] (1). Test Key (No Comment) <address@mail.invalid>
Command> trust
pub 1024D/1A2B3INV created: 2007-07-18 expires: never usage: SC
trust: unknown validity: unknown
sub 2048R/8E9F0INV created: 2007-07-18 expires: 2008-07-18 usage: S
sub 2048g/7A8B9INV created: 2007-07-18 expires: 2008-07-18 usage: E
[ unknown] (1). Test Key (No Comment) <address@mail.invalid>
Please decide how far you trust this user to correctly verify other users' keys
(by looking at passports, checking fingerprints from different sources, etc.)
1 = I don't know or won't say
2 = I do NOT trust
3 = I trust marginally
4 = I trust fully
5 = I trust ultimately
m = back to the main menu
Your decision? 5
Do you really want to set this key to ultimate trust? (y/N) y
pub 1024D/1A2B3INV created: 2007-07-18 expires: never usage: SC
trust: ultimate validity: unknown
sub 2048R/8E9F0INV created: 2007-07-18 expires: 2008-07-18 usage: S
sub 2048g/7A8B9INV created: 2007-07-18 expires: 2008-07-18 usage: E
[ unknown] (1). Test Key (No Comment) <address@mail.invalid>
Please note that the shown key validity is not necessarily correct
unless you restart the program.
Command> quit
|
Possiamo quindi procedere all'ultimo backup:
T:\GnuPG>md backup3
T:\GnuPG>copy *.gpg backup3
pubring.gpg
secring.gpg
trustdb.gpg
3 file copiati.
T:\GnuPG>copy *.asc backup1
public.asc
secret.asc
subsecret.asc
3 file copiati.
|
A questo punto, tutto ciò che ci servirà, sarà:
T:\GnuPG>dir
Il volume nell'unità T è TJL73
Numero di serie del volume: 47C1-741C
Directory di T:\GnuPG
18/07/2007 10.10 <DIR> .
18/07/2007 10.10 <DIR> ..
18/07/2007 10.10 <DIR> backup1
18/07/2007 10.10 <DIR> backup2
18/07/2007 10.10 <DIR> backup3
18/07/2007 10.10 2.616 public.asc
18/07/2007 10.10 1.828 pubring.bak
18/07/2007 10.10 1.828 pubring.gpg
18/07/2007 10.10 600 random_seed
18/07/2007 10.10 3.770 secret.asc
18/07/2007 10.10 2.611 secring.gpg
18/07/2007 10.10 3.696 subsecret.asc
18/07/2007 10.10 1.280 trustdb.gpg
8 File 18.229 byte
5 Directory 123.456.789 byte disponibili
T:\GnuPG>
|
- il file "public.asc", che andremo a distribuire a tutti i nostri contatti, tramite i consueti canali di distribuzione (WEB, KeyServer, ecc.).
- il contenuto della cartella "backup3", che andremo ad utilizzare quotidianamente(pur conservandolo con tutti i crismi);
- il contenuto della cartella "backup1", che andremo a custodire gelosamente e tireremo fuori solo per le grandi occasioni (vedi: firma di chiavi altrui);
Tutto il resto, dovrà essere eliminato definitivamente (meglio, se tramite "wipe"... personalmente, in ambiente Win32, consiglio "Eraser").
Per riassumere, ciò che abbiamo ottenuto è:
- una coppia di chiavi da utilizzare quotidianamente, comprensiva di una chiave pubblica principale e una o
più coppie di chiavi secondarie (queste ultime, con validità ridotta nel tempo);
- una coppia di chiavi principali, comprensiva di una chiave pubblica principale e una chiave privata
principale, da utilizzare esclusivamente per la firma o la certificazione di elementi che non prevedono scadenza
(quali, ad esempio, la firma di chiavi altrui);
- la possibilità di conservare la propria chiave privata principale in un posto sicuro, pur disponendo
comodamente delle private secondarie per un uso quotidiano;
- l'opportunità di revocare le sole chiavi secondarie, nel caso queste risultino compromesse o la possibilità
di portarle a scadenza naturale (quindi "virtualmente" revocandole automaticamente), ricreandone di nuove, senza che la principale vada mai a scadere;
- la possibilità di conservare le firme altrui raccolte nel tempo e apposte alla nostra chiave principale,
senza il rischio di doverle raccogliere nuovamente.
Nel tempo...
Sarà necessario rinnovare periodicamente le chiavi secondarie, in modo che queste possano continuare ad essere utilizzate
dai nostri corrispondenti per inviarci dei crittogrammi e da parte nostra per firmare quelli che invieremo ad essi.
Per effettuare questa operazione, si possono utilizzare metodi differenti:
- se si ha la quasi certezza che la nostra chiave non sia mai stata compromessa, ci basterà rinnovare le
chiavi secondarie, editando la nostra chiave e utilizzando il comando "expire"
per estendere la validità delle chiavi;
- se si suppone, invece, che la chiave possa in qualche modo essere stata compromessa, ci basterà
revocare le chiavi secondarie o, se siamo alla loro scadenza naturale, lasciarle scadere e crearne di nuove, con
il comando "addkey" (come già visto in precedenza);
- se siamo paranoici incurabili, lasceremo sempre scadere le chiavi secondarie e ne creeremo comunque ogni volta di nuove.
Dato che nel nostro portachiavi "quotidiano" non disponiamo della nostra privata principale, non ci
sarà possibile revocare, rinnovare, estendere o creare nuove chiavi, in modo semplice e veloce.
La procedura per il rinnovo della nostra chiave è un po' macchinosa, ma non impraticabile (considerate anche
che dovrà essere fatta molto raramente... quindi, il disagio in cui si incorre è pienamente ripagato
dalla sicurezza che otterremo).
Per poter effettuare qualsiasi modifica alla nostra chiave, dovremo quindi tirar fuori dalla naftalina il nostro
portachiavi per le grandi occasioni e farlo diventare portachiavi principale.
Per effettuare questa operazione, ci basterà dire a GnuPG che la sua cartella principale non è
più la solita, bensì quella contenente il nostro portachiavi speciale. Per fare questo, ci
basterà, mediante l'opzione "--homedir", specificare il percorso
in cui sarà contenuto il nostro portachiavi contenente la nostra chiave privata principale (ad esempio, una chiavetta USB).
In tale cartella dovrà essere eventualmente presente anche il file "gpg.conf"
contenente la nostra configurazione, nel caso ne avessimo una particolare.
Nota:
|
È altresì possibile utilizzare la variabile d'ambiente "GNUPGHOME"
al posto dell'opzione "--homedir", oltre che specificare l'ubicazione dei portachiavi
alternativi nel file "gpg.conf", invece che come opzioni su linea di comando.
Per le modalità di utilizzo, fare riferimento alla documentazione ufficiale di GnuPG.
|
Di seguito, si suppone che il percorso "S:\GnuPG" contenga i portachiavi per
le grandi occasioni (conservati, ad esempio, su una chiavetta USB); mentre, nel percorso "T:\GnuPG"
siano presenti i portachiavi per uso quotidiano.
Con questo comando (particolarmente dettagliato) possiamo quindi vedere che vengono caricati entrambi i portachiavi privati:
T:\GnuPG>gpg --homedir S:\GnuPG --keyring T:\GnuPG\pubring.gpg --secret-keyring T:\GnuPG\secring.gpg --trustdb-name T:\GnuPG\trustdb.gpg --list-secret-keys
s:/gnupg\secring.gpg
-----------------------------------------------------------------------------------
sec 1024D/1A2B3INV 2007-07-18
uid Test Key (No Comment) <address@mail.invalid>
T:\GnuPG\secring.gpg
------------------------------
sec# 1024D/1A2B3INV 2007-07-18
uid Test Key (No Comment) <address@mail.invalid>
ssb 2048R/8E9F0INV 2007-07-18
ssb 2048g/7A8B9INV 2007-07-18
|
A questo punto modificheremo la chiave, facendo riferimento ad una delle chiavi secondarie che la compongono (nel caso del
nostro esempio, prenderemo in considerazione la chiave secondaria "0x8E9F0INV").
Dato che la chiave secondaria compare solo nel portachiavi ad uso quotidiano, GnuPG saprà che ci stiamo riferendo a questi
per la modifica, ma utilizzerà la privata principale per la certificazione dell'estensione di validità, dato che è presente nel portachiavi primario:
T:\GnuPG>gpg --homedir S:\GnuPG --keyring T:\GnuPG\pubring.gpg --secret-keyring T:\GnuPG\secring.gpg --trustdb-name T:\GnuPG\trustdb.gpg --edit-key 0x8E9F0INV
gpg (GnuPG) 1.4.8; Copyright (C) 2007 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.
Secret key is available.
pub 1024D/1A2B3INV created: 2007-07-18 expires: never usage: SC
trust: ultimate validity: ultimate
sub 2048R/8E9F0INV created: 2007-07-18 expires: 2008-07-18 usage: S
sub 2048g/7CAEC74C created: 2007-07-18 expires: 2008-07-18 usage: E
[ultimate] (1). Test Key (No Comment) <address@mail.invalid>
|
Estenderemo, quindi, la validità della prima chiave secondaria a (nel nostro esempio) un paio d'anni:
Command> key 1
pub 1024D/1A2B3INV created: 2007-07-18 expires: never usage: SC
trust: ultimate validity: ultimate
sub* 2048R/8E9F0INV created: 2007-07-18 expires: 2008-07-18 usage: S
sub 2048g/7CAEC74C created: 2007-07-18 expires: 2008-07-18 usage: E
[ultimate] (1). Test Key (No Comment) <address@mail.invalid>
Command> expire
Changing expiration time for a subkey.
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) 2y
Key expires at 07/18/09 10:10:10
Is this correct? (y/N) y
gpg: No corresponding signature in secret ring
You need a passphrase to unlock the secret key for
user: "Test Key (No Comment) <address@mail.invalid>"
1024-bit DSA key, ID 1A2B3INV, created 2007-07-18
Enter passphrase: ***********************
pub 1024D/1A2B3INV created: 2007-07-18 expires: never usage: SC
trust: ultimate validity: ultimate
sub* 2048R/8E9F0INV created: 2007-07-18 expires: 2009-07-18 usage: S
sub 2048g/7CAEC74C created: 2007-07-18 expires: 2008-07-18 usage: E
[ultimate] (1). Test Key (No Comment) <address@mail.invalid>
|
nonché della seconda, di egual durata:
Command> key 1
pub 1024D/1A2B3INV created: 2007-07-18 expires: never usage: SC
trust: ultimate validity: ultimate
sub 2048R/8E9F0INV created: 2007-07-18 expires: 2009-07-18 usage: S
sub 2048g/7CAEC74C created: 2007-07-18 expires: 2008-07-18 usage: E
[ultimate] (1). Test Key (No Comment) <address@mail.invalid>
Command> key 2
pub 1024D/1A2B3INV created: 2007-07-18 expires: never usage: SC
trust: ultimate validity: ultimate
sub 2048R/8E9F0INV created: 2007-07-18 expires: 2009-07-18 usage: S
sub* 2048g/7CAEC74C created: 2007-07-18 expires: 2008-07-18 usage: E
[ultimate] (1). Test Key (No Comment) <address@mail.invalid>
Command> expire
Changing expiration time for a subkey.
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) 2y
Key expires at 18/07/2009 10.10.10
Is this correct? (y/N) y
gpg: No corresponding signature in secret ring
You need a passphrase to unlock the secret key for
user: "Test Key (No Comment) <address@mail.invalid>"
1024-bit DSA key, ID 1A2B3INV, created 2007-07-18
Enter passphrase: ***********************
pub 1024D/1A2B3INV created: 2007-07-18 expires: never usage: SC
trust: ultimate validity: ultimate
sub 2048R/8E9F0INV created: 2007-07-18 expires: 2009-07-18 usage: S
sub* 2048g/7CAEC74C created: 2007-07-18 expires: 2009-07-18 usage: E
[ultimate] (1). Test Key (No Comment) <address@mail.invalid>
Command> save
T:\GnuPG>
|
Fatto questo, avremo ottenuto l'aggiornamento della nostra chiave e potremo riporre il portachiavi riservato nuovamente in cassaforte.
Naturalmente, dato che le firme che altri hanno apposto alla nostra chiave sono associate alla parte pubblica, nessuna di queste andrà
persa. In ogni caso, ci basterà fare una copia della nostra chiave pubblica, prima di iniziare le modifiche, in modo da poterla
reimportare se necessario.
Certificazioni
Per apporre firme a chiavi di altri, dovremo sempre utilizzare il portachiavi in cassaforte dato che è
l'unico che contiene la privata principale.
Faremo la stessa operazione effettuata qui sopra, dopo aver importato la chiave del nostro corrispondente all'interno
del nostro portachiavi di uso quotidiano.
Per prima cosa, verifichiamo che la chiave sia presente nel nostro portachiavi (nel nostro esempio, si tratterà
della chiave "0x4B5C6INV"):
T:\GnuPG>gpg --list-keys
T:/GnuPG\pubring.gpg
--------------------
pub 1024D/1A2B3INV 2007-07-18
uid Test Key (No Comment) <address@mail.invalid>
sub 2048R/8E9F0INV 2007-07-18 [expires: 2009-07-18]
sub 2048g/7A8B9INV 2007-07-18 [expires: 2009-07-18]
pub 1024R/4B5C6INV 2007-07-18
uid Third Part (Sample key) <tp@mail.invalid>
|
Possiamo anche verificare le firme apposte a quella chiave (nel nostro esempio, è presente solo la firma di autocertificazione):
T:\GnuPG>gpg --edit-key 4B5C6INV
gpg (GnuPG) 1.4.8; Copyright (C) 2007 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.
pub 1024R/4B5C6INV created: 2007-07-18 expires: never usage: SCE
trust: unknown validity: unknown
[ unknown] (1). Third Part (Sample key) <tp@mail.invalid>
Command> check
uid Third Part (Sample key) <tp@mail.invalid>
sig!3 4B5C6INV 2007-07-18 [self-signature]
Command> quit
|
A questo punto, potremo caricare i nostri portachiavi come già spiegato in precedenza (ad esempio, per visualizzare nuovamente le chiavi):
T:\GnuPG>gpg --homedir S:\GnuPG --keyring T:\GnuPG\pubring.gpg --secret-keyring T:\GnuPG\secring.gpg --trustdb-name T:\GnuPG\trustdb.gpg --list-keys
S:/GnuPG\pubring.gpg
--------------------
pub 1024D/1A2B3INV 2007-07-18
uid Test Key (No Comment) <address@mail.invalid>
T:\GnuPG\pubring.gpg
--------------------
pub 1024D/1A2B3INV 2007-07-18
uid Test Key (No Comment) <address@mail.invalid>
sub 2048R/8E9F0INV 2007-07-18 [expires: 2009-07-18]
sub 2048g/7A8B9INV 2007-07-18 [expires: 2009-07-18]
pub 1024R/4B5C6INV 2007-07-18
uid Third Part (Sample key) <tp@mail.invalid>
|
Andremo quindi a modificare la chiave interessata, per poter apporre la nostra firma:
T:\GnuPG>gpg --homedir S:\GnuPG --keyring T:\GnuPG\pubring.gpg --secret-keyring T:\GnuPG\secring.gpg --trustdb-name T:\GnuPG\trustdb.gpg --edit-key 4B5C6INV
gpg (GnuPG) 1.4.8; Copyright (C) 2007 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.
pub 1024R/4B5C6INV created: 2007-07-18 expires: never usage: SCE
trust: unknown validity: unknown
[ unknown] (1). Third Part (Sample key) <tp@mail.invalid>
Command> sign
pub 1024R/4B5C6INV created: 2007-07-18 expires: never usage: SCE
trust: unknown validity: unknown
Primary key fingerprint: A2E9 6C86 DB2D 103E C73B 2682 4D7C 1DD6 E483 C9AB
Third Part (Sample key) <tp@mail.invalid>
Are you sure that you want to sign this key with your
key "Test Key (No Comment) <address@mail.invalid>" (1A2B3INV)
Really sign? (y/N) y
You need a passphrase to unlock the secret key for
user: "Test Key (No Comment) <address@mail.invalid>"
1024-bit DSA key, ID 1A2B3INV, created 2007-07-18
Enter passphrase: ********************
Command> check
uid Third Part (Sample key) <tp@mail.invalid>
sig!3 4B5C6INV 2007-07-18 [self-signature]
sig! 1A2B3INV 2007-07-18 Test Key (No Comment) <address@mail.invalid>
Command> save
|
Come si può vedere nell'ultima parte (dopo il comando "check"),
alla chiave in questione sarà stata apposta anche la nostra firma.
Ultima modifica:
|