问题描述
我已经计算出RSA密钥的n,e,d,p,q值.现在,如何使用openssl命令行工具生成私钥文件(pem或der)?我在考虑
openssl asn1parse -genconf asn1.cnf -noout -out asn1.der
但是我不明白如何构建conf文件.
OpenSSL asn_generate_nconf的联机帮助页附带一个示例cnf,用于生成应与您的cmdline一起使用的private_key ASN.1序列:
asn1=SEQUENCE:private_key
[private_key]
version=INTEGER:0
n=INTEGER:0xBB6FE79432CC6EA2D8F970675A5A87BFBE1AFF0BE63E879F2AFFB93644\
D4D2C6D000430DEC66ABF47829E74B8C5108623A1C0EE8BE217B3AD8D36D5EB4FCA1D9
e=INTEGER:0x010001
d=INTEGER:0x6F05EAD2F27FFAEC84BEC360C4B928FD5F3A9865D0FCAAD291E2A52F4A\
F810DC6373278C006A0ABBA27DC8C63BF97F7E666E27C5284D7D3B1FFFE16B7A87B51D
p=INTEGER:0xF3929B9435608F8A22C208D86795271D54EBDFB09DDEF539AB083DA912\
D4BD57
q=INTEGER:0xC50016F89DFF2561347ED1186A46E150E28BF2D0F539A1594BBD7FE467\
46EC4F
exp1=INTEGER:0x9E7D4326C924AFC1DEA40B45650134966D6F9DFA3A7F9D698CD4ABEA\
9C0A39B9
exp2=INTEGER:0xBA84003BB95355AFB7C50DF140C60513D0BA51D637272E355E397779\
E7B2458F
coeff=INTEGER:0x30B9E4F2AFA5AC679F920FC83F1F2DF1BAF1779CF989447FABC2F5\
628657053A
作为替代方法 rsatool.py 可以生成base64编码的ASN.1 privkey.pem
或纯asn .1 der序列,带有简单cmdline
#>python rsatool.py -n <n> -p <p> -q <q> -e <e> -v PEM -o privkey.pem
或用于ASN.1 der中的输出:
#>python rsatool.py -n <n> -p <p> -q <q> -e <e> -v DER -o privkey.key
I have calculated n, e, d, p, q values of an RSA key.Now, how can I generate a private key file (pem or der) with openssl command line tools?
I was thinking about
openssl asn1parse -genconf asn1.cnf -noout -out asn1.der
but I cannot understand how to build the conf file.
The OpenSSL manpage for asn_generate_nconf comes with an example cnf for generating the private_key ASN.1 sequence that should work with your cmdline:
asn1=SEQUENCE:private_key
[private_key]
version=INTEGER:0
n=INTEGER:0xBB6FE79432CC6EA2D8F970675A5A87BFBE1AFF0BE63E879F2AFFB93644\
D4D2C6D000430DEC66ABF47829E74B8C5108623A1C0EE8BE217B3AD8D36D5EB4FCA1D9
e=INTEGER:0x010001
d=INTEGER:0x6F05EAD2F27FFAEC84BEC360C4B928FD5F3A9865D0FCAAD291E2A52F4A\
F810DC6373278C006A0ABBA27DC8C63BF97F7E666E27C5284D7D3B1FFFE16B7A87B51D
p=INTEGER:0xF3929B9435608F8A22C208D86795271D54EBDFB09DDEF539AB083DA912\
D4BD57
q=INTEGER:0xC50016F89DFF2561347ED1186A46E150E28BF2D0F539A1594BBD7FE467\
46EC4F
exp1=INTEGER:0x9E7D4326C924AFC1DEA40B45650134966D6F9DFA3A7F9D698CD4ABEA\
9C0A39B9
exp2=INTEGER:0xBA84003BB95355AFB7C50DF140C60513D0BA51D637272E355E397779\
E7B2458F
coeff=INTEGER:0x30B9E4F2AFA5AC679F920FC83F1F2DF1BAF1779CF989447FABC2F5\
628657053A
As an alternative rsatool.py can generate the base64 encoded ASN.1 privkey.pem
or plain asn.1 der sequence with a simple cmdline
#>python rsatool.py -n <n> -p <p> -q <q> -e <e> -v PEM -o privkey.pem
or for output in ASN.1 der:
#>python rsatool.py -n <n> -p <p> -q <q> -e <e> -v DER -o privkey.key
这篇关于使用OpenSSL从bash中的n,e,d,p,q值生成RSA私钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!