问题描述
SubjectPublicKeyInfo我想要显示的是什么键还是有更新的格式?
How would I go about doing this myself? Further, is SubjectPublicKeyInfo what I want to be displaying the keys in or is there a more updated format?
编辑:为清楚起见,这是我正在寻找的一个例子:
For clarity, here's an example of what I'm looking for:
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0
FPqri0cb2JZfXJ/DgYSF6vUpwmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/
3j+skZ6UtW+5u09lHNsj6tQ51s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQAB
-----END PUBLIC KEY-----
我目前有:
Public Key (n,e): (25130290470670502980544427869200613840944965290040433220698179071215137002904823499373962164071905921326803837460733139500455896910114421141830335882737678919237073090149470600927019562678483947908156329730770276498955439764614844798829603416304775442087438623389826719642285111749464396302305124179886483673046650125158307930593778247437940929550491287419436361905923356252487704851166279431792122641372330876814779543893241235355988829436458897455503500810769146739895787437926366072829812130032509796362669335922016603663923790043992999351304972183762844549989472560311169566110061553119311399708581940621713200371,65537)
我不知道我怎么可以隐蔽的这个庞大的数字为标准格式key。
I don't know how I can covert this huge number into a standard-form key.
推荐答案
执行此操作的最佳方法是使用Java API。只需创建一个 RSAPublicKey
并调用 getEncoded()
。否则,您可以使用Bouncy Castle库并使用Bouncy内部ASN.1编码结构构建公钥(可能窃取Bouncy Castle JCE实现中的实现,他们必须实现 getEncoded()
以及。)
The best way to do this is to use the Java API. Simply create an RSAPublicKey
and call getEncoded()
. Otherwise you could use the Bouncy Castle libraries and construct the public key using the Bouncy internal ASN.1 encoding structures (possibly "stealing" the implementation from the Bouncy Castle JCE implementation, they have to implement getEncoded()
as well).
最后,您可以简单地查找PKCS#1 RSA标准并实现ASN.1结构。如果您这样做,那么您将必须至少学习ASN.1和DER编码规则的子集。请注意,如果您想从头开始实现完整的 ASN.1解析器+ BER / DER编码器/解码器,您将需要几个月的实施时间和数年的经验。
Finally, you can simply look up the PKCS#1 RSA standard and implement the ASN.1 structure. If you do this then you will have to learn at least a subset of ASN.1 and DER encoding rules. Note that if you want to implement a complete ASN.1 parser + BER/DER encoder/decoder from scratch, you will need a couple of months implementation time and several years of experience.
注意 getEncoded()
只包含二进制DER编码的ASN.1结构。您需要转换为base 64并添加起始行和起始行以创建您向我们展示的PEM结构。这有时也称为ASCII装甲,因为它在发送结构时屏蔽二进制代码以防止损坏。通过邮件(PEM表示隐私增强邮件)。
Note that getEncoded()
simply contains the binary DER encoded ASN.1 structure. You need to convert to base 64 and add the beginning and starting lines to create the PEM structure you have shown us. This is also sometimes called an "ASCII armor" as it shields the binary code against corruption when you send the structure e.g. by mail (PEM means Privacy Enhanced Mail).
这篇关于从BigIntegers将RSA密钥转换为SubjectPublicKeyInfo表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!