1
$\begingroup$

The throw away private keys below (master ed25519 & subkey curve 25519) were exported without being password encrypted.

% cat skaht_0523F5B4_Secret.asc

-----BEGIN PGP PRIVATE KEY BLOCK-----
lFgEXfAoixYJKwYBBAHaRw8BAQdAQ5l6GBKYVua9IGVmHiZNEZykd2h0AkxO5mcL
NanWJO0AAQC2JM3xGd6htChecBpLTYGM+Z0tRLQs1Oo5FGBgE2D6wg97tCdza2Fo
dCAodG1wLTI1NTE5KSA8c2NvdHRAaW50ZWdyaWtleS5pbz6IlgQTFgoAPhYhBNlO
4ePoKewKHz7ayfkTtuEFI/W0BQJd8CiLAhsDBQkB4TOABQsJCAcDBRUKCQgLBRYC
AwEAAh4BAheAAAoJEPkTtuEFI/W0IwYBAKMJtsSo+GkD0h64ztYHreMY2bu4sEDM
IAjUok6G3PIXAQDuWAERJnmci1XeGHVjabUmHQH7YiMGOemeTgh4RlrhCJxdBF3w
KIsSCisGAQQBl1UBBQEBB0D53zCpkElmLeMApZz5dxS7vEtigBNvjgD3Mzmo0fUQ
GQMBCAcAAP9bZrg2eQPGhFB0e7jq04Y1ErXSFV9OeSkCiadVkWDUQA9siH4EGBYK
ACYWIQTZTuHj6CnsCh8+2sn5E7bhBSP1tAUCXfAoiwIbDAUJAeEzgAAKCRD5E7bh
BSP1tNEVAP4hDr18GRTwtSFCSzeEMQh3z+9Zial4fK5+fNDvsIVRewEAqgarwKEe
Eeiovywl3jsDdfcuQ2j0FVMTLjbCLqsOEAo=
=V0+2
-----END PGP PRIVATE KEY BLOCK-----

https://cirw.in/gpg-decoder/ (https://github.com/ConradIrwin/gpg-decoder) does a good job at identifying of breaking the the PRIVATE KEY BLOCK above into its constituent parts, but lacks functionality to properly parse the 5 packets below into their constituent parts.

PGP PRIVATE KEY BLOCK Contains 5 Packets:

  1. Secret-Key Packet (0x6):
  2. User ID Packet (0xd):
  3. Signature Packet (0x2):
  4. Secret-Subkey Packet (0x7):
  5. Signature Packet (0x2): 

After removing the header & footer decorations from the skaht_0523F5B4_Secret.asc file to create skaht_0523F5B4_Secret, the raw hex data can easily be obtained.

% cat skaht_0523F5B4_Secret | bx base64-decode | bx base16-encode 9458045df0288b16092b06010401da470f0101074043997a18129856e6bd2065661e264d119ca4776874024c4ee6670b35a9d624ed000100b624cdf119dea1b4285e701a4b4d818cf99d2d44b42cd4ea391460601360fac20f7bb427736b6168742028746d702d323535313929203c73636f747440696e74656772696b65792e696f3e88960413160a003e162104d94ee1e3e829ec0a1f3edac9f913b6e10523f5b405025df0288b021b03050901e13380050b0908070305150a09080b051602030100021e01021780000a0910f913b6e10523f5b423060100a309b6c4a8f86903d21eb8ced607ade318d9bbb8b040cc2008d4a24e86dcf2170100ee58011126799c8b55de18756369b5261d01fb62230639e99e4e0878465ae1089c5d045df0288b120a2b060104019755010501010740f9df30a99049662de300a59cf97714bbbc4b6280136f8e00f73339a8d1f51019030108070000ff5b66b8367903c68450747bb8ead3863512b5d2155f4e79290289a7559160d4400f6c887e0418160a0026162104d94ee1e3e829ec0a1f3edac9f913b6e10523f5b405025df0288b021b0c050901e13380000a0910f913b6e10523f5b4d11500fe210ebd7c1914f0b521424b3784310877cfef5989a9787cae7e7cd0efb085517b0100aa06abc0a11e11e8a8bf2c25de3b0375f72e4368f41553132e36c22eab0e100a

Packets #1. Secret-Key Packet (0x6), and #4. Secret-Subkey Packet (0x7) above are of primary interest:

1) Secret-Key Packet (0x5), Tag 5:

https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-08#section-5.5.3 "5.5.3. Secret-Key Packet Formats"

