GnuPG with Gnuk Token

Niibe Yutaka

Chofu, 2017-10-21

Created: 2017-10-21 土 11:00

Introduction

About Me - Niibe with 'g'

  • GNU Project
    • 90s: GNU Emacs, Guile, glibc, GCC
    • 00s: GPLv3
    • 10s: www.gnu.org (Japanese), GnuPG
  • GNU/Linux on SuperH around 2000
  • FSIJ since 2002
  • Debian since 2005

About Me - gniibe

  • Student ID: 85C70
  • GPG (RSA):
    • 00B45EBD4CA7BABE
    • 1241 24BD 3B48 62AF 7A0A 42F1 00B4 5EBD 4CA7 BABE
  • GPG (ECC):
    • E267B052364F028D
    • 249C B377 1750 745D 5CDD 323C E267 B052 364F 028D

What's GnuPG?

  • GnuPG stands for "GNU Privacy Guard"
  • A tool for secure commincation and data storage.
    • Encryption
    • Digital signature

What's Gnuk?

  • Free Software Project of FSIJ

  • Free Software implementation of Cryptographic Token
  • Supports OpenPGP card Protocol (v2, v3)
  • Runs on STM32103 MCU (Cortex-M3)
  • Supports RSA-2048 and ECC

How GnuPG is Important

Who Use GnuPG?

  • Activists
  • Journalists
  • Lawyers
  • Free Software Developers and Users

Free Software relies on GnuPG

  • Major use cases: GNU, Linux, Debian
  • By digital signing, assure distribution of
    • Source code
    • Binary
  • Members' authenticating each other
    • Commit (change of code)
    • Upload
    • Vote

Software Security relies on GnuPG

  • Vulnerability Information
    • Exchanged by encrypted
    • Released with digital signature
  • Security Update
    • Distributed with digital signature

My Daily Use

My use case: GnuPG with Gnuk Token

At work
Home
On the Go

Everyday usage (1)

  • Encrypted Disk (partition)
    • For Maildir
      • Unencrypted emails
      • Decrypted attachments
  • Encrypted email messages

Everyday usage (2)

  • Use public key authentication
    • Using OpenSSH
      • access to git repos
      • build servers

Occasionally (1)

  • Encrypted file (by Emacs)
    • Personal notes/comments
    • Saving network ID+pass
  • Encrypted file
    • When making backup
    • Use of USB memory

Occasionally (2)

  • Sign
    • commit
    • binary package
    • source code release
  • Verify signature
    • download
    • software update
    • security information

Occasionally (3)

  • Key Sign
  • Vote with digital signature

Is GnuPG is difficult to use?

NO!

But…

  • Using it correctly might be difficult
  • Starting using GnuPG is surely difficult

Some reasons

  • Because of the tech: public-key crypto
  • Because of its uniqueness: end-to-end
    • It's you who control
    • Social structure

Public Key Cryptography

  • Public key
  • Private key
  • Key management
    • Certify: ID and signatures

End-to-End

GnuPG is designed to be end-to-end

  • With no central control
  • Fully distributed
  • No one but you who control

Consequence

  • It might require a good friend (or two) who kindly introduces you to "the" network
  • Usually, it starts by "key signing" (party) or learning key management
  • … which may be the most difficult part.

Why not start using TODAY?

  • My own introductory steps for GnuPG
  • Optionally with Gnuk Token

Important Suggestions

  • Use good passpharase
    • Easy to remember
    • Easy to type
    • But not weak
  • Never use passphrase manager
    • for generating passphrase for GnuPG
    • Use passphrase manager which uses GnuPG

Steps for GnuPG use

  • (1) Passive Private Use
  • (2) [option] Your Own Security Assessment
  • (3) [option] Adopt Gnuk Token
  • (4) Key Signing
  • (5) Use for email encryption
  • (6) Use socially (sign, encryption, auth)

Passive Private Use: Five steps

  • Verify signature : don't need your own key
  • Create your own key
  • Certify locally by lsign
  • Verify again
  • Encrypt to yourself

