OpenPGP atslēgas ģenerēšana ar dublēšanu#

(Nitrokey Pro 2 - macOS)

Turpmākajos norādījumos ir izskaidrota OpenPGP atslēgu ģenerēšana un to kopēšana uz Nitrokey. Šīs metodes priekšrocība ir tā, ka tā nodrošina atslēgu dublējumu Nitrokey nozaudēšanas vai sabojāšanas gadījumā. Instrukcijas ir balstītas uz GnuPG komandrindas saskarni. Tāpēc jūsu sistēmā ir jābūt instalētam GnuPG. Jaunāko GnuPG versiju operētājsistēmai Windows var atrast šeit un jaunāko versiju operētājsistēmai MacOS var atrast šeit. Linux sistēmu lietotājus lūdzam instalēt GnuPG ar pakotņu pārvaldnieka palīdzību.

Atslēgu ģenerēšana#

Vispirms ir jāģenerē atslēga lokāli. Jūs varat izlemt, kādus atslēgas atribūtus izmantot, un, kas ir vissvarīgākais, varat eksportēt atslēgu un saglabāt to kaut kur, lai saglabātu gadījumā, ja atslēgu nepieciešams atjaunot.

Galvenā atslēga un šifrēšanas papildatslēga#

Varam izmantot komandu gpg --full-generate-key --expert, lai sāktu vadītu atslēgas ģenerēšanu ar visām iespējamām iespējām. Var izvēlēties atslēgas veidu (parasti RSA (1) vai ECC (9)), atslēgas garumu un citus atribūtus. Tālāk redzamais izvads ir tikai vienkāršs piemērs, jūs varat izvēlēties citas vērtības.

> gpg --full-generate-key --expert
gpg (GnuPG) 2.2.10; Copyright (C) 2018 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)
   (7) DSA (set your own capabilities)
   (8) RSA (set your own capabilities)
   (9) ECC and ECC
  (10) ECC (sign only)
  (11) ECC (set your own capabilities)
  (13) Existing key
Your selection? 1
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
Requested keysize is 2048 bits
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want for the subkey? (2048)
Requested keysize is 2048 bits
Please specify how long the key should be valid.
         0 = key does not expire
        = key expires in n days
      w = key expires in n weeks
      m = key expires in n months
      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 "

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.
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 0EFFB0704391497C marked as ultimately trusted
gpg: revocation certificate stored as '/home/nitrokey//.gnupg/openpgp-revocs.d/9D12C91F6FC4CD6E10A1727A0EFFB0704391497C.rev'
public and secret key created and signed.

pub   rsa2048 2018-09-17 [SC]
      9D12C91F6FC4CD6E10A1727A0EFFB0704391497C
uid                      Jane Doe
sub   rsa2048 2018-09-17 [E]

Piezīme

Informāciju par atbalstītajiem algoritmiem skatiet faq.

Autentifikācijas autentifikācijas atslēgas apakšatslēga#

Tagad jums ir galvenā atslēga ar iespēju parakstīt un sertificēt (atzīmēta kā [SC]) un papildatslēga šifrēšanai (atzīmēta kā [E]). Nepieciešams vēl viens papildatslēga izmantošanas gadījumiem, kad ir nepieciešama autentifikācija. Šo apakšatslēgu ģenerē nākamajā solī. Ievadiet gpg --edit-key --expert keyID, lai sāktu procesu, savukārt „keyID“ ir vai nu atslēgas id, vai atslēgas ģenerēšanā izmantotā e-pasta adrese.

> gpg --edit-key --expert jane@example.com
gpg (GnuPG) 2.2.10; Copyright (C) 2018 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.

Secret key is available.

sec  rsa2048/0EFFB0704391497C
     created: 2018-09-17  expires: never       usage: SC
     trust: ultimate      validity: ultimate
ssb  rsa2048/A9A814C210F16700
     created: 2018-09-17  expires: never       usage: E
[ultimate] (1). Jane Doe

gpg>

Tagad esat GnuPG interaktīvajā režīmā un varat pievienot atslēgu, vienkārši ierakstot addkey. Jums ir jāizvēlas atslēga, kuru vēlaties izmantot. Ļoti svarīgi ir izvēlēties „iestatīt savas spējas“, jo mēs vēlamies, lai mums būtu iespēja „autentificēt“, kas citādi nav pieejama. Mēs pārslēdzam parakstīšanu un šifrēšanu, ierakstot </x id="320"></x> un e un aktivizējam autentificēšanu, ierakstot </x id="375"></x>.

gpg> addkey
Please select what kind of key you want:
   (3) DSA (sign only)
   (4) RSA (sign only)
   (5) Elgamal (encrypt only)
   (6) RSA (encrypt only)
   (7) DSA (set your own capabilities)
   (8) RSA (set your own capabilities)
  (10) ECC (sign only)
  (11) ECC (set your own capabilities)
  (12) ECC (encrypt only)
  (13) Existing key
