使用 GPGME 的对称加密
Symmetric Encryption with GPGME
根据文档,GPGME 的 gpgme_op_encrypt
方法能够执行对称加密任务:
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.
但是对称加密的密钥是从哪里来的呢?是否有可能以某种方式获取此密钥并将其传输到另一台设备(我想在其中解密文本)?
session key for symmetric encryption is derived from a passphrase,将通过其中一种输入法向用户查询。特别突出显示您已经引用的部分文本:
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.
我不知道你可以通过 GPGME 提取会话密钥,但你真的不需要:在另一端你需要知道的只是使用的密码,并且可以再次导出会话密钥.您当然也可以重新实现 string-to-key-function used for OpenPGP.
根据文档,GPGME 的 gpgme_op_encrypt
方法能够执行对称加密任务:
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.
但是对称加密的密钥是从哪里来的呢?是否有可能以某种方式获取此密钥并将其传输到另一台设备(我想在其中解密文本)?
session key for symmetric encryption is derived from a passphrase,将通过其中一种输入法向用户查询。特别突出显示您已经引用的部分文本:
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.
我不知道你可以通过 GPGME 提取会话密钥,但你真的不需要:在另一端你需要知道的只是使用的密码,并且可以再次导出会话密钥.您当然也可以重新实现 string-to-key-function used for OpenPGP.