如何从GPG密钥环导出数字RSA密钥(d)

时间:2019-12-10 21:39:10

标签: gnupg secret-key

我正在通过以下命令使用GPG2导出我的GPG密钥环:

$ gpg --export-secret-key | gpg --list-packets -vvv --debug 0xffff

(其中包括)打印RSA密钥:

   :secret sub key packet:
        version 4, algo 1, created 1576011813, expires 0
        pkey[0]: ABD2...
        pkey[1]: 010001
        iter+salt S2K, algo: 7, SHA1 protection, hash: 2, salt: D476FD990128BDB1
        protect count: 3014656 (183)
        protect IV:  0c 7c 1a d8 ec e3 f0 d4 ac ba bf 46 2a 15 e4 cd
        skey[2]: [v4 protected]
        keyid: E8F5DC1127CAB70F

输出

$ gpg --export-secret-key | pgpdump -i -l -m -p

是:

Old: Secret Subkey Packet(tag 7)(966 bytes)
        Ver 4 - new
        Public key creation time - Tue Dec 10 22:03:33 CET 2019
        Pub alg - RSA Encrypt or Sign(pub 1)
        RSA n(2048 bits) - ab d2 ...
        Sym alg - AES with 128-bit key(sym 7)
        Iterated and salted string-to-key(s2k 3):
                Hash alg - SHA1(hash 2)
                Salt - c2 a0 1f 8f 94 52 f0 a3 
                Count - 3014656(coded count 183)
        IV - 4c 28 ae 9d d6 77 68 f4 67 ce b3 17 4b cf 20 f6 
        Encrypted RSA d
        Encrypted RSA p
        Encrypted RSA q
        Encrypted RSA u
        Encrypted SHA1 hash

看起来pkey[0] n pkey[1] e (0x010001 == 65537),而skey[2]是< em> d 。如何获得 d 的未加密数字(十六进制)值打印? (我知道密钥密码。)

请注意,我想获取实际的未加密的 d 值,并且我不希望将密钥导入另一台运行GPG的计算机上。

1 个答案:

答案 0 :(得分:0)

https://superuser.com/a/1012873所示,用gpg --edit-key ...删除密码短语(passwd Enter ,旧密码, Enter Enter Enter save Enter ),问题中的两个命令均打印 d ,< em> p , q u

然后,我可以使用gpg --edit-key ...重新添加密码。