简体   繁体   English

Diffie Hellman Key Agreement 在 Java 中使用可选的 subprime q 和 DHParameterSpec

[英]Diffie Hellman Key Agreement using optional subprime q with DHParameterSpec in Java

I am trying to perform a Diffie Hellman Hey agreement, and as part of the parameter definition, I have 3 values:我正在尝试执行 Diffie Hellman Hey 协议,作为参数定义的一部分,我有 3 个值:

a prime modulus pa base generator ga subprime q a 质数模数 pa 基础生成器 ga 次质数 q

looking at the various constructors for creating the keys necessary to perform this agreement, I don't seem to be able to set the q value:查看用于创建执行此协议所需的密钥的各种构造函数,我似乎无法设置 q 值:

https://docs.oracle.com/en/java/javase/11/docs/api/java.base/javax/crypto/spec/DHParameterSpec.html https://docs.oracle.com/en/java/javase/11/docs/api/java.base/javax/crypto/spec/DHParameterSpec.html

DHParameterSpec(BigInteger p, BigInteger g) DHParameterSpec(BigInteger p, BigInteger g)
Constructs a parameter set for Diffie-Hellman, using a prime modulus p and a base generator g.使用质数模数 p 和基本生成器 g 构造 Diffie-Hellman 的参数集。 DHParameterSpec(BigInteger p, BigInteger g, int l) DHParameterSpec(BigInteger p, BigInteger g, int l)
Constructs a parameter set for Diffie-Hellman, using a prime modulus p, a base generator g, and the size in bits, l, of the random exponent (private value).使用质数模数 p、基本生成器 g 和随机指数(私有值)的位大小 l 构造 Diffie-Hellman 的参数集。

and https://docs.oracle.com/javase/9/docs/api/javax/crypto/spec/DHPublicKeySpec.htmlhttps://docs.oracle.com/javase/9/docs/api/javax/crypto/spec/DHPublicKeySpec.html

DHPublicKeySpec(BigInteger y, BigInteger p, BigInteger g) DHPublicKeySpec(BigInteger y, BigInteger p, BigInteger g)
Constructor that takes a public value y, a prime modulus p, and a base generator g.采用公共值 y、质数模数 p 和基本生成器 g 的构造函数。

https://docs.oracle.com/javase/9/docs/api/javax/crypto/spec/DHPrivateKeySpec.html https://docs.oracle.com/javase/9/docs/api/javax/crypto/spec/DHPrivateKeySpec.html

DHPrivateKeySpec(BigInteger x, BigInteger p, BigInteger g) DHPrivateKeySpec(BigInteger x, BigInteger p, BigInteger g)
Constructor that takes a private value x, a prime modulus p, and a base generator g.采用私有值 x、质数模数 p 和基本生成器 g 的构造函数。

Now, I know that Bouncy Castle has an implementation that supports this:现在,我知道 Bouncy Castle 有一个支持这个的实现:

https://people.eecs.berkeley.edu/~jonah/bc/org/bouncycastle/crypto/params/DHParameters.html https://people.eecs.berkeley.edu/~jonah/bc/org/bouncycastle/crypto/params/DHParameters.html

But I cannot use Bouncy Castle.但是我不能使用充气城堡。

Is there a way to still use DHParameterSpec/DHPublicKey/DHPrivateKey with the q value that I am missing?有没有办法仍然使用 DHParameterSpec/DHPublicKey/DHPrivateKey 和我缺少的 q 值?

Use DSA BigInteger getG() Returns the base g.使用 DSA BigInteger getG() 返回基数 g。 BigInteger getP() Returns the prime p. BigInteger getP() 返回素数 p。 BigInteger getQ() Returns the sub-prime q. BigInteger getQ() 返回次级素数 q。 https://docs.oracle.com/javase/7/docs/api/java/security/spec/DSAParameterSpec.html https://docs.oracle.com/javase/7/docs/api/java/security/spec/DSAParameterSpec.html

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

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