Generowanie klucza OpenPGP na urządzeniu¶
Compatible Nitrokeys |
|||||||
|---|---|---|---|---|---|---|---|
✓ active |
⨯ inactive |
⨯ inactive |
✓ active |
⨯ inactive |
✓ active |
✓ active |
⨯ inactive |
Poniższa instrukcja wyjaśnia generowanie kluczy OpenPGP bezpośrednio na Nitrokey. Odbywa się to za pomocą interfejsu wiersza poleceń GnuPG. W związku z tym, musisz mieć zainstalowany GnuPG w swoim systemie. Najnowszą wersję GnuPG dla Windows można znaleźć tutaj, a najnowszą wersję dla MacOS można znaleźć tutaj. Użytkowników systemów linuksowych prosimy o zainstalowanie GnuPG za pomocą menedżera pakietów.
Informacja
Te instrukcje są oparte na GnuPG w wersji 2.2.6 lub wyższej. Niektóre dystrybucje Linuksa mają zainstalowaną starszą wersję. W takim przypadku należy wybrać inną metodę wymienioną tutaj lub zainstalować nowszą wersję, jeśli to możliwe.
Generowanie kluczy¶
The following descriptions explain the basic key generation on-device via GnuPG’s command line interface. The default behaviour is to generate RSA keys of 2048 bit size. If you want to change the key algorithm and length, have a look at the next section first.
Otwórz wiersz poleceń i wpisz gpg2 --card-edit.
To open the Windows command line please push the Windows-key and R-key. Now type cmd.exe in the text field and hit enter. To open a Terminal on macOS or GNU/Linux please use the application search (e.g. spotlight on 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>
Teraz jesteś w interaktywnym interfejsie GnuPG. Aktywuj polecenia administratora za pomocą admin i użyj generate, aby rozpocząć generowanie kluczy.
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>
**Nie należy tworzyć sugerowanej kopii zapasowej poza kartą. Ta „kopia zapasowa” zapisuje tylko klucz szyfrowania, ale nie podpis i klucze uwierzytelniania. W przypadku utraty urządzenia, nie będziesz w stanie przywrócić całego zestawu kluczy. Więc z jednej strony nie jest to pełna kopia zapasowa (użyj tych instrukcji zamiast tego, jeśli potrzebujesz), a z drugiej strony ryzykujesz, że ktoś inny może wejść w posiadanie twojego klucza szyfrowania. Zaletą generowania kluczy na urządzeniu jest pewność, że klucze są przechowywane w bezpieczny sposób. Dlatego zalecamy pominięcie tej części kopii zapasowej.
Teraz masz kompletny zestaw kluczy na swoim urządzeniu, który może być używany do różnych aplikacji wymienionych na naszej stronie. Wpisz quit i naciśnij enter, aby wyjść.
Zmiana Kluczowe atrybuty¶
Ta sekcja dotyczy zmiany atrybutów kluczy. Jeśli chcesz użyć wartości domyślnych, możesz przejść do następnej sekcji.
Otwórz wiersz poleceń i wpisz 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]
Teraz znajdujesz się w interaktywnym interfejsie GnuPG. Jak widać w polu „Atrybuty klucza” powyżej, domyślnie ustawiona jest wartość rsa2048. Aby je zmienić, aktywuj polecenia administratora za pomocą admin i użyj key-attr, aby zmienić atrybuty kluczy.
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:
(1) RSA
(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:
(1) RSA
(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:
(1) RSA
(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
Możesz wybrać atrybut dla każdego klucza (czyli podpisu, klucza szyfrowania i uwierzytelniania). Większość ludzi będzie używać tych samych atrybutów dla każdego klucza. Wpisz list, aby zobaczyć wyniki (spójrz na pole „Atrybuty klucza”, które teraz brzmi 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]
Wpisz quit i naciśnij enter, aby wyjść lub przejdź bezpośrednio do poprzedniej sekcji, aby faktycznie wygenerować klucze z atrybutami kluczy, które właśnie ustawiłeś.
Poniższa tabela ilustruje, który algorytm może być zastosowany na którym urządzeniu.
Algorithm |
Start |
Pro + Storage |
Pro 2 + Storage 2 |
|---|---|---|---|
rsa1024 |
✓ |
✓ |
|
rsa2048 |
✓ |
✓ |
✓ |
rsa3072 |
✓ |
✓ |
|
rsa4096 |
✓ |
✓ |
|
krzywa25519 (ECC) |
✓ |
||
NIST (ECC) |
✓ |
✓ |
|
Brainpool (ECC) |
✓ |
||
secp256k1 |
✓ |
Eksportowanie klucza publicznego i użycie Keyservera¶
Chociaż możesz zacząć używać Nitrokey od razu po wygenerowaniu kluczy w Twoim systemie, musisz zaimportować swój klucz publiczny na każdym systemie, na którym chcesz używać Nitrokey. Aby być przygotowanym masz dwie opcje: albo zapisujesz klucz publiczny gdziekolwiek chcesz i używasz go na innym systemie, albo zapisujesz klucz publiczny na stronie internetowej/serwerze kluczy.
Generowanie pliku klucza publicznego¶
Aby uzyskać prosty plik swojego klucza publicznego, możesz po prostu użyć gpg2 --armor --export keyID > pubkey.asc. Użyj albo odcisku palca jako „keyID” (spójrz na gpg -K, aby go uzyskać) lub po prostu użyj swojego adresu e-mail jako identyfikatora.
You can carry this file with you or send it to anyone who you like. This file is not secret at all. If you want to use the Nitrokey on another system, you first import this public key via gpg2 --import pubkey.asc and then types gpg2 --card-status so that the system knows where to look for this key. That’s all.
Przesyłanie klucza publicznego¶
Jeśli nie chcesz nosić ze sobą pliku klucza publicznego, możesz przesłać go do keyservera. Możesz to zrobić wpisując gpg --keyserver search.keyserver.net --send-key keyID. Jeśli używasz innej maszyny, możesz po prostu zaimportować go używając gpg --keyserver search.keyserver.net --recv-key keyID.
Another possibility is to change the URL setting on your card.
Run gpg --card-edit again and first set the URL where the key is situated (e.g. on the keyserver or on your webpage etc.) via the url command.
From now on you can import the key on another system by just using the fetch command within the gpg --card-edit environment.