9458045df0288b16092b06010401da470f0101074043997a18129856e6bd2065661e264d119ca4776874024c4ee6670b35a9d624ed000100b624cdf119dea1b4285e701a4b4d818cf99d2d44b42cd4ea391460601360fac20f7b

  • 94
  • 58 = 88 bytes are contained in the remainder of the packet
  • 04 = Version 4
  • 5df0288b = Tuesday, December 10, 2019 6:21:47 PM GMT-05:00
  • 16 = "EdDSA [RFC8032]"
  • 09 = the number of bytes that follow that representing the curve OID
  • 2b06010401da470f01 = "1.3.6.1.4.1.11591.15.1", Ed25519; is the Curve OID bytes ASN.1 ObjectIdentifier
  • 010740
  • 43997a18129856e6bd2065661e264d119ca4776874024c4ee6670b35a9d624ed = Public Master Ed25519 Key
  • 000100b624
  • cdf119dea1b4285e701a4b4d818cf99d2d44b42cd4ea391460601360fac20f7b is likely the Secret Master Ed25519 Key used for digital signatures.

4) Secret-Subkey Packet (0x7), Tag 7:

https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-08#section-5.5.1.4 "5.5.1.4. Secret-Subkey Packet (Tag 7)"

9c5d045df0288b120a2b060104019755010501010740f9df30a99049662de300a59cf97714bbbc4b6280136f8e00f73339a8d1f51019030108070000ff5b66b8367903c68450747bb8ead3863512b5d2155f4e79290289a7559160d4400f6c

  • 9c ?
  • 5d = 93 bytes are contained in the remainder of the packet
  • 04 = Version 4
  • 5df0288b = Tuesday, December 10, 2019 6:21:47 PM GMT-05:00
  • 12 = ECDH public key algorithm
  • 0a = number of bytes that follow representing the curve OID
  • 2b060104019755010501 = "1.3.6.1.4.1.3029.1.5.1", Curve25519
  • 010740 ?
  • f9df30a9 ?
  • 9049662de300a59cf97714bbbc4b6280136f8e00f73339a8d1f5101903010807 = the Public Curve25519 Subkey
  • 0000ff5b66 ?
  • b8367903c68450747bb8ead3863512b5d2155f4e79290289a7559160d4400f6c = likely the Secret Curve25519 Subkey used for Diffie-Helman key exchanges to support encrypted communication channels.

The issue I have with reading https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-08 is that the bolded highlighted fields are too difficult to translate from examining the latest Draft RFC. Can someone try to explain what the values above really map to?

$\endgroup$
1
$\begingroup$

Not trivial by any means, but the bolded script below complements the output of:

% gpg --verbose --list-packets skaht_0523F5B4_Secret.asc

% ./parse.csh skaht_0523F5B4_Secret.asc

9458045df0288b16092b06010401da470f0101074043997a18129856e6bd2065661e264d119ca4776874024c4ee6670b35a9d624ed000100b624cdf119dea1b4285e701a4b4d818cf99d2d44b42cd4ea391460601360fac20f7bb427736b6168742028746d702d323535313929203c73636f747440696e74656772696b65792e696f3e88960413160a003e162104d94ee1e3e829ec0a1f3edac9f913b6e10523f5b405025df0288b021b03050901e13380050b0908070305150a09080b051602030100021e01021780000a0910f913b6e10523f5b423060100a309b6c4a8f86903d21eb8ced607ade318d9bbb8b040cc2008d4a24e86dcf2170100ee58011126799c8b55de18756369b5261d01fb62230639e99e4e0878465ae1089c5d045df0288b120a2b060104019755010501010740f9df30a99049662de300a59cf97714bbbc4b6280136f8e00f73339a8d1f51019030108070000ff5b66b8367903c68450747bb8ead3863512b5d2155f4e79290289a7559160d4400f6c887e0418160a0026162104d94ee1e3e829ec0a1f3edac9f913b6e10523f5b405025df0288b021b0c050901e13380000a0910f913b6e10523f5b4d11500fe210ebd7c1914f0b521424b3784310877cfef5989a9787cae7e7cd0efb085517b0100aa06abc0a11e11e8a8bf2c25de3b0375f72e4368f41553132e36c22eab0e100a


