27.1.1. Primary Secret-Key packet¶
The output starts with the (primary) Secret-Key packet.
This is the structure of the Secret-Key packet we will now look at.
The output of Sequoia’s sq packet dump
for this packet:
Secret-Key Packet, new CTB, 2 header bytes + 75 bytes
Version: 6
Creation time: 2023-09-29 15:17:58 UTC
Pk algo: Ed25519
Pk size: 256 bits
Fingerprint: AAA18CBB254685C58358320563FD37B67F3300F9FB0EC457378CD29F102698B3
KeyID: AAA18CBB254685C5
Secret Key:
Unencrypted
00000000 c5 CTB
00000001 4b length
00000002 06 version
00000003 65 16 ea a6 creation_time
00000007 1b pk_algo
00000008 00 00 00 20 public_len
0000000c 53 24 e9 43 ed25519_public
00000010 af ab 15 f7 6e d5 b5 12 98 79 69 cd 1b 5d 10 65
00000020 eb e7 42 e2 ab 47 f4 86 b3 ae 65 3e
0000002c 00 s2k_usage
0000002d ef e1 99 ed25519_secret
00000030 b5 5f 11 fb aa 93 e8 26 9d 3b b2 2d 72 20 7d ff
00000040 bd 42 dd 4b e9 a3 36 81 3b a5 cc cf fb
The Secret-Key packet consists in large part of the actual cryptographic key data. Notice that its content is almost entirely the same as the Public-Key packet seen in the previous chapter. Let’s look at the packet field by field:
CTB: 0xc5
[1]: The packet type ID for this packet. The binary representation of the value0xc5
is11000101
. Bits 7 and 6 show that the packet is in OpenPGP packet format (as opposed to in Legacy packet format). The remaining 6 bits encode the type ID’s value: “5”. This is the value for a Secret-Key packet, as shown in the list of packet type IDs.length: 0x4b
: The remaining length of this packet.
The packet type id defines the semantics of the remaining data in the packet. We’re looking at a Secret-Key packet, which is a kind of Key Material Packet.
version: 0x06
: The key material is in version 6 format
This means that the next part of the packet follows the structure of Version 6 Public Keys
creation_time: 0x6516eaa6
: “The time that the key was created” (also see Time Fields)pk_algo: 0x1b
: “The public-key algorithm ID of this key” (decimal value 27, see the list of Public-Key Algorithms)public_len: 0x00000020
: “Octet count for the following public key material” (in this case, the length of the followinged25519_public
field)ed25519_public
: Algorithm-specific representation of the public key material (the format is based on the value ofpk_algo
), in this case 32 bytes of Ed25519 public key
This concludes the Public Key section of the packet. The remaining data follows the Secret-Key packet format:
s2k_usage: 0x00
: The S2K usage value of0x00
specifies that the secret-key data is not encrypteded25519_secret
: Algorithm-specific representation of the secret key data (the format is based on the value ofpk_algo
). Because the private key material in this packet is not encrypted, this field
Tip
The overall structure of OpenPGP packets is described in the Packet Syntax chapter of the RFC.
Note that the Secret-Key packet contains both the private and the public part of the key.