Passive Private Use: verify (1)

  • Go https://www.gnupg.org/signature_key.html
  • Save keys into a file: gpg-release-keys.asc
  • Import the keys:

    $ gpg --import gpg-release-keys.asc 
    gpg: key 249B39D24F25E3B6: public key "Werner Koch (dist sig)" imported
    gpg: key 04376F3EE0856959: public key "David Shaw (GnuPG Release Signing Key) " imported
    gpg: key 2071B08A33BD3F06: public key "NIIBE Yutaka (GnuPG Release Key) " imported
    gpg: key 8A861B1C7EFD60D9: public key "Werner Koch (Release Signing Key)" imported
    gpg: key 53B620D01CE0C630: public key "Werner Koch (dist sig) " imported
    gpg: key 68B7AB8957548DCD: public key "Werner Koch (gnupg sig) " imported
    gpg: Total number processed: 6
    gpg:               imported: 6
    

Passive Private Use: verify (2)

  • Verify the release

    $ gpg --verify gnupg-2.2.1.tar.bz2.sig gnupg-2.2.1.tar.bz2
    gpg: Signature made Tue Sep 19 15:23:06 2017 JST
    gpg:                using RSA key D8692123C4065DEA5E0F3AB5249B39D24F25E3B6
    gpg: Good signature from "Werner Koch (dist sig)" [unknown]
    gpg: WARNING: This key is not certified with a trusted signature!
    gpg:          There is no indication that the signature belongs to the owner.
    Primary key fingerprint: D869 2123 C406 5DEA 5E0F  3AB5 249B 39D2 4F25 E3B6
    gpg: Signature made Wed Sep 20 17:00:09 2017 JST
    gpg:                using RSA key 031EC2536E580D8EA286A9F22071B08A33BD3F06
    gpg: Good signature from "NIIBE Yutaka (GnuPG Release Key) " [unknown]
    gpg: WARNING: This key is not certified with a trusted signature!
    gpg:          There is no indication that the signature belongs to the owner.
    Primary key fingerprint: 031E C253 6E58 0D8E A286  A9F2 2071 B08A 33BD 3F06
    

Passive Private Use: genkey

  • Create your own key:

    $  gpg  --yes --quick-gen-key "NIIBE Yutaka "
    [INPUT YOUR PASSPHRASE HERE, TWICE]
    

Passive Private Use: certify

  • Check the key fingerprints on the web (and its path to you)
  • Certify keys by:

    $ gpg --quick-lsign-key D8692123C4065DEA5E0F3AB5249B39D24F25E3B6
    $ gpg --quick-lsign-key 031EC2536E580D8EA286A9F22071B08A33BD3F06
    

Passive Private Use: verify (3)

  • Verify again

    $ gpg --verify gnupg-2.2.1.tar.bz2.sig gnupg-2.2.1.tar.bz2
    gpg: Signature made Tue Sep 19 15:23:06 2017 JST
    gpg:                using RSA key D8692123C4065DEA5E0F3AB5249B39D24F25E3B6
    gpg: Good signature from "Werner Koch (dist sig)" [full]
    gpg: Signature made Wed Sep 20 17:00:09 2017 JST
    gpg:                using RSA key 031EC2536E580D8EA286A9F22071B08A33BD3F06
    gpg: Good signature from "NIIBE Yutaka (GnuPG Release Key) " [full]
    

Passive Private Use: encrypt/decrypt

  • Encrypt and decrypt

    $ date > some-file.txt
    $ gpg -r gniibe@fsij.org -e some-file.txt
    $ gpg -d some-file.txt.gpg 
    gpg: encrypted with 2048-bit RSA key, ID FD4F434ECA32C80C, created 2017-10-20
      "NIIBE Yutaka "
    Sat Oct 21 08:51:01 JST 2017
    

Security Assessment

  • Attack vectors
    • Attack to your computer
    • $HOME/.gnupg/private-keys-v1.d
    • weak passphrase
  • How we can minimize the attack surface?

Gnuk Token

  • Gnuk is software implementation
  • gniibe also makes hardware design: FST-01
  • We call a device Gnuk Token when it runs Gnuk

