对重点用GPG从--list-包的输出,以获得MPI值来生成S-EX pressions [英] Using output from gpg --list-packets on a key to get the mpi values to generate s-expressions

查看:210
本文介绍了对重点用GPG从--list-包的输出,以获得MPI值来生成S-EX pressions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用GPG生成的公钥使用libgcrypt做加密。我用列表分组命令的关键,让我的关键内容和分析的MPI值成S-EX pression。所以,当我尝试连接code我和我的公钥会话密钥我得到的错误,在S-EX pression奇数十六进制数?我认为,名单报文也许给我十六进制数字没有前导零?如果这样做了什么,我需要做的就是我,我可以在libgcrypt使用MPI值?

I am trying to use gpg generated public keys to do encryption using libgcrypt. I used the list packets command on the key to get me the contents of the key and parsed the mpi values into an s-expression. So when I try to encode my session key with my public key I get the error "Odd hexadecimal numbers in S-expression"? I think list packets is maybe giving me hex numbers without the leading zero? If so what do I need to do to get me mpi values that I can use in libgcrypt?

推荐答案

从GPG和libgcrypt邮件列表的试错和建议后,列表分组命令不会从MPI值截断前导零,因此你会有pre-挂起的MPI值为零(S)时:

After trial and error and advice from the gpg and libgcrypt mailing lists, the list packets command does truncate the leading zeros from the mpi value and as a result you would have to pre-pend the mpi values with zero(s) when:


  • 十六进制字符串的长度是奇数(pre-挂起一个零)或

  • 的MPI是负值($ P $对挂起与两个零)。

作为进一步的说明,这是不明智的使用列表分组来获得MPI值,因为它不能可靠地获得,因为它被认为是一个调试命令,它可随时更改您的MPI值。我发现得到MPI值的公共和私有密钥的最好方法是通过使用与RFC4880出口重点命令取消code直接解析关键的二进制输出。

As a further note, it is not wise to use list packets to get mpi values as it does not reliably gets you mpi values as it is supposed to be a debugging command which is subject to change. The best way that I have found to get the mpi values for both the public and private keys is to directly parse the binary export of the key by using export key command with RFC4880 to decode it.

这篇关于对重点用GPG从--list-包的输出,以获得MPI值来生成S-EX pressions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