Your selection? 8

Possible actions for a RSA key: Sign Encrypt Authenticate
Current allowed actions: Sign Encrypt

   (S) Toggle the sign capability
   (E) Toggle the encrypt capability
   (A) Toggle the authenticate capability
   (Q) Finished

Your selection? s

Possible actions for a RSA key: Sign Encrypt Authenticate
Current allowed actions: Encrypt

   (S) Toggle the sign capability
   (E) Toggle the encrypt capability
   (A) Toggle the authenticate capability
   (Q) Finished

Your selection? e

Possible actions for a RSA key: Sign Encrypt Authenticate
Current allowed actions:

   (S) Toggle the sign capability
   (E) Toggle the encrypt capability
   (A) Toggle the authenticate capability
   (Q) Finished

Your selection? a

Possible actions for a RSA key: Sign Encrypt Authenticate
Current allowed actions: Authenticate

   (S) Toggle the sign capability
   (E) Toggle the encrypt capability
   (A) Toggle the authenticate capability
   (Q) Finished

Your selection? q

Mēs beidzam ar q. Pēc tam mums jāatbild uz tiem pašiem jautājumiem kā iepriekš. Visbeidzot mums ir gatavs atslēgu komplekts, ko varam importēt savā ierīcē.

RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
Requested keysize is 2048 bits
Please specify how long the key should be valid.
         0 = key does not expire
        = key expires in n days
      w = key expires in n weeks
      m = key expires in n months
      y = key expires in n years
Key is valid for? (0)
Key does not expire at all
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.

sec  rsa2048/0EFFB0704391497C
     created: 2018-09-17  expires: never       usage: SC
     trust: ultimate      validity: ultimate
ssb  rsa2048/A9A814C210F16700
     created: 2018-09-17  expires: never       usage: E
ssb  rsa2048/61F186B8B0BBD5D5
     created: 2018-09-17  expires: never       usage: A
[ultimate] (1). Jane Doe

gpg> quit
Save changes? (y/N) y

Tagad ir īstais brīdis, lai izveidotu rezerves kopiju. Lūdzu, saglabājiet šo dublējumu ļoti drošā veidā. Labākā prakse ir nekad nelikt šo atslēgu parastā datorā, kam ir savienojums ar internetu, lai atslēga nekad netiktu apdraudēta. Rezerves kopiju varat izveidot, izmantojot, piemēram, šādu programmu:

> gpg --export-secret-keys jane@example.com > sec-key.asc

Galvenais imports#

Jums ir galvenā atslēga un divas papildatslēgas, kuras var importēt uz Nitrokey. Pirms turpināšanas pārliecinieties, ka jums patiešām ir atslēgas dublējums, ja tāds ir nepieciešams. Nākamajos soļos izmantotā keytocard komanda izdzēsīs jūsu atslēgu no diska!

Mēs sākam procesu, atkal piekļūstot GnuPG interaktīvajam interfeisam ar gpg --edit-key --expert keyID, savukārt keyID ir atslēgas id vai atslēgas ģenerēšanas laikā izmantotā e-pasta adrese.

> gpg --edit-key --expert jane@example.com
gpg (GnuPG) 2.2.10; Copyright (C) 2018 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.

Secret key is available.

sec  rsa2048/0EFFB0704391497C
     created: 2018-09-17  expires: never       usage: SC
     trust: ultimate      validity: ultimate
ssb  rsa2048/A9A814C210F16700
     created: 2018-09-17  expires: never       usage: E
ssb  rsa2048/61F186B8B0BBD5D5
     created: 2018-09-17  expires: never       usage: A
[ultimate] (1). Jane Doe

gpg> keytocard
Really move the primary key? (y/N) y
Please select where to store the key:
   (1) Signature key
   (3) Authentication key
Your selection? 1

sec  rsa2048/0EFFB0704391497C
     created: 2018-09-17  expires: never       usage: SC
     trust: ultimate      validity: ultimate
ssb  rsa2048/A9A814C210F16700
     created: 2018-09-17  expires: never       usage: E
ssb  rsa2048/61F186B8B0BBD5D5
     created: 2018-09-17  expires: never       usage: A
[ultimate] (1). Jane Doe

Mēs tikai importējām galveno atslēgu uz karti. Tagad mēs turpinām darbu ar diviem papildatslēgiem. Ievadām key 1, lai atlasītu šifrēšanas papildatslēgu, un ievadām keytocard un vēlreiz izvēlamies slotu, ko izmantot.

gpg> key 1

sec  rsa2048/0EFFB0704391497C
     created: 2018-09-17  expires: never       usage: SC
     trust: ultimate      validity: ultimate
