简体   繁体   English

我想在 openssl 中为 diffiehellman 更改 P 和 G 的值

[英]I want to change the values of P and G for diffiehellman in openssl

Since parameter generation can be an expensive process this is normally done once in advance and then the same set of parameters are used over many key exchanges.由于参数生成可能是一个昂贵的过程,因此通常提前完成一次,然后在多次密钥交换中使用相同的参数集。 Is there any way to modify p and g before its advance set up?有没有办法在提前设置之前修改 p 和 g?

If you use openssl command, you can try asn1...如果你使用 openssl 命令,你可以试试 asn1...

# cat dh.conf
asn1=SEQUENCE:dh_key

[dh_key]
p=INTEGER:0x97
g=INTEGER:5

# openssl dh -in newkey.der -inform der -text -check
    DH Parameters: (7 bit)
    prime: 97 (0x61)
    generator: 5 (0x5)
p value is not a safe prime
-----BEGIN DH PARAMETERS-----
MAYCAWECAQU=
-----END DH PARAMETERS-----

the above implements the simple dh math, ie以上实现了简单的 dh 数学,即

> Alice Bob wants to change key...
> Let p =97 and g=5
> and XA=36 and XB=58
> so YA=g^XA mod p = 50
>    YB=g^XB mod p = 44
> thus Alice:K=(YB) ^XA mod p=75 
>      Bob:  K=(YA) ^XB mod p=75

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM