当前位置: 首页>>代码示例>>Java>>正文


Java CramerShoupPublicKeyParameters类代码示例

本文整理汇总了Java中org.bouncycastle.crypto.params.CramerShoupPublicKeyParameters的典型用法代码示例。如果您正苦于以下问题:Java CramerShoupPublicKeyParameters类的具体用法?Java CramerShoupPublicKeyParameters怎么用?Java CramerShoupPublicKeyParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CramerShoupPublicKeyParameters类属于org.bouncycastle.crypto.params包,在下文中一共展示了CramerShoupPublicKeyParameters类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateKeyPair

import org.bouncycastle.crypto.params.CramerShoupPublicKeyParameters; //导入依赖的package包/类
public AsymmetricCipherKeyPair generateKeyPair() {
	CramerShoupParameters csParams = param.getParameters();

	CramerShoupPrivateKeyParameters sk = generatePrivateKey(param.getRandom(), csParams);
	CramerShoupPublicKeyParameters pk = calculatePublicKey(csParams, sk);
	sk.setPk(pk);

	return new AsymmetricCipherKeyPair(pk, sk);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:10,代码来源:CramerShoupKeyPairGenerator.java

示例2: calculatePublicKey

import org.bouncycastle.crypto.params.CramerShoupPublicKeyParameters; //导入依赖的package包/类
private CramerShoupPublicKeyParameters calculatePublicKey(CramerShoupParameters csParams, CramerShoupPrivateKeyParameters sk) {
	BigInteger g1 = csParams.getG1();
	BigInteger g2 = csParams.getG2();
	BigInteger p = csParams.getP();
	
	BigInteger c = g1.modPow(sk.getX1(), p).multiply(g2.modPow(sk.getX2(), p));
	BigInteger d = g1.modPow(sk.getY1(), p).multiply(g2.modPow(sk.getY2(), p));
	BigInteger h = g1.modPow(sk.getZ(), p);
	
	return new CramerShoupPublicKeyParameters(csParams, c, d, h);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:12,代码来源:CramerShoupKeyPairGenerator.java

示例3: encryptBlock

import org.bouncycastle.crypto.params.CramerShoupPublicKeyParameters; //导入依赖的package包/类
public CramerShoupCiphertext encryptBlock(BigInteger input)
{

    CramerShoupCiphertext result = null;

    if (!key.isPrivate() && this.forEncryption && key instanceof CramerShoupPublicKeyParameters)
    {
        CramerShoupPublicKeyParameters pk = (CramerShoupPublicKeyParameters)key;
        BigInteger p = pk.getParameters().getP();
        BigInteger g1 = pk.getParameters().getG1();
        BigInteger g2 = pk.getParameters().getG2();

        BigInteger h = pk.getH();

        if (!isValidMessage(input, p))
        {
            return result;
        }

        BigInteger r = generateRandomElement(p, random);

        BigInteger u1, u2, v, e, a;

        u1 = g1.modPow(r, p);
        u2 = g2.modPow(r, p);
        e = h.modPow(r, p).multiply(input).mod(p);

        Digest digest = pk.getParameters().getH();
        byte[] u1Bytes = u1.toByteArray();
        digest.update(u1Bytes, 0, u1Bytes.length);
        byte[] u2Bytes = u2.toByteArray();
        digest.update(u2Bytes, 0, u2Bytes.length);
        byte[] eBytes = e.toByteArray();
        digest.update(eBytes, 0, eBytes.length);
        if (this.label != null)
        {
            byte[] lBytes = this.label.getBytes();
            digest.update(lBytes, 0, lBytes.length);
        }
        byte[] out = new byte[digest.getDigestSize()];
        digest.doFinal(out, 0);
        a = new BigInteger(1, out);

        v = pk.getC().modPow(r, p).multiply(pk.getD().modPow(r.multiply(a), p)).mod(p);

        result = new CramerShoupCiphertext(u1, u2, e, v);
    }
    return result;
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:50,代码来源:CramerShoupCoreEngine.java


注:本文中的org.bouncycastle.crypto.params.CramerShoupPublicKeyParameters类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。