Key Singing [Party]

  • Conference is agood place
  • Exchange and examine fingerprints
  • Feel free to call me
  • TIPS: Bring your passport
    • Even for domestic local event

Use for email encryption

Use socially

  • Signing for:
    • your vote
    • your commit (git commit -S)
    • your tag (git tag -s)
    • package (debsign)
    • –detach-sign
    • –clear-sign
  • Authentication with OpenSSH access

Gnuk Basics

Cryptographic Token

  • Holds your secret
  • Performs security operations on the device
    • Digital signature
    • Decryption
    • Authentication
  • No direct access to secret materials

Technical Hilights

What's New in Gnuk 1.2?

  • New RNG: NeuG 1.0.4
  • New Algo
    • Ed25519 for signature
    • X25519 for encryption
    • Pretty fast
    • Much safer against side-channel attacks

Let's use Gnuk 1.2 with GnuPG 2.1!

  • Ed25519 and X25519 are the new algo of GnuPG
  • Why not use the good algo?
  • Bonus: keys and signatures are small in size

How fast is it?

  • Experiments in Köln with Ed25519 and X25519
  • 10sec for 100 signatures by gpg --detach-signature

    ./run-sig.sh
    Signing 100 times.
    Thu Sep  8 13:42:40 JST 2016
    ....................
    Thu Sep  8 13:42:50 JST 2016
    
  • 21sec for 100 decryptions by gpg --decrypt

    $ ./run-dec.sh
    Decrypt 100 times.
    Thu Sep  8 13:43:48 JST 2016
    ....................
    Thu Sep  8 13:44:09 JST 2016
    

How to use it?

Card status

  • Shows card information

    $ gpg --card-status
    
    Reader ...........: 234B:0000:FSIJ-1.2.1-87193059:0
    Application ID ...: D276000124010200FFFE871930590000
    Version ..........: 2.0
    Manufacturer .....: unmanaged S/N range
    Serial number ....: 87193059
    Name of cardholder: Yutaka Niibe
    Language prefs ...: ja
    Sex ..............: male
    URL of public key : [not set]
    Login data .......: gniibe
    Signature PIN ....: not forced
    Key attributes ...: ed25519 cv25519 ed25519
    Max. PIN lengths .: 127 127 127
    PIN retry counter : 3 3 3
    Signature counter : 3128
    Signature key ....: 249C B377 1750 745D 5CDD  323C E267 B052 364F 028D
          created ....: 2015-08-12 07:10:48
    Encryption key....: E228 AB42 0F73 3B1D 712D  E50C 850A F040 D619 F240
          created ....: 2015-08-12 07:10:48
    Authentication key: E63F 31E6 F203 20B5 D796  D266 5F91 0521 FAA8 05B1
          created ....: 2015-08-12 07:16:14
    General key info..: pub  ed25519/E267B052364F028D 2015-08-12 NIIBE Yutaka 
    sec>  ed25519/E267B052364F028D  created: 2015-08-12  expires: never     
    				card-no: FFFE 87193059
    ssb>  cv25519/850AF040D619F240  created: 2015-08-12  expires: never     
    				card-no: FFFE 87193059
    ssb>  ed25519/5F910521FAA805B1  created: 2015-08-12  expires: never     
    				card-no: FFFE 87193059
    

Signing

  • Just as same when private keys are on host

    $ gpg --sign gnuk-1_2.org
    $ gpg --clearsign gnuk-1_2.org 
    $ gpg --detach-sign gnuk-1_2.org
    

Decryption

  • Just as same when private keys are on host

    $ gpg --decrypt gnuk-1_2.org.gpg
    

OpenSSH

  • Authentication key can be used for SSH

    $ ssh YOUR-SERVER
    
  • We need to configure gpg-agent as ssh-agent

Availability

  • NeuG 1.0.4 on FST-01
    • ?: shop.fsf.org USD50
  • NeuG 1.0.4 on FST-01G
    • 30: 4000 JPY
  • Gnuk 1.2.6 on FST-01G
    • Can be flash on site

Happy Hacking!

Created by gniibe.