2

According to the documentation the gpgme_op_encrypt method of GPGME is able to perform symmetric encryption tasks:

gpgme_op_encrypt (gpgme_ctx_t ctx, gpgme_key_t recp[], gpgme_encrypt_flags_t flags, gpgme_data_t plain, gpgme_data_t cipher)

If recp is NULL, symmetric rather than public key encryption is performed. Symmetrically encrypted cipher text can be deciphered with gpgme_op_decrypt. Note that in this case the crypto backend needs to retrieve a passphrase from the user. Symmetric encryption is currently only supported for the OpenPGP crypto backend.

But where does the key used for the symmetric encryption come from? Is it somehow possible to fetch this key and transfer it to another device (where I would like to decrypt the text) ?

4

1 回答 1

1

对称加密的会话密钥来自密码短语,将通过其中一种 pinentry 方法从用户那里查询。特别突出显示您已经引用的部分文本:

如果 recp 为 NULL,则执行对称而不是公钥加密。对称加密的密文可以用 gpgme_op_decrypt 解密。请注意,在这种情况下,加密后端需要从用户那里检索密码。目前仅 OpenPGP 加密后端支持对称加密。

我不知道您可以通过 GPGME 提取会话密钥,但您实际上并不需要:在另一端您只需要知道使用的密码,并且可以再次派生会话密钥。您当然也可以重新实现用于 OpenPGP 的字符串到键的功能

于 2016-01-25T10:29:56.110 回答