GPG
The CORE integration with the GPG2 includes two steps: enabling the CORE plugin in the GPG2 Agent infrastructure and importing proxies of the CORE keys into GPGGNU Privacy Guard - PGP cryptography implementation keyrings.
This section describes the steps required to prepare a GPGGNU Privacy Guard - PGP cryptography implementation machine to use the
gpg2
commands while the key material is stored in the CORE and crypto-operations are performed by the CORE. The preparation includes:
- Onboarding the GPG
GNU Privacy Guard - PGP cryptography implementation machine as the CORE client.
- GPG
GNU Privacy Guard - PGP cryptography implementation Agent preparation.
- Testing.
Note
1. To manage the proxy keys and to troubleshoot the infrastructure, see the corresponding topics in ucl pgp-key.
2. If you need to export a public key in GPGGNU Privacy Guard - PGP cryptography implementation format from CORE, see Export PGP Public Key.
Specification
Prerequisites:
- GPG
GNU Privacy Guard - PGP cryptography implementation: 2.1 .
- CORE (UKC): 2.0.2001 or later.
- CORE (UKC) key material type: RSA.
- CORE (UKC) partition: the key material is located in the client's SLOT-0
The first UKC partition in output of the ucl partition list command. partition.
- CORE (UKC) user performing this command:
- Has the OS permission to write to the $HOME directory.
- Has the CORE (UKC) permission to sign crypto material.
Supported crypto:
- The key material type: RSA.
- Crypto operations: Signing, Decryption.
Preparation
CORE Client Preparation
Install, configure and activate CORE client on the system that uses GPGGNU Privacy Guard - PGP cryptography implementation.
CORE Client Installation
On the machine that shall use GPGGNU Privacy Guard - PGP cryptography implementation integrated with CORE:
- Install the CORE client. See Install Client Software.
- Check connectivity to the CORE service and its readiness to handle CORE requests:
curl --insecure -X GET 'https://<EP>[:<port>]/api/v1/info'
Use the <EP
> and, optionally, the <port
> values as they are set in the /etc/ekm/client.conf
file.
CORE Server Preparation
Using CORE management CLICommand Line Interface or UI:
- As needed, create or update the CORE partition that stores keys and certificates used by the GPG
GNU Privacy Guard - PGP cryptography implementation server. See Create Partition.
- Pre-activate the client. See Step 1 - Create Client Name and AC.
For example:
ucl partition create -n test
For example:
ucl client create -n gpgserver -p test -m ACTIVATION
CORE Client Onboarding
On the machine that shall use GPGGNU Privacy Guard - PGP cryptography implementation integrated with CORE:
- Register the machine with the partition. See Step 2 - Register a Machine using AC.
- Generate or import the RSA key used for GPG
GNU Privacy Guard - PGP cryptography implementation.
- Check that the generated or imported key is present in the partition:
For example:
ucl register -n gpgserver -p test -c **********
For example:
ucl generate -t RSA -n my-key
ucl list
GPG Infrastructure Preparation
GPGGNU Privacy Guard - PGP cryptography implementation-specific preparations include:
- Creating, as needed, GPG2 keyring infrastructure.
- Creating or updating, as needed, the GPG
GNU Privacy Guard - PGP cryptography implementation-Agent infrastructure.
- Creating a CORE Agent.
GPG Keyrings
GnuPG (GPG2) keyring infrastructure is located in the $HOME/.gnupg
folder. As the minimum it includes the public and private ("secret") keyrings and the trust-db:
private-keys-v1.d
pubring.kbx
pubring.kbx~
trustdb.gpg
If missing, this infrastructure is created by the first GPG2 command that creates or imports the key material.
In particular, if it is missing, it is created by the first ucl pgp-key command.
GPG Agent Infrastructure
GPGGNU Privacy Guard - PGP cryptography implementation Agent allows delegating crypto operations and key management to external devices ("SC" - "security cards"). It is comprised of two parts:
$HOME/.gnupg/gpg-agent.conf
file that contains non-default GPGGNU Privacy Guard - PGP cryptography implementation Agent settings and the name of the SC-specific plugin procedure.
- Indication in the selected key's metadata that the key material is located in the specified SC.
The GPGGNU Privacy Guard - PGP cryptography implementation Agent infrastructure is created by the first command that imports an SC-based key into GPG
GNU Privacy Guard - PGP cryptography implementation keyring.
In particular, if the $HOME/.gnupg/gpg-agent.conf
file is missing, it is created by the first ucl pgp-key command.
CORE Agent Plugin
The first ucl pgp-key command adds the CORE Agent plugin into GPGGNU Privacy Guard - PGP cryptography implementation Agent infrastructure:
- Setting the SC program in the
gpg-agent.conf
file: - Adding two new files to the
$HOME/.gnupg
folder:.unbound-key-uid
- contains the UID of the key used by the CORE Agent..unbound-daemon-pipe
- for internal use.
cat .gnupg/gpg-agent.conf
scdaemon-program /usr/bin/ubpgpdaemon
Test the GPG Infrastructure
On the GPGGNU Privacy Guard - PGP cryptography implementation server:
- List the RSA keys in the connected partition:
- Create a proxy of "my-key".
- List the GPG2 secret keyring.
Make sure the "my-key
" appears in the list and its metadata specifies "Card serial no = **********
":
For example: - The "
>
" character insec>
indicates that the secret key is outside the file system. Card serial no. =
indicates that the key is stored on the "Secure Card"."my-key"
in the last line is the name of the key.
ucl list -t RSA
Partition 0 pgp: 2 objects found
Private RSA key : UID=974553e132e913dc Name="rsa-key"
Private RSA key : UID=c35238fc1a23e6c7 Name="my-key"
ucl pgp-key -n my-key > /dev/null
gpg2 --list-secret-keys
/home/ec2-user/.gnupg/pubring.kbx
---------------------------------
sec> rsa2048 2020-01-25 [SCEA]
89161090660E4AC61126A0C749C15D46C1E2616D
Card serial no. = 3131 3034F20C
uid [ unknown] my-key
It is important to see the following:
For the additional details, see Examine Secret Keyring.
Manage UB-PGP Proxy Keys
The UB-PGPPretty Good Privacy - PKI implementation proxy keys integrate with the rest of the GPG
GNU Privacy Guard - PGP cryptography implementation keys and are managed by GPGP2 tools. This section highlights items specific to the UB-PGP
Pretty Good Privacy - PKI implementation proxies.
Create and Import UB-PGP Proxy
Use the command:
ucl pgp-key < -n <key-name> | -u <CORE uid>>
Examine Secret Keyring
Assuming that we already imported two keys ("pgp1" and "rsa1") into the GPGGNU Privacy Guard - PGP cryptography implementation infrastructure, the secret keyring should show (at least) two entries.
gpg2 --list-secret-keys
gpg: WARNING: unsafe permissions on homedir '/home/ec2-user/.gnupg'
/home/ec2-user/.gnupg/pubring.kbx
---------------------------------
sec> rsa2048 2020-01-25 [SCEA]
89161090660E4AC61126A0C749C15D46C1E2616D
Card serial no. = 3131 3034F20C
uid [ unknown] pgp1
sec> rsa4096 2020-01-26 [SCEA]
A112BD1ECFFE999DC65F3CD480645EAFFC0843C5
Card serial no. = 3131 3034F20C
uid [ unknown] rsa1
GPG2 uses the following fields to describe the key:
- The "
>
" character insec>
indicates that the secret key is not stored in the file system. - '[SCEA]" indicates the permitted crypto operations using the key:
S - Sign
C - Certify (can certify other GPG keys)
E - Encrypt
A - Authenticate - "Card serial no" appears when the key's secret data is stored on the "security card". In our case, this is the CORE system.
uid [ unknown] <key-name>:
- This GPGGNU Privacy Guard - PGP cryptography implementation User Id (uid) meta-data. It specifies the trust-level and the name of the GPG
GNU Privacy Guard - PGP cryptography implementation Key owner.
- [unknown] refers to the GPG
GNU Privacy Guard - PGP cryptography implementation Trust level assigned by you to the key. To change it, see GPG - Trust in a Key's Owner.
- key-name In the standard GPG
GNU Privacy Guard - PGP cryptography implementation use case, the name of the key is identical to the user's email address. In the case of CORE, it is the name of the key in CORE (pgp1).
Note
GPGGNU Privacy Guard - PGP cryptography implementation allows adding multiple UIDs to a key. Use
gpg2 --edit-key <key name>
.- [unknown] refers to the GPG
Delete Proxy Key
To delete the proxy key, you must delete it from both key-rings:
gpp2 --delete-secret-key <key-name>
gpg2 --delete-key <key-name>
Mandatory Explicit and Implicit Parameters
To use CORE proxy key in GPG2 commands:
- Use the ucl pgp-key command to specify the key to be used by the command.
- Use the same key in the GPG2 command.
- Provide the command with the mandatory CORE Agent parameters.
Set the UB-PGP Proxy Key
Note
In the UKC 2.0.2001 release, the UKC plugin ubpgpdaemon uses the last key referred by the ucl key-pgp <UKC key>
command.
This restriction creates no problems if your GPGGNU Privacy Guard - PGP cryptography implementation keyring has only one CORE proxy key. However, if you are using many proxy keys, always precede its use by the command:
ucl key-pgp <required CORE key>
Note
GPGGNU Privacy Guard - PGP cryptography implementation ring infrastructure ignores multiple insertions of the same proxy key, and responds as follows:
gpg: key 49C15D46C1E2616D: "<name of the CORE key>" not changed
But, if you examine <GPG
, the content changed to the CORE UID of the GNU Privacy Guard - PGP cryptography implementation Folder>/.unbound-key-uid
<name of the CORE key>
.
The common indication that the key referred by the gpg2 --sign
command and the UID forwarded to the CORE mismatch, is the signature validation
error. This happens because the public key that is used for the validation and the signing key mismatch.
GPG2 Parameters
To use key RSA key <key-name> stored in CORE in the GPGGNU Privacy Guard - PGP cryptography implementation applications:
Use the following GPG2 Parameters:
- Use
--pinentry-mode loopback --batch
- Specify the
key-name in CORE
using the-u <key-name in CORE>
option. - If the CORE default
USER
has a password, specify it using the--passphrase <USER's password>
option. - To use the command by any user of the partition, specify their credentials
--passphrase '{"username":"<name>", "password":"<user password>"}'
Examples
Encryption
- Run the following command to encrypt a file:
gpg2 --pinentry-mode loopback --batch --output [encrypted_file.gpg] --encrypt --recipient [Real.name] [file_to_encrypt] -u <key-name>
- Run the following command to decrypt the file:
gpg2 --pinentry-mode loopback --batch --output [decrypted_file.txt] --decrypt [encrypted_file.gpg] -u <key-name>
Signing
To sign an RPMFile format for software package distributed by RPM Package Manager file using GPG
GNU Privacy Guard - PGP cryptography implementation without encrypting it, use the
--detach-sign
option:
gpg2 --pinentry-mode loopback --batch --detach-sign --output <rpm file>.sig <rpm file> -u <key name>
This option creates the signature file for the specified rpm file.
To check the signature use, use the --verify
option with both signature and rpm files:
gpg2 --verify <rpm file>.sig <rpm file>
Note
The .sig
file must precede the .rpm
file