Generazione di chiavi OpenPGP sul dispositivo#

(Nitrokey Pro 2 - Windows)

The following instructions explain the generation of OpenPGP keys directly on the Nitrokey. This is done by using the command line interface of GnuPG. Thus, you need to have GnuPG installed on your system. The newest GnuPG version for Windows can be found here and the newest version for MacOS can be found here. Users of Linux systems please install GnuPG with help of the package manager.

Nota

Queste istruzioni si basano su GnuPG versione 2.2.6 o superiore. Alcune distribuzioni Linux hanno installato una versione precedente. In questo caso si prega di scegliere un metodo diverso come elencato ` qui <openpgp.html>`_ o installare una versione più recente se possibile.

Generazione di chiavi#

Le seguenti descrizioni spiegano la generazione di base delle chiavi sul dispositivo tramite l’interfaccia a riga di comando di GnuPG. Il comportamento predefinito è quello di generare chiavi RSA di 2048 bit. Se volete cambiare l’algoritmo e la lunghezza della chiave, date prima un’occhiata alla prossima sezione.

Aprite una linea di comando e digitate gpg2 --card-edit.

Per aprire la riga di comando di Windows premete il tasto Windows e il tasto R. Ora scrivi “cmd.exe” nel campo di testo e premi invio. Per aprire un terminale su macOS o GNU/Linux usa la ricerca delle applicazioni (ad esempio Spotlight su macOS).

> gpg2 --card-edit

Reader ...........: 20A0:4108:0000320E0000000000000000:0
Application ID ...: D27600012401020100050000320E0000
Version ..........: 2.1
Manufacturer .....: ZeitControl
Serial number ....: 0000320E
Name of cardholder: [not set]
Language prefs ...: de
Sex ..............: unspecified
URL of public key : [not set]
Login data .......: [not set]
Signature PIN ....: forced
Key attributes ...: rsa2048 rsa2048 rsa2048
Max. PIN lengths .: 32 32 32
PIN retry counter : 3 0 3
Signature counter : 0
Signature key ....: [none]
Encryption key....: [none]
Authentication key: [none]
General key info..: [none]

gpg/card>

Ora siete nell’interfaccia interattiva di GnuPG. Attivate i comandi di amministrazione con admin e usate generate dopo per iniziare la generazione delle chiavi.

gpg/card> admin
Admin commands are allowed

gpg/card> generate
Make off-card backup of encryption key? (Y/n) n

Please note that the factory settings of the PINs are
   PIN = '123456'     Admin PIN = '12345678'
You should change them using the command --change-pin

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: Jane Doe
Email address: jane@example.com
Comment:
You selected this USER-ID:
"Jane Doe <jane@doecom>"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
gpg: key 817E149CA002B92F marked as ultimately trusted
gpg: revocation certificate stored as '/home/nitrokey//.gnupg/openpgp-revocs.d/E62F445E8BB4B5085C031F5381
7E149CA002B92F.rev'
public and secret key created and signed.


gpg/card>
</jane@doe.com></n></n></n></n>

**Questo «backup» salva solo la chiave di crittografia, ma non la firma e le chiavi di autenticazione. In caso di perdita del dispositivo, non sarà possibile ripristinare l’intero set di chiavi. Quindi da un lato non è un backup completo (usate ` queste istruzioni <openpgp-keygen-backup.html>`_ invece, se ne avete bisogno) e dall’altro lato rischiate che qualcun altro possa entrare in possesso della vostra chiave di cifratura. Il vantaggio di generare le chiavi sul dispositivo è quello di assicurarsi che le chiavi siano conservate in modo sicuro. Pertanto, si consiglia di saltare questo mezzo backup.

Ora avete un set completo di chiavi sul vostro dispositivo che può essere utilizzato per le varie applicazioni elencate sul nostro sito. Scrivi quit e premi invio per uscire.

Cambiare gli attributi chiave#

Questa sezione riguarda la modifica degli attributi chiave. Se vuoi usare i valori predefiniti, puoi procedere con la prossima sezione.

Aprite una linea di comando e digitate gpg2 --card-edit --expert.

> gpg2 --card-edit --expert

Reader ...........: 20A0:4108:0000320E0000000000000000:0
Application ID ...: D27600012401020100050000320E0000
Version ..........: 2.1
Manufacturer .....: ZeitControl
Serial number ....: 0000320E
Name of cardholder: [not set]
Language prefs ...: de
Sex ..............: unspecified
URL of public key : [not set]
Login data .......: [not set]
Signature PIN ....: forced
Key attributes ...: rsa2048 rsa2048 rsa2048
Max. PIN lengths .: 32 32 32
PIN retry counter : 3 0 3
Signature counter : 0
Signature key ....: [none]
Encryption key....: [none]
Authentication key: [none]
General key info..: [none]

