PGP private key format

$ \begingroup $ The pgpdump command list all of the information. The under
pgpdump private_key_file.txt -l -u
is used to dump contents. As one can see it is well regulated.

Old: Secret Key Packet(tag 5)(443 bytes)
        Ver 4 - new
        Public key creation time - Tue Jan 17 15:40:43 UTC 2017
        Pub alg - DSA Digital Signature Algorithm(pub 17)
        DSA p(1024 bits) - ...
        DSA q(160 bits) - ...
        DSA g(1024 bits) - ...
        DSA y(1019 bits) - ...
        DSA x(160 bits) - ...
        Checksum - 08 f2 
Old: User ID Packet(tag 13)(18 bytes)
        User ID - Bobby 
Old: Signature Packet(tag 2)(97 bytes)
        Ver 4 - new
        Sig type - Positive certification of a User ID and Public Key packet(0x13).
        Pub alg - DSA Digital Signature Algorithm(pub 17)
        Hash alg - SHA1(hash 2)
        Hashed Sub: signature creation time(sub 2)(4 bytes)
                Time - Tue Jan 17 15:40:43 UTC 2017
        Hashed Sub: key flags(sub 27)(1 bytes)
                Flag - This key may be used to certify other keys
                Flag - This key may be used to sign data
        Hashed Sub: preferred symmetric algorithms(sub 11)(4 bytes)
                Sym alg - AES with 256-bit key(sym 9)
                Sym alg - AES with 192-bit key(sym 8)
                Sym alg - AES with 128-bit key(sym 7)
                Sym alg - Triple-DES(sym 2)
        Hashed Sub: preferred hash algorithms(sub 21)(5 bytes)
                Hash alg - SHA256(hash 8)
                Hash alg - SHA384(hash 9)
                Hash alg - SHA512(hash 10)
                Hash alg - SHA224(hash 11)
                Hash alg - SHA1(hash 2)
        Hashed Sub: preferred compression algorithms(sub 22)(3 bytes)
                Comp alg - ZLIB (comp 2)
                Comp alg - BZip2(comp 3)
                Comp alg - ZIP (comp 1)
        Hashed Sub: features(sub 30)(1 bytes)
                Flag - Modification detection (packets 18 and 19)
        Hashed Sub: key server preferences(sub 23)(1 bytes)
                Flag - No-modify
        Sub: issuer key ID(sub 16)(8 bytes)
                Key ID - 0xCFB2C05FD70EB4F8
        Hash left 2 bytes - 4f ea 
        DSA r(160 bits) - ...
        DSA s(159 bits) - ...
                -> hash(DSA q bits)
Old: Secret Subkey Packet(tag 7)(305 bytes)
        Ver 4 - new
        Public key creation time - Tue Jan 17 15:40:43 UTC 2017
        Pub alg - ElGamal Encrypt-Only(pub 16)
        ElGamal p(1024 bits) - ...
        ElGamal g(3 bits) - ...
        ElGamal y(1022 bits) - ...
        ElGamal x(246 bits) - ...
        Checksum - 0f be 
Old: Signature Packet(tag 2)(73 bytes)
        Ver 4 - new
        Sig type - Subkey Binding Signature(0x18).
        Pub alg - DSA Digital Signature Algorithm(pub 17)
        Hash alg - SHA1(hash 2)
        Hashed Sub: signature creation time(sub 2)(4 bytes)
                Time - Tue Jan 17 15:40:43 UTC 2017
        Hashed Sub: key flags(sub 27)(1 bytes)
                Flag - This key may be used to encrypt communications
                Flag - This key may be used to encrypt storage
        Sub: issuer key ID(sub 16)(8 bytes)
                Key ID - 0xCFB2C05FD70EB4F8
        Hash left 2 bytes - dc 26 
        DSA r(157 bits) - ...
        DSA s(159 bits) - ...
                -> hash(DSA q bits)

If one uses the -u choice, besides, then it will print the values, excessively.

DSA x(160 bits) - 8d 5d 6a 83 d8 40 ed 59 16 23 76 8b b8 9e 60 60 25 29 65 1a

The charge is encoded with Base64. consequently, you need to decode the base64 which results in bytes. Locate the necessary information by using the information from the dump, or read the rfc4880. The first octet ( byte ) of the mailboat header is called the Packet Tag, see in the dump .
A cleaver act is using the reservoir file of pgpdump or like to locate values, change them, and print them back .
The numbers are stored in big-endian, act according to this data .

Leave a Reply

Your email address will not be published.