Elliptisten käyrien (ECC) tuki¶
Compatible Nitrokeys |
|||||||
|---|---|---|---|---|---|---|---|
✓ active |
⨯ inactive |
✓ active |
✓ active |
⨯ inactive |
✓ active |
⨯ inactive |
⨯ inactive |
RSA-2048 muuttuu yhä epävarmemmaksi¶
Saksan liittovaltion tietoturvavirasto (Bundesamt für Sicherheit in der Informationstechnik, BSI) ei turvallisuussyistä enää suosittele 2048-bittisten ` RSA-avainten käyttöä vuoden 2023 jälkeen <https://www.bsi.bund.de/SharedDocs/Downloads/EN/BSI/Publications/TechGuidelines/TG02102/BSI-TR-02102-1.pdf>`__. Tämä tarkoittaa, että pidempiä avaimia on otettava käyttöön lähitulevaisuudessa. Jos oletetaan, että käyttöaika on viisi vuotta, on jo nyt tarpeen luoda pidempiä avaimia. Pidemmät RSA-avaimet, 3072 tai 4096 bittiä, ovat kuitenkin huomattavasti hitaampia. Tästä syystä uudet Nitrokey Storage 2 ja Pro 2 (tai integroidun OpenPGP-kortin versio 3.3) tukevat salausta elliptisen käyrän salausmenetelmällä (ECC). Tätä menetelmää pidetään yhtä turvallisena pienemmillä ECC-avaimilla kuin pidemmillä RSA-avaimilla, ja se on myös huomattavasti nopeampi.
Elliptisen käyrän salauksen perusteet¶
Toisin kuin RSA:ssa, elliptisen käyrän salausmenetelmästä on olemassa monia eri muotoja (niin sanottuja käppyröitä). Erityisesti NSA oli mukana NIST-käyrien kehittämisessä. Vaikka käyrissä ei olisikaan todisteita takaovista, tietyn käyrän käyttäminen voi herättää luottamuskysymyksen. Onneksi uudet Nitrokey Storage 2 ja Pro 2 tukevat kahdenlaisia käyriä, nimittäin NIST- ja Brainpool-käyriä. Seuraavassa käytämme Brainpool-käyriä. Tämä artikkeli tarjoaa hyvän lähtökohdan yleiseen ymmärrykseen elliptisten käyrien kryptografiasta.
Järjestelmävaatimukset¶
Elliptisiin käyriin perustuvien avainten luomiseen tarvitaan Nitrokey Storage 2 / Pro 2 ja GnuPG:n versio 2.1.17 tai uudempi.
You can read Nitrokey’s OpenPGP Card version via gpg2 --card-status:
> gpg2 --card-status
Reader ...........: 20A0:...
Application ID ...: D276...
Version ..........: 3.3
...
The Version field represents the version of the OpenPGP Card integrated in the Nitrokey — in this case it is 3.3 as needed for Elliptic-curve cryptography. OpenPGP Card version 2.2 doesn’t support ECC.
GnuPG:n asennetun version saat selville gpg2 --version kautta. Vähintään versio 2.1.16 vaaditaan. Uusin GnuPG-versio Windowsille löytyy täältä ja uusin versio MacOS:lle löytyy täältä. Sopiva versio GnuPG:stä sisältyy GNU/Linux-jakeluihin Ubuntu (18.04:stä lähtien), Debian (Stretchistä lähtien), Arch Linux, Fedora (julkaisusta 26 lähtien) ja openSUSE Tumbleweed. Tämän artikkelin lopussa on ohjeet GnuPG:n manuaaliseen päivittämiseen vanhemmissa Ubuntu-versioissa.
Tärkeä
GnuPG 2.0 on edelleen käytössä, mutta sen tuki on lopetettu vuonna 2017. Kaikkien viestintäkumppaneiden on käytettävä GnuPG 2.1:tä tai uudempaa versiota sähköpostin salaukseen ECC:n avulla, muuten saattaa syntyä yhteensopimattomuusongelmia. Siksi ECC:tä kannattaa käyttää vain, jos olet varma, että pystyt kiertämään tämän ongelman.
Avainten tuottaminen Nitrokey Storage 2 / Pro 2 -laitteella¶
Once these requirements are fulfilled, you can get started. (Warning: existing keys will be overwritten in the process!) You now have two options. The first option is to create the key directly on the Nitrokey Storage 2 / Pro 2. The benefit here is that the key will never be outside the device and as such can never be read out. The second option is to import a previously locally generated key. The advantage in this case is that you can securely store a backup of the key, which can then be restored in case the Nitrokey is lost. Only the first option is described below. In order to create a key with backup, you can access the following instructions and use this general information to transfer the key to the Nitrokey.
GnuPG:ssä on jo komento ”generate”, jolla voit helposti luoda avaimia laitteeseen. Avaintyyppiä ei kuitenkaan vielä voi valita suoraan, joten avain on ensin valmisteltava. Käytämme tähän seuraavia komentoja:
> gpg-connect-agent "SCD SETATTR KEY-ATTR --force 1 19 brainpoolP256r1" /bye
> gpg-connect-agent "SCD SETATTR KEY-ATTR --force 2 18 brainpoolP256r1" /bye
> gpg-connect-agent "SCD SETATTR KEY-ATTR --force 3 19 brainpoolP256r1" /bye
Vaihtoehtoisesti voidaan valita myös muita käyriä, kuten seuraavassa jaksossa kuvataan.
Nyt kirjoitamme gpg2 --card-edit ja näemme, että brainpoolP256r1 on ”key attributes” -kohdassa rsa2048:n sijaan.
> gpg2 --card-edit
Reader ...........: 20A0:4109:0000000000000:0
Application ID ...: D276000124010303000500005F100000
Version ..........: 3.3
Manufacturer .....: ZeitControl
Serial number ....: 00005F10
Name of cardholder: [not set]
Language prefs ...: [not set]
Sex ..............: unspecified
URL of public key : [not set]
Login data .......: [not set]
Signature PIN ....: forced
Key attributes ...: brainpoolP256r1 brainpoolP256r1 brainpoolP256r1
Max. PIN lengths .: 64 64 64
PIN retry counter : 3 0 3
Signature counter : 0
Signature key ....: [none]
Encryption key....: [none]
Authentication key: [none]
General key info..: [none]
Sitten luomme avaimen.
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.doe@example.org
Comment:
You selected this USER-ID:
"Jane Doe <jane.doe@example.org>"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
gpg: key 7F8C68E1B084E169 marked as ultimately trusted
gpg: revocation certificate stored as '/home/jane/.gnupg/openpgp-revocs.d/F8C00BC1636A7D7604A31A877F8C68E1B084E169.rev'
public and secret key created and signed.
Nitrokey käyttää nyt RSA-avaimen sijasta elliptisen käyrän salausmenetelmää, ja sitä voidaan käyttää tavalliseen tapaan.
Saatavilla olevat käyrät¶
Edellä esitetyssä menettelyssä valitsimme Brainpool-käyrät. Vaihtoehtoisesti voidaan käyttää NIST-käyriä. Konfigurointi suoritetaan seuraavasti:
> gpg-connect-agent "SCD SETATTR KEY-ATTR --force 1 19 nistp256" /bye
> gpg-connect-agent "SCD SETATTR KEY-ATTR --force 2 18 nistp256" /bye
> gpg-connect-agent "SCD SETATTR KEY-ATTR --force 3 19 nistp256" /bye
Päivitys GnuPG Ubuntussa¶
The following steps are needed only if you are running a Ubuntu version older than 18.04. You can install GnuPG 2.1.18 on such system with the commands below. This involves newer Debian packages, which is the easiest option. This approach has been tested successfully on Ubuntu 17.10 and propbably works on 16.04 as well. However, the occurence of problems during usage can’t be excluded.
$ mkdir gnupg_tmp
$ cd gnupg_tmp
$ wget http://ftp.debian.org/debian/pool/main/g/gnupg2/gnupg_2.1.18-8~deb9u1_amd64.deb
$ wget http://ftp.debian.org/debian/pool/main/g/gnupg2/dirmngr_2.1.18-8~deb9u1_amd64.deb
$ wget http://ftp.debian.org/debian/pool/main/g/gnupg2/gnupg-agent_2.1.18-8~deb9u1_amd64.deb
$ wget http://ftp.debian.org/debian/pool/main/g/gnupg2/scdaemon_2.1.18-8~deb9u1_amd64.deb
$ sudo dpkg -i *
$ cd ..
$ rm -rf gnupg_tmp
Jos haluat peruuttaa asennuksen, sinun on suoritettava seuraavat komennot:
$ sudo dpkg --remove --force-depends gnupg dirmngr gnupg-agent scdaemon
# (removes manually installed packages)
$ sudo apt-get install gnupg dirmngr gnupg-agent scdaemon
# (installs the appropriate packages from regular package repositories)