This is an old revision of the document!


GPG command line

Encrypt

Encrypt a file for multiple recipient:

gpg -r <recipient1 email> -r <recipient2 email> --encrypt <myfile>

Encrypt multiple files:

gpg -r <recipient1 email> --encrypt-files <myfile1> <myfile2>

Encrypt, and convert output to ASCII (so it can be mailed):

gpg -e -a ...

List

List keys:

gpg --list-keys
		pub  1024D/0A69A19C 2004-05-27 XXX <XXX@YYY.fr>
		sub  1024g/8CF406CB 2004-05-27

List secret keys: gpg –list-secret-keys

List signature:

gpg --list-sigs
		pub  1024D/0A69A19C 2004-05-27 XXX <XXX@YYY.fr>
		sig 3       0A69A19C 2004-05-27   XXX <XXX@YYY.fr>
		sig 2       CA739793 2004-05-27   Axelle Apvrille <XXX@XXX.fr>
		sub  1024g/8CF406CB 2004-05-27
		sig         0A69A19C 2004-05-27   XXX <XXX@YYY.fr>

Export

Export key to file: gpg -ao toto-public.key –export 0637B724

Export private key: gpg -ao toto-private.key –export-secret-keys 0637B724

⇒ keep this file in a secure place ! ⇒ to protect it with a passphrase:

gpg -a –export-secret-keys 0637B724 | gpg -aco my-private.key.gpg

⇒ to protect it with conventional encryption:

gpg -a –export-secret-keys 0637B724 | gpg -c my-private.key.gpg

Export public key to armour file: gpg –armor –export email@email.com > mypk

Rem. attention gpg –export xxx –armor n'armore pas…

Import

Import key: gpg –import {key file}

Import private key: gpg –allow-secret-key-import –import {key}

=> importing an encrypted key: gpg --decrypt toto-private.key.gpg |gpg --import

Sign a key

1- select the key ID you want to select (--list-keys)
2- sign the key (--sign-key) or interactively (--edit-key + sign)
3- optional: send the public part of the key to its owner, it contains your signature.
gpg [--default-key xxxxx] --sign-key 0a69a19c 
	pub  1024D/0A69A19C  créée: 2004-05-27 expire: never      confiance: -/-
	sub  1024g/8CF406CB  créée: 2004-05-27 expire: never
	(1). XXX <XXX@YYY.fr>
	pub  1024D/0A69A19C  créée: 2004-05-27 expire: never      confiance: -/-

Empreinte de la clé principale: F233 758B 65C0 A98E 99AC 2DB0 96E7 6731 0A69 A19C

   		XXX <XXX@YYY.fr>
	Avec quel soin avez-vous vérifié que la clé que vous allez signer
	appartient réellement à la personne sus-nommée ? Si vous ne savez
	quoi répondre, entrez "0".
 		(0) Je ne répondrai pas. (par défaut)
 		(1) Je n'ai pas vérifié du tout.
 		(2) J'ai un peu vérifié.
 		(3) J'ai vérifié très soigneusement.
	Your selection? (enter '?' for more information): 2
	Etes-vous vraiment sûr(e) que vous voulez signer cette clé
	avec la vôtre: "Axelle Apvrille <XXX>" (CA739793)
	J'ai un peu vérifié cette clé.
	Signer réellement ? oui
	Vous avez besoin d'un mot de passe pour déverrouiller la clé secrète pour
	l'utilisateur: "Axelle Apvrille <XXX.XXX@fr>"
	clé de 2048 bits RSA, ID CA739793, créée le 2004-02-02
	Entrez le mot de passe: ****

Add a photo

Interactive way:
gpg --edit-key xxxxx
Command> addphoto
choose a JPEG photo

Modify passphrase

Interactive way:
gpg --edit-key myemail@com
Command> passwd

Conventional encryption

gpg --s2k-mode 3 -c file ==> makes file.gpg
asks a password
the s2k mode salts the passphrase

Design

Private key protection (RFC 2440)

OpenPGP buils a OpenPGP “Secret Key” Packet (“Private Key Packet” does not exist).

This packet contains:

- all information included in the Public Key Packet

- private key encryption method:

0 | PLAINTEXT PRIVATE KEY
or Algo ID | IV | ENCRYPTED PRIVATE KEY
	=> passphrase is MD5 hashed, the resulting key encrypts with AlgoID the private key.(CFB mode)		
or 255 | Algo ID | S2K spec | IV | ENCRYPTED PRIVATE KEY
	=> passphrase is converted into a key using S2K algorithm specified by S2K spec:
		Simple S2K = hash the passphrase	=> S2KSpec = 0x00 HashAlgo
		Salted S2K = hash salt + passphrase	=> S2KSpec = 0x01 HashAlgo 8-byte salt
		Iterated S2K = loop hash(salt + passph) => S2KSpec = 0x03 HashAlgo 8-byte salt 1-byte count
 
Back to top
tools/gpg.1198326707.txt.gz · Last modified: 2007/12/22 13:31 by axelle
 
 
Get OpenSolaris Recent changes RSS feed Valid XHTML 1.0 Driven by DokuWiki chimeric.de = chi`s home
(c) A. Apvrille - 2009