本文整理汇总了Java中org.bouncycastle.crypto.params.GOST3410PublicKeyParameters类的典型用法代码示例。如果您正苦于以下问题:Java GOST3410PublicKeyParameters类的具体用法?Java GOST3410PublicKeyParameters怎么用?Java GOST3410PublicKeyParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GOST3410PublicKeyParameters类属于org.bouncycastle.crypto.params包,在下文中一共展示了GOST3410PublicKeyParameters类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: init
import org.bouncycastle.crypto.params.GOST3410PublicKeyParameters; //导入依赖的package包/类
public void init(
boolean forSigning,
CipherParameters param)
{
if (forSigning)
{
if (param instanceof ParametersWithRandom)
{
ParametersWithRandom rParam = (ParametersWithRandom)param;
this.random = rParam.getRandom();
this.key = (GOST3410PrivateKeyParameters)rParam.getParameters();
}
else
{
this.random = new SecureRandom();
this.key = (GOST3410PrivateKeyParameters)param;
}
}
else
{
this.key = (GOST3410PublicKeyParameters)param;
}
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:25,代码来源:GOST3410Signer.java
示例2: generateKeyPair
import org.bouncycastle.crypto.params.GOST3410PublicKeyParameters; //导入依赖的package包/类
public AsymmetricCipherKeyPair generateKeyPair()
{
BigInteger p, q, a, x, y;
GOST3410Parameters GOST3410Params = param.getParameters();
SecureRandom random = param.getRandom();
q = GOST3410Params.getQ();
p = GOST3410Params.getP();
a = GOST3410Params.getA();
do
{
x = new BigInteger(256, random);
}
while (x.equals(ZERO) || x.compareTo(q) >= 0);
//
// calculate the public key.
//
y = a.modPow(x, p);
return new AsymmetricCipherKeyPair(
new GOST3410PublicKeyParameters(y, GOST3410Params),
new GOST3410PrivateKeyParameters(x, GOST3410Params));
}
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:26,代码来源:GOST3410KeyPairGenerator.java
示例3: BCGOST3410PublicKey
import org.bouncycastle.crypto.params.GOST3410PublicKeyParameters; //导入依赖的package包/类
BCGOST3410PublicKey(
GOST3410PublicKeyParameters params,
GOST3410ParameterSpec spec)
{
this.y = params.getY();
this.gost3410Spec = spec;
}
开发者ID:Appdome,项目名称:ipack,代码行数:8,代码来源:BCGOST3410PublicKey.java
示例4: generateKeyPair
import org.bouncycastle.crypto.params.GOST3410PublicKeyParameters; //导入依赖的package包/类
public KeyPair generateKeyPair()
{
if (!initialised)
{
init(new GOST3410ParameterSpec(CryptoProObjectIdentifiers.gostR3410_94_CryptoPro_A.getId()), new SecureRandom());
}
AsymmetricCipherKeyPair pair = engine.generateKeyPair();
GOST3410PublicKeyParameters pub = (GOST3410PublicKeyParameters)pair.getPublic();
GOST3410PrivateKeyParameters priv = (GOST3410PrivateKeyParameters)pair.getPrivate();
return new KeyPair(new BCGOST3410PublicKey(pub, gost3410Params), new BCGOST3410PrivateKey(priv, gost3410Params));
}
开发者ID:Appdome,项目名称:ipack,代码行数:14,代码来源:KeyPairGeneratorSpi.java
示例5: generatePublicKeyParameter
import org.bouncycastle.crypto.params.GOST3410PublicKeyParameters; //导入依赖的package包/类
static public AsymmetricKeyParameter generatePublicKeyParameter(
PublicKey key)
throws InvalidKeyException
{
if (key instanceof GOST3410PublicKey)
{
GOST3410PublicKey k = (GOST3410PublicKey)key;
GOST3410PublicKeyParameterSetSpec p = k.getParameters().getPublicKeyParameters();
return new GOST3410PublicKeyParameters(k.getY(),
new GOST3410Parameters(p.getP(), p.getQ(), p.getA()));
}
throw new InvalidKeyException("can't identify GOST3410 public key: " + key.getClass().getName());
}
开发者ID:Appdome,项目名称:ipack,代码行数:16,代码来源:GOST3410Util.java
示例6: verifySignature
import org.bouncycastle.crypto.params.GOST3410PublicKeyParameters; //导入依赖的package包/类
/**
* return true if the value r and s represent a GOST3410 signature for
* the passed in message for standard GOST3410 the message should be a
* GOST3411 hash of the real message to be verified.
*/
public boolean verifySignature(
byte[] message,
BigInteger r,
BigInteger s)
{
byte[] mRev = new byte[message.length]; // conversion is little-endian
for (int i = 0; i != mRev.length; i++)
{
mRev[i] = message[mRev.length - 1 - i];
}
BigInteger m = new BigInteger(1, mRev);
GOST3410Parameters params = key.getParameters();
BigInteger zero = BigInteger.valueOf(0);
if (zero.compareTo(r) >= 0 || params.getQ().compareTo(r) <= 0)
{
return false;
}
if (zero.compareTo(s) >= 0 || params.getQ().compareTo(s) <= 0)
{
return false;
}
BigInteger v = m.modPow(params.getQ().subtract(new BigInteger("2")),params.getQ());
BigInteger z1 = s.multiply(v).mod(params.getQ());
BigInteger z2 = (params.getQ().subtract(r)).multiply(v).mod(params.getQ());
z1 = params.getA().modPow(z1, params.getP());
z2 = ((GOST3410PublicKeyParameters)key).getY().modPow(z2, params.getP());
BigInteger u = z1.multiply(z2).mod(params.getP()).mod(params.getQ());
return u.equals(r);
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:43,代码来源:GOST3410Signer.java
示例7: generateKeyPair
import org.bouncycastle.crypto.params.GOST3410PublicKeyParameters; //导入依赖的package包/类
public AsymmetricCipherKeyPair generateKeyPair()
{
BigInteger p, q, a, x, y;
GOST3410Parameters GOST3410Params = param.getParameters();
SecureRandom random = param.getRandom();
q = GOST3410Params.getQ();
p = GOST3410Params.getP();
a = GOST3410Params.getA();
int minWeight = 64;
for (;;)
{
x = new BigInteger(256, random);
if (x.signum() < 1 || x.compareTo(q) >= 0)
{
continue;
}
if (WNafUtil.getNafWeight(x) < minWeight)
{
continue;
}
break;
}
//
// calculate the public key.
//
y = a.modPow(x, p);
return new AsymmetricCipherKeyPair(
new GOST3410PublicKeyParameters(y, GOST3410Params),
new GOST3410PrivateKeyParameters(x, GOST3410Params));
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:38,代码来源:GOST3410KeyPairGenerator.java
示例8: generateKeyPair
import org.bouncycastle.crypto.params.GOST3410PublicKeyParameters; //导入依赖的package包/类
public AsymmetricCipherKeyPair generateKeyPair()
{
BigInteger p, q, a, x, y;
GOST3410Parameters GOST3410Params = param.getParameters();
SecureRandom random = param.getRandom();
q = GOST3410Params.getQ();
p = GOST3410Params.getP();
a = GOST3410Params.getA();
int minWeight = 64;
for (;;)
{
x = new BigInteger(256, random);
if (x.signum() < 1 || x.compareTo(q) >= 0)
{
continue;
}
/*
* Require a minimum weight of the NAF representation, since low-weight primes may be
* weak against a version of the number-field-sieve for the discrete-logarithm-problem.
*
* See "The number field sieve for integers of low weight", Oliver Schirokauer.
*/
if (WNafUtil.getNafWeight(x) < minWeight)
{
continue;
}
break;
}
//
// calculate the public key.
//
y = a.modPow(x, p);
return new AsymmetricCipherKeyPair(
new GOST3410PublicKeyParameters(y, GOST3410Params),
new GOST3410PrivateKeyParameters(x, GOST3410Params));
}
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:44,代码来源:GOST3410KeyPairGenerator.java
注:本文中的org.bouncycastle.crypto.params.GOST3410PublicKeyParameters类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论