1) ECC Secret-Key Packet (Tag 5): 0x94
   Raw Packet: 9458045df0288b16092b06010401da470f0101074043997a18129856e6bd2065661e264d119ca4776874024c4ee6670b35a9d624ed000100b624cdf119dea1b4285e701a4b4d818cf99d2d44b42cd4ea391460601360fac20f7b
   Packet size in bytes         : 90
   Packet body size in bytes    : 0x58 or 88
   Packet Version               : 0x04
             UNIX Epoch Time    : 0x5df0288b  or  Tue Dec 10 18:21:47 EST 2019
             Pubkey Algo index  : 0x16 -> EdDSA [RFC8032]
             OID Size in bytes  : 0x09 or 9
             Object Identifier  : 0x2b06010401da470f01 -> 1.3.6.1.4.1.11591.15.1, Ed25519
             KDF Size in bytes  : 0x01 or 1
             KDF Details        : 0x07 -> SHA2-256
             Canonical Prefix   : 0x40 -> Native point format, compressed
               Public Key       : 43997a18129856e6bd2065661e264d119ca4776874024c4ee6670b35a9d624ed
               Fingerprint Basis: 990033045df0288b16092b06010401da470f0101074043997a18129856e6bd2065661e264d119ca4776874024c4ee6670b35a9d624ed
               Fingerprint      : d94ee1e3e829ec0a1f3edac9f913b6e10523f5b4
           S2K Hash Header      : 0x00 -> Simple S2K
           S2K Hash Algorithm   : 0x01 -> SHA-1
           S2K Cipher Header    : 0x00 -> No S2K Cipher, No encryption, Cleartext
               Secret Key       : b624cdf119dea1b4285e701a4b4d818cf99d2d44b42cd4ea391460601360fac2
               Checksum         : 0x0f7b

2) User ID Packet       (Tag 13): 0xb4
   Raw Packet: b427736b6168742028746d702d323535313929203c73636f747440696e74656772696b65792e696f3e
   Packet size in bytes         : 41
   Packet body size in bytes    : 0x27 or 39
                 User ID String : skaht (tmp-25519) <scott@integrikey.io>

3) ECC Signature Packet  (Tag 2): 0x88
   Raw Packet: 88960413160a003e162104d94ee1e3e829ec0a1f3edac9f913b6e10523f5b405025df0288b021b03050901e13380050b0908070305150a09080b051602030100021e01021780000a0910f913b6e10523f5b423060100a309b6c4a8f86903d21eb8ced607ade318d9bbb8b040cc2008d4a24e86dcf2170100ee58011126799c8b55de18756369b5261d01fb62230639e99e4e0878465ae108
   Packet size in bytes         : 152
   Packet body size in bytes    : 0x96 or 150
   Packet Version               : 0x04
                 Signature Type : 0x13 -> Positive certification of a User ID and Public-Key packet.
           Public Key Algorithm : 0x16 -> EdDSA [RFC8032]
                 Hash Algorithm : 0x0a -> SHA2-512 [FIPS180] or SHA512
              HASHED DATA COUNT : 0x003e or 62
   Subpacket #1 Length in bytes : 0x16 or 22
                 Subpacket Type : 0x21 -> Issuer Fingerprint - https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-08#section-5.2.3.28
             Fingerprint Prefix : 0x04
           Issuer's Fingerprint : 0xd94ee1e3e829ec0a1f3edac9f913b6e10523f5b4
   Subpacket #2 Length in bytes : 0x05 or 5
                 Subpacket Type : 0x02 -> Issuer Signature Creation Time - https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-08#section-5.2.3.4
                UNIX Epoch Time : 0x5df0288b  or  Tue Dec 10 18:21:47 EST 2019
   Subpacket #3 Length in bytes : 0x02 or 2
                 Subpacket Type : 0x1b -> Key Flags - https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-08#section-5.2.3.22
                    Hashed Data : 0x03
   Subpacket #4 Length in bytes : 0x05 or 5
                 Subpacket Type : 0x09 -> Key Expiration Time - https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-08#section-5.2.3.6
                UNIX Epoch Time : 0x01e13380  or  Thu Dec 31 19:00:00 EST 1970
   Subpacket #5 Length in bytes : 0x05 or 5
                 Subpacket Type : 0x0b -> Preferred Symmetric Algorithms - https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-08#section-9.3
                    Hashed Data : 0x09080703
   Subpacket #6 Length in bytes : 0x05 or 5
                 Subpacket Type : 0x15 -> Preferred Hash Algorithms - https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-08#section-9.5
                    Hashed Data : 0x0a09080b
   Subpacket #7 Length in bytes : 0x05 or 5
                 Subpacket Type : 0x16 -> Preferred Compression Algorithms - https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-08#section-9.4
                    Hashed Data : 0x02030100
   Subpacket #8 Length in bytes : 0x02 or 2
                 Subpacket Type : 0x1e -> Features - https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-08#section-5.2.3.25
                    Hashed Data : 0x01
   Subpacket #9 Length in bytes : 0x02 or 2
                 Subpacket Type : 0x17 -> Key Server Preference - https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-08#section-5.2.3.18
                    Hashed Data : 0x80
            UNHASHED DATA COUNT : 0x000a or 10
   Subpacket #10 Length in bytes : 0x09 or 9
                 Subpacket Type : 0x10 -> Issuer - https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-08#section-5.2.3.5
                  Unhashed Data : 0xf913b6e10523f5b4
          signedHashValuePrefix : 0x2306
                   Delimiter #1 : 0x0100
         R Portion of Signature : a309b6c4a8f86903d21eb8ced607ade318d9bbb8b040cc2008d4a24e86dcf217
                   Delimiter #2 : 0x0100
         S Portion of Signature : ee58011126799c8b55de18756369b5261d01fb62230639e99e4e0878465ae108

