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


Java RSAPublicBCPGKey类代码示例

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


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

示例1: init

import org.bouncycastle.bcpg.RSAPublicBCPGKey; //导入依赖的package包/类
private void init(KeyFingerPrintCalculator fingerPrintCalculator)
    throws PGPException
{
    BCPGKey                key = publicPk.getKey();

    this.fingerprint = fingerPrintCalculator.calculateFingerprint(publicPk);

    if (publicPk.getVersion() <= 3)
    {
        RSAPublicBCPGKey    rK = (RSAPublicBCPGKey)key;
        
        this.keyID = rK.getModulus().longValue();
        this.keyStrength = rK.getModulus().bitLength();
    }
    else
    {
        this.keyID = ((long)(fingerprint[fingerprint.length - 8] & 0xff) << 56)
                        | ((long)(fingerprint[fingerprint.length - 7] & 0xff) << 48)
                        | ((long)(fingerprint[fingerprint.length - 6] & 0xff) << 40)
                        | ((long)(fingerprint[fingerprint.length - 5] & 0xff) << 32)
                        | ((long)(fingerprint[fingerprint.length - 4] & 0xff) << 24)
                        | ((long)(fingerprint[fingerprint.length - 3] & 0xff) << 16)
                        | ((long)(fingerprint[fingerprint.length - 2] & 0xff) << 8)
                        | ((fingerprint[fingerprint.length - 1] & 0xff));
        
        if (key instanceof RSAPublicBCPGKey)
        {
            this.keyStrength = ((RSAPublicBCPGKey)key).getModulus().bitLength();
        }
        else if (key instanceof DSAPublicBCPGKey)
        {
            this.keyStrength = ((DSAPublicBCPGKey)key).getP().bitLength();
        }
        else if (key instanceof ElGamalPublicBCPGKey)
        {
            this.keyStrength = ((ElGamalPublicBCPGKey)key).getP().bitLength();
        }
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:40,代码来源:PGPPublicKey.java

示例2: checkWeakKey

import org.bouncycastle.bcpg.RSAPublicBCPGKey; //导入依赖的package包/类
private final static void checkWeakKey(PGPPublicKey pk)
    throws PGPException
{
    BCPGKey k = pk.getPublicKeyPacket().getKey();
    if (k instanceof RSAPublicBCPGKey) {
        checkWeakRSA((RSAPublicBCPGKey) k);
    }
    else if (k instanceof DSAPublicBCPGKey) {
        checkDSA((DSAPublicBCPGKey) k);
    }
    // tbd
}
 
开发者ID:kbsriram,项目名称:keypan,代码行数:13,代码来源:CPGPUtils.java

示例3: checkWeakRSA

import org.bouncycastle.bcpg.RSAPublicBCPGKey; //导入依赖的package包/类
private final static void checkWeakRSA(RSAPublicBCPGKey rsak)
    throws PGPException
{
    BigInteger n = rsak.getModulus();
    BigInteger e = rsak.getPublicExponent();

    // n and e should be odd.
    if (!n.testBit(0) || !e.testBit(0)) {
        throw new PGPException("modulus and exponent must not be even.");
    }

    // e should be > 2
    if (e.compareTo(TWO) <= 0) {
        throw new PGPException("exponent must be >= 3");
    }

    // modulus should fail primality test
    if (n.isProbablePrime(80)) {
        throw new PGPException
            ("modulus doesn't seem to be a composite number.");
    }

    // modulus should have no small factors
    BigInteger factor = n.gcd(SMALL_FACTORS);
    if (!factor.equals(BigInteger.ONE)) {
        throw new PGPException("modulus has a small factor ("+factor+")");
    }
}
 
开发者ID:kbsriram,项目名称:keypan,代码行数:29,代码来源:CPGPUtils.java


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