从初始私钥/材料密钥生成 pgp 密钥

从初始私钥/材料密钥生成 pgp 密钥

一些库允许我以这样的方式生成 pgp 密钥对:

var options = {
    curve: 'secp256k1',
    userId: 'Hamlet <[email protected]>',
    passphrase: 'To be, or not to be: that is the question',
    material: {
      key: privateKey,
      subkey: privateKey
    }
};

openpgp.generateKeyPair(options).then(function(keypair) {
    // success
    var privkey = keypair.privateKeyArmored;
    var pubkey = keypair.publicKeyArmored;
    //.........

也就是说,除了 user_id/passphrase 之外,还给定一些初始私钥/材料,它会生成或可能转换为 pgp 密钥。

我想知道,有没有办法用 Linux 附带的标准 gpg 实用程序做同样的事情?我知道它接受 userId 和密码短语作为参数,但它是否接受与该库中的“材料”私钥相对应的参数作为参数?

或者是否有一种方法可以包含更多步骤来达到生成 openpg 密钥对的相同结果?

答案1

是的。

GNUPG 可以使用现有的密钥。如果您使用交互式界面,您需要激活“专家”选项才能显示菜单项。如果您使用 GNUPG 2.2.1,您将看到类似以下内容:

$gpg --expert --full-gen-key

gpg (GnuPG) 2.2.1; Copyright (C) 2017 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
   (7) DSA (set your own capabilities)
   (8) RSA (set your own capabilities)
   (9) ECC and ECC
  (10) ECC (sign only)
  (11) ECC (set your own capabilities)
  (13) Existing key
Your selection? 

选择选项 13 以使用现有的 PGP 密钥材料。您需要知道启动键的键柄。对于与 GPG 一起使用的现有 PGP 密钥:

$gpg --with-keygrip --list-secret-keys [keyid]

据我了解,这是一项新功能,因此所有错误可能尚未解决……这可能就是它隐藏在“专家”菜单中的原因。我的一些简单测试表明,它似乎适用于 RSA 密钥,但不适用于 Curve 25519 密钥。

相关内容