4) ECC Secret-Subkey Packet (Tag 7): 0x9c
   Raw Packet: 9c5d045df0288b120a2b060104019755010501010740f9df30a99049662de300a59cf97714bbbc4b6280136f8e00f73339a8d1f51019030108070000ff5b66b8367903c68450747bb8ead3863512b5d2155f4e79290289a7559160d4400f6c
   Packet size in bytes         : 95
   Packet body size in bytes    : 0x5d or 93
   Packet Version               : 0x04
             UNIX Epoch Time    : 0x5df0288b  or  Tue Dec 10 18:21:47 EST 2019
             Pubkey Algo index  : 0x12 -> ECDH public key algorithm
             OID Size in bytes  : 0x0a or 10
             Object Identifier  : 0x2b060104019755010501 -> 1.3.6.1.4.1.3029.1.5.1, Curve25519
             KDF Size in bytes  : 0x01 or 1
             KDF Details        : 0x07 -> SHA2-256
             Canonical Prefix   : 0x40 -> Native point format, compressed
               Public Key       : f9df30a99049662de300a59cf97714bbbc4b6280136f8e00f73339a8d1f51019
       Public Key Mystery Field : 0x03010807
               Fingerprint Basis: 990038045df0288b120a2b060104019755010501010740f9df30a99049662de300a59cf97714bbbc4b6280136f8e00f73339a8d1f5101903010807
               Fingerprint      : 8517dbf00c6543587342e5b98f345dd05147c2fd
           S2K Hash Header      : 0x00 -> Simple S2K
           S2K Hash Algorithm   : 0x00 -> MD5 [HAC]
           S2K Cipher Header    : 0xff -> No S2K Cipher, No encryption, Cleartext
               Secret Key       : 5b66b8367903c68450747bb8ead3863512b5d2155f4e79290289a7559160d440
               Checksum         : 0x0f6c

5) ECC Signature Packet  (Tag 2): 0x88
   Raw Packet: 887e0418160a0026162104d94ee1e3e829ec0a1f3edac9f913b6e10523f5b405025df0288b021b0c050901e13380000a0910f913b6e10523f5b4d11500fe210ebd7c1914f0b521424b3784310877cfef5989a9787cae7e7cd0efb085517b0100aa06abc0a11e11e8a8bf2c25de3b0375f72e4368f41553132e36c22eab0e100a
   Packet size in bytes         : 128
   Packet body size in bytes    : 0x7e or 126
   Packet Version               : 0x04
                 Signature Type : 0x18 -> Subkey Binding Signature.
           Public Key Algorithm : 0x16 -> EdDSA [RFC8032]
                 Hash Algorithm : 0x0a -> SHA2-512 [FIPS180] or SHA512
              HASHED DATA COUNT : 0x0026 or 38
   Subpacket #1 Length in bytes : 0x16 or 22
                 Subpacket Type : 0x21 -> Issuer Fingerprint - https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-08#section-5.2.3.28
             Fingerprint Prefix : 0x04
           Issuer's Fingerprint : 0xd94ee1e3e829ec0a1f3edac9f913b6e10523f5b4
   Subpacket #2 Length in bytes : 0x05 or 5
                 Subpacket Type : 0x02 -> Issuer Signature Creation Time - https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-08#section-5.2.3.4
                UNIX Epoch Time : 0x5df0288b  or  Tue Dec 10 18:21:47 EST 2019
   Subpacket #3 Length in bytes : 0x02 or 2
                 Subpacket Type : 0x1b -> Key Flags - https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-08#section-5.2.3.22
                    Hashed Data : 0x0c
   Subpacket #4 Length in bytes : 0x05 or 5
                 Subpacket Type : 0x09 -> Key Expiration Time - https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-08#section-5.2.3.6
                UNIX Epoch Time : 0x01e13380  or  Thu Dec 31 19:00:00 EST 1970
            UNHASHED DATA COUNT : 0x000a or 10
   Subpacket #5 Length in bytes : 0x09 or 9
                 Subpacket Type : 0x10 -> Issuer - https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-08#section-5.2.3.5
                  Unhashed Data : 0xf913b6e10523f5b4
          signedHashValuePrefix : 0xd115
                   Delimiter #1 : 0x00fe
         R Portion of Signature : 210ebd7c1914f0b521424b3784310877cfef5989a9787cae7e7cd0efb085517b
                   Delimiter #2 : 0x0100
         S Portion of Signature : aa06abc0a11e11e8a8bf2c25de3b0375f72e4368f41553132e36c22eab0e100a
```
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.