ssb* rsa2048/A9A814C210F16700
     created: 2018-09-17  expires: never       usage: E
ssb  rsa2048/61F186B8B0BBD5D5
     created: 2018-09-17  expires: never       usage: A
[ultimate] (1). Jane Doe

gpg> keytocard
Please select where to store the key:
   (2) Encryption key
Your selection? 2

sec  rsa2048/0EFFB0704391497C
     created: 2018-09-17  expires: never       usage: SC
     trust: ultimate      validity: ultimate
ssb* rsa2048/A9A814C210F16700
     created: 2018-09-17  expires: never       usage: E
ssb  rsa2048/61F186B8B0BBD5D5
     created: 2018-09-17  expires: never       usage: A
[ultimate] (1). Jane Doe

Tagad noņemam pirmās atslēgas atlasi ar key 1 un izvēlamies otro apakšatslēgu ar key 2 un pārvietojam arī to ar keytocard. Pēc tam izstājamies un saglabājam izmaiņas.

gpg> key 1

sec  rsa2048/0EFFB0704391497C
     created: 2018-09-17  expires: never       usage: SC
     trust: ultimate      validity: ultimate
ssb  rsa2048/A9A814C210F16700
     created: 2018-09-17  expires: never       usage: E
ssb  rsa2048/61F186B8B0BBD5D5
     created: 2018-09-17  expires: never       usage: A
[ultimate] (1). Jane Doe

gpg> key 2

sec  rsa2048/0EFFB0704391497C
     created: 2018-09-17  expires: never       usage: SC
     trust: ultimate      validity: ultimate
ssb  rsa2048/A9A814C210F16700
     created: 2018-09-17  expires: never       usage: E
ssb* rsa2048/61F186B8B0BBD5D5
     created: 2018-09-17  expires: never       usage: A
[ultimate] (1). Jane Doe

gpg> keytocard
Please select where to store the key:
   (3) Authentication key
Your selection? 3

sec  rsa2048/0EFFB0704391497C
     created: 2018-09-17  expires: never       usage: SC
     trust: ultimate      validity: ultimate
ssb  rsa2048/A9A814C210F16700
     created: 2018-09-17  expires: never       usage: E
ssb* rsa2048/61F186B8B0BBD5D5
     created: 2018-09-17  expires: never       usage: A
[ultimate] (1). Jane Doe

gpg> quit
Save changes? (y/N) y

Tagad jūsu atslēgas ir pārvietotas uz Nitrokey un tādējādi ir nodrošinātas ar aparatūru. Apsveicam!

Publiskās atslēgas eksportēšana un atslēgu servera izmantošana#

Lai gan pēc atslēgu ģenerēšanas savā sistēmā Nitrokey varat sākt izmantot uzreiz, publiskā atslēga jāimportē katrā sistēmā, kurā vēlaties izmantot Nitrokey. Lai būtu gatavi, jums ir divas iespējas: Vai nu saglabājat publisko atslēgu jebkurā vēlamajā vietā un izmantojat to citā sistēmā, vai arī saglabājat publisko atslēgu tīmekļa vietnē/atslēgu serverī.

Publiskās atslēgas faila ģenerēšana#

Lai iegūtu vienkāršu publiskās atslēgas failu, varat vienkārši izmantot gpg --armor --export keyID > pubkey.asc. Izmantojiet pirkstu nospiedumu kā „keyID“ (skatiet gpg -K, lai to iegūtu) vai vienkārši izmantojiet savu e-pasta adresi kā identifikatoru.

Šo failu varat nēsāt līdzi vai nosūtīt jebkuram, kas jums patīk. Šis fails nav slepens. Ja Nitrokey vēlaties izmantot citā sistēmā, vispirms importējiet šo publisko atslēgu, izmantojot gpg --import pubkey.asc, un pēc tam ierakstiet </x>`gpg --card-status, lai sistēma zinātu, kur šo atslēgu meklēt. Tas ir viss.

Publiskās atslēgas augšupielāde#

Ja nevēlaties nēsāt līdzi publisko atslēgas failu, varat to augšupielādēt keyserver. To var izdarīt, ierakstot gpg --keyserver search.keyserver.net --send-key keyID. Ja izmantojat citu mašīnu, varat to vienkārši importēt, izmantojot gpg --keyserver search.keyserver.net --recv-key keyID.

Vēl viena iespēja ir mainīt kartes URL iestatījumu. Palaidiet `gpg --card-edit vēlreiz un vispirms iestatiet URL, kurā atrodas atslēga (piemēram, atslēgu serverī vai jūsu tīmekļa vietnē u. c.), izmantojot </x id="201"></x> komandu. Turpmāk atslēgu var importēt citā sistēmā, vienkārši izmantojot fetch komandu gpg --card-edit environment.