简体   繁体   中英

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?

If you use openssl command, you can try 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

> 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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