„OpenPGP“ raktų generavimas su atsargine kopija#

(Nitrokey Storage 2 - macOS)

Toliau pateikiamuose nurodymuose paaiškinama, kaip generuoti „OpenPGP“ raktus ir kaip juos nukopijuoti į „Nitrokey“. Šio būdo privalumas yra tas, kad praradus ar sulaužius „Nitrokey“, galima sukurti atsarginę raktų kopiją. Instrukcijos pagrįstos GnuPG komandinės eilutės sąsaja. Taigi jūsų sistemoje turi būti įdiegta GnuPG. Naujausią „Windows“ skirtą „GnuPG“ versiją rasite kur, o naujausią „MacOS“ skirtą versiją rasite kur. „Linux“ sistemų naudotojų prašome įdiegti „GnuPG“ naudojant paketų tvarkyklę.

Raktų generavimas#

Iš pradžių reikia vietoje sukurti raktą. Galite nuspręsti, kokius rakto atributus naudoti, o svarbiausia - galite raktą eksportuoti ir išsaugoti, jei prireiktų jį atkurti.

Pagrindinis raktas ir šifravimo pagalbinis raktas#

Galime naudoti komandą gpg --full-generate-key --expert, norėdami pradėti vedamąjį rakto generavimą su visomis galimomis parinktimis. Galima pasirinkti rakto tipą (paprastai RSA (1) arba ECC (9)), rakto ilgį ir kitus požymius. Toliau pateikiamas išvesties rodmuo yra tik paprastas pavyzdys, galite pasirinkti kitas reikšmes.

> 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]

Pastaba

Informacijos apie palaikomus algoritmus rasite faq.

Autentiškumo nustatymo rakto pakaitalas#

Dabar turite pagrindinį raktą, galintį pasirašyti ir patvirtinti (pažymėtą [SC]), ir šifravimo rakto dalį (pažymėtą [E]). Naudojimo atvejams, kai reikalingas autentiškumo patvirtinimas, būtina turėti dar vieną pagalbinį raktą. Šis dalinis raktas sukuriamas kitame etape. Norėdami pradėti procesą, įveskite gpg --edit-key --expert keyID, o „keyID“ yra rakto ID arba el. pašto adresas, naudotas generuojant raktą.

> 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>

Dabar esate interaktyviajame GnuPG režime ir galite pridėti raktą tiesiog įvesdami addkey. Reikia pasirinkti raktą, kurį norite naudoti. Labai svarbu pasirinkti „Set your own capabilities“ (nustatyti savo galimybes), nes norime turėti „Autentification“ (autentifikavimo) galimybę, kurios kitu atveju nėra. Pasirašymą ir šifravimą perjungiame įvesdami </x id="320"></x> ir e ir aktyvuojame autentifikavimą, įvesdami </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

Baigiame su q. Vėliau turime atsakyti į tuos pačius klausimus kaip ir anksčiau. Galiausiai turime paruoštą raktų rinkinį, kurį galime importuoti į savo įrenginį.

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

Dabar yra tinkamas laikas sukurti atsarginę rakto kopiją. Šią atsarginę kopiją saugokite labai saugiai. Geriausia šio rakto niekada nelaikyti įprastame kompiuteryje, kuris turi ryšį su internetu, kad raktas niekada nebūtų pažeistas. Atsarginę kopiją galite sukurti naudodami pvz:

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

Pagrindinis importas#

Turite pagrindinį raktą ir du papildomus raktus, kuriuos galima importuoti į „Nitrokey“. Prieš tęsdami įsitikinkite, kad tikrai turite atsarginę rakto kopiją, jei jums jos reikia. Tolesniuose veiksmuose naudojama komanda keytocard pašalins jūsų raktą iš disko!

Procesą pradedame vėl prisijungę prie interaktyviosios GnuPG sąsajos su gpg --edit-key --expert keyID, o keyID yra rakto id arba el. pašto adresas, naudotas generuojant raktą.

> 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

Ką tik importavome pagrindinį raktą į kortelę. Dabar pereisime prie dviejų pagalbinių raktų. Įrašome key 1, kad pasirinktume šifravimo pagalbinį raktą, ir vėl įrašome keytocard ir pasirenkame naudojamą lizdą.

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

Dabar panaikiname pirmojo rakto pasirinkimą naudodami key 1 ir pasirenkame antrąjį subklavišą naudodami key 2 ir jį taip pat perkeliame su keytocard. Po to baigiame darbą ir išsaugome pakeitimus.

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

Jūsų raktai perkeliami į „Nitrokey“ ir taip apsaugomi aparatinėje įrangoje. Sveikiname!

Viešojo rakto eksportavimas ir Keyserverio naudojimas#

Nors galite pradėti naudoti „Nitrokey“ iš karto po raktų generavimo savo sistemoje, turite importuoti viešąjį raktą į kiekvieną sistemą, kurioje norite naudoti „Nitrokey“. Taigi, norėdami pasiruošti, turite dvi galimybes: Viešąjį raktą galite išsaugoti bet kurioje norimoje vietoje ir naudoti kitoje sistemoje arba išsaugoti viešąjį raktą interneto svetainėje / raktų serveryje.

Viešojo rakto failo generavimas#

Norėdami gauti paprastą savo viešojo rakto failą, galite tiesiog naudoti gpg --armor --export keyID > pubkey.asc. Kaip „keyID“ naudokite pirštų atspaudą (pažiūrėkite į gpg -K, kad jį gautumėte) arba tiesiog naudokite savo el. pašto adresą kaip identifikatorių.

Šį failą galite nešiotis su savimi arba siųsti bet kam, kam tik norite. Šis failas visai neslaptas. Jei norite naudoti „Nitrokey“ kitoje sistemoje, pirmiausia importuokite šį viešąjį raktą per gpg --import pubkey.asc ir tada įveskite </x>`gpg --card-status, kad sistema žinotų, kur ieškoti šio rakto. Tai viskas.

Viešojo rakto įkėlimas#

Jei nenorite su savimi nešiotis viešojo rakto failo, galite jį įkelti į keyserverį. Tai galite padaryti įvesdami gpg --keyserver search.keyserver.net --send-key keyID. Jei naudojate kitą kompiuterį, galite jį tiesiog importuoti naudodami gpg --keyserver search.keyserver.net --recv-key keyID.

Kita galimybė - pakeisti kortelės URL nustatymą. Vėl paleiskite gpg --card-edit ir pirmiausia nustatykite URL, kuriame yra raktas (pvz., raktų serveryje arba jūsų tinklalapyje ir pan.), naudodami komandą url. Nuo šiol raktą į kitą sistemą galite importuoti tiesiog naudodami ``fetch komandą, esančią gpg --card-edit environment.