Ora siete nell’interfaccia interattiva di GnuPG. Come potete vedere nel campo «Key attributes» sopra, è impostato il valore predefinito rsa2048. Per cambiarli, attivate i comandi di amministrazione con admin e usate key-attr successivamente per cambiare gli attributi delle chiavi.

gpg/card> admin
Admin commands are allowed

gpg/card> key-attr
Changing card key attribute for: Signature key
Please select what kind of key you want:
&nbsp;&nbsp; (1) RSA
&nbsp;&nbsp; (2) ECC
Your selection? 1
What keysize do you want? (2048) 4096
The card will now be re-configured to generate a key of 4096 bits
Changing card key attribute for: Encryption key
Please select what kind of key you want:
&nbsp;&nbsp; (1) RSA
&nbsp;&nbsp; (2) ECC
Your selection? 1
What keysize do you want? (2048) 4096
The card will now be re-configured to generate a key of 4096 bits
Changing card key attribute for: Authentication key
Please select what kind of key you want:
&nbsp;&nbsp; (1) RSA
&nbsp;&nbsp; (2) ECC
Your selection? 1
What keysize do you want? (2048) 4096
The card will now be re-configured to generate a key of 4096 bits

Puoi scegliere l’attributo per ogni chiave (cioè firma, chiave di crittografia e di autenticazione). La maggior parte delle persone userà gli stessi attributi per ogni chiave. Scrivi list per vedere i risultati (guarda il campo «Key attributes», che ora dice rsa4096).

gpg/card> list

Reader ...........: 20A0:4108:0000320E0000000000000000:0
Application ID ...: D27600012401020100050000320E0000
Version ..........: 2.1
Manufacturer .....: ZeitControl
Serial number ....: 0000320E
Name of cardholder: [not set]
Language prefs ...: de
Sex ..............: unspecified
URL of public key : [not set]
Login data .......: [not set]
Signature PIN ....: forced
Key attributes ...: rsa4096 rsa4096 rsa4096
Max. PIN lengths .: 32 32 32
PIN retry counter : 3 0 3
Signature counter : 0
Signature key ....: [none]
Encryption key....: [none]
Authentication key: [none]
General key info..: [none]

Scrivi quit e premi invio per uscire o procedi direttamente con la sezione precedente per generare effettivamente le chiavi con gli attributi chiave che hai appena impostato.

La seguente tabella illustra quale algoritmo può essere utilizzato su quale dispositivo.

Iniziare

Pro + Storage

Pro 2 + Storage 2

rsa1024

rsa2048

rsa3072

rsa4096

curva25519 (ECC)

NIST (ECC)

Brainpool (ECC)

secp256k1

Esportazione della chiave pubblica e uso del Keyserver#

Anche se puoi iniziare a usare la tua Nitrokey subito dopo aver generato le chiavi sul tuo sistema, devi importare la tua chiave pubblica su ogni sistema su cui vuoi usare la Nitrokey. Quindi per essere preparati avete due opzioni: O salvi la chiave pubblica dove vuoi e la usi su un altro sistema o salvi la chiave pubblica su una pagina web/keyserver.

Generare un file di chiave pubblica#

Per ottenere un semplice file della vostra chiave pubblica, potete semplicemente usare gpg2 --armor --export keyID > pubkey.asc. Usa l’impronta digitale come «keyID» (guarda gpg -K per ottenerlo) o usa semplicemente il tuo indirizzo email come identificatore.

Potete portare questo file con voi o inviarlo a chiunque vogliate. Questo file non è affatto segreto. Se volete usare la Nitrokey su un altro sistema, dovete prima importare questa chiave pubblica tramite gpg2 --import pubkey.asc e poi scrivere gpg2 --card-status in modo che il sistema sappia dove cercare questa chiave. Questo è tutto.

Caricare la chiave pubblica#

Se non volete portare con voi un keyfile pubblico, potete caricarlo su keyserver. Puoi farlo digitando gpg --keyserver search.keyserver.net --send-key keyID. Se stai usando un’altra macchina puoi semplicemente importarlo usando gpg --keyserver search.keyserver.net --recv-key keyID.

Un’altra possibilità è cambiare l’impostazione dell’URL sulla vostra scheda. Avviate nuovamente gpg -card-edit e per prima cosa impostate l’URL dove si trova la chiave (ad esempio sul keyserver o sulla vostra pagina web ecc.) tramite il comando url. D’ora in poi potrete importare la chiave su un altro sistema usando semplicemente il comando fetch all’interno dell’ambiente gpg --card-edit.