rpm 4.10.0

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- Data Structures
- Data Fields

Data Fields
pgpPktKey_u Union Reference
OpenPGP API.

5.5.3. More...

`#include <rpmpgp.h>`

Collaboration diagram for pgpPktKey_u:
[legend]

## Data Fields
struct pgpPktKeyV3_s | v3
struct pgpPktKeyV4_s | v4

## Detailed Description

5.5.3.

Secret Key Packet Formats

The Secret Key and Secret Subkey packets contain all the data of the Public Key and Public Subkey packets, with additional algorithm- specific secret key data appended, in encrypted form.

The packet contains:

- A Public Key or Public Subkey packet, as described above
- One octet indicating string-to-key usage conventions. 0 indicates that the secret key data is not encrypted. 255 indicates that a string-to-key specifier is being given. Any other value is a symmetric-key encryption algorithm specifier.
- [Optional] If string-to-key usage octet was 255, a one-octet symmetric encryption algorithm.
- [Optional] If string-to-key usage octet was 255, a string-to-key specifier. The length of the string-to-key specifier is implied by its type, as described above.
- [Optional] If secret data is encrypted, eight-octet Initial Vector (IV).
- Encrypted multi-precision integers comprising the secret key data. These algorithm-specific fields are as described below.
- Two-octet checksum of the plaintext of the algorithm-specific portion (sum of all octets, mod 65536).

Algorithm Specific Fields for RSA secret keys:

- multiprecision integer (MPI) of RSA secret exponent d.
- MPI of RSA secret prime value p.
- MPI of RSA secret prime value q (p < q).
- MPI of u, the multiplicative inverse of p, mod q.

Algorithm Specific Fields for DSA secret keys:

- MPI of DSA secret exponent x.

Algorithm Specific Fields for Elgamal secret keys:

- MPI of Elgamal secret exponent x.

Secret MPI values can be encrypted using a passphrase. If a string- to-key specifier is given, that describes the algorithm for converting the passphrase to a key, else a simple MD5 hash of the passphrase is used. Implementations SHOULD use a string-to-key specifier; the simple hash is for backward compatibility. The cipher for encrypting the MPIs is specified in the secret key packet.

Encryption/decryption of the secret data is done in CFB mode using the key created from the passphrase and the Initial Vector from the packet. A different mode is used with V3 keys (which are only RSA) than with other key formats. With V3 keys, the MPI bit count prefix (i.e., the first two octets) is not encrypted. Only the MPI non- prefix data is encrypted. Furthermore, the CFB state is resynchronized at the beginning of each new MPI value, so that the CFB block boundary is aligned with the start of the MPI data.

With V4 keys, a simpler method is used. All secret MPI values are encrypted in CFB mode, including the MPI bitcount prefix.

The 16-bit checksum that follows the algorithm-specific portion is the algebraic sum, mod 65536, of the plaintext of all the algorithm- specific octets (including MPI prefix and data). With V3 keys, the checksum is stored in the clear. With V4 keys, the checksum is encrypted like the algorithm-specific data. This value is used to check that the passphrase was correct.

## Field Documentation

struct pgpPktKeyV3_s pgpPktKey_u::v3

Definition at line 715 of file rpmpgp.h.

struct pgpPktKeyV4_s pgpPktKey_u::v4

Definition at line 716 of file rpmpgp.h.

The documentation for this union was generated from the following file:

- rpmpgp.h