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


Java RSAPrivateCrtKey.getPrivateExponent方法代码示例

本文整理汇总了Java中java.security.interfaces.RSAPrivateCrtKey.getPrivateExponent方法的典型用法代码示例。如果您正苦于以下问题:Java RSAPrivateCrtKey.getPrivateExponent方法的具体用法?Java RSAPrivateCrtKey.getPrivateExponent怎么用?Java RSAPrivateCrtKey.getPrivateExponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.security.interfaces.RSAPrivateCrtKey的用法示例。


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

示例1: JCERSAPrivateCrtKey

import java.security.interfaces.RSAPrivateCrtKey; //导入方法依赖的package包/类
/**
 * construct a private key from another RSAPrivateCrtKey.
 *
 * @param key the object implementing the RSAPrivateCrtKey interface.
 */
JCERSAPrivateCrtKey(
    RSAPrivateCrtKey key)
{
    this.modulus = key.getModulus();
    this.publicExponent = key.getPublicExponent();
    this.privateExponent = key.getPrivateExponent();
    this.primeP = key.getPrimeP();
    this.primeQ = key.getPrimeQ();
    this.primeExponentP = key.getPrimeExponentP();
    this.primeExponentQ = key.getPrimeExponentQ();
    this.crtCoefficient = key.getCrtCoefficient();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:18,代码来源:JCERSAPrivateCrtKey.java

示例2: BCRSAPrivateCrtKey

import java.security.interfaces.RSAPrivateCrtKey; //导入方法依赖的package包/类
/**
 * construct a private key from another RSAPrivateCrtKey.
 *
 * @param key the object implementing the RSAPrivateCrtKey interface.
 */
BCRSAPrivateCrtKey(
    RSAPrivateCrtKey key)
{
    this.modulus = key.getModulus();
    this.publicExponent = key.getPublicExponent();
    this.privateExponent = key.getPrivateExponent();
    this.primeP = key.getPrimeP();
    this.primeQ = key.getPrimeQ();
    this.primeExponentP = key.getPrimeExponentP();
    this.primeExponentQ = key.getPrimeExponentQ();
    this.crtCoefficient = key.getCrtCoefficient();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:18,代码来源:BCRSAPrivateCrtKey.java

示例3: generateRSAPrivateKeyParameter

import java.security.interfaces.RSAPrivateCrtKey; //导入方法依赖的package包/类
public static RSAKeyParameters generateRSAPrivateKeyParameter(RSAPrivateKey key) {
    ParamUtil.requireNonNull("key", key);
    if (key instanceof RSAPrivateCrtKey) {
        RSAPrivateCrtKey rsaKey = (RSAPrivateCrtKey) key;

        return new RSAPrivateCrtKeyParameters(rsaKey.getModulus(), rsaKey.getPublicExponent(),
                rsaKey.getPrivateExponent(), rsaKey.getPrimeP(), rsaKey.getPrimeQ(),
                rsaKey.getPrimeExponentP(), rsaKey.getPrimeExponentQ(),
                rsaKey.getCrtCoefficient());
    } else {
        return new RSAKeyParameters(true, key.getModulus(), key.getPrivateExponent());
    }
}
 
开发者ID:xipki,项目名称:xitk,代码行数:14,代码来源:SignerUtil.java

示例4: getRSASignerCredentials

import java.security.interfaces.RSAPrivateCrtKey; //导入方法依赖的package包/类
protected TlsSignerCredentials getRSASignerCredentials() throws IOException {

        RSAPrivateCrtKey key = (RSAPrivateCrtKey)(pair.getValue().getPrivate());
        return new DefaultTlsSignerCredentials(context,
                cert,
                new RSAKeyParameters(true,key.getModulus(),key.getPrivateExponent()),
                new SignatureAndHashAlgorithm(HashAlgorithm.sha256,SignatureAlgorithm.rsa));
    }
 
开发者ID:IIlllII,项目名称:bitbreeds-webrtc,代码行数:9,代码来源:WebrtcDtlsServer.java

示例5: TempJCERSAPrivateCrtKey

import java.security.interfaces.RSAPrivateCrtKey; //导入方法依赖的package包/类
/**
 * construct a private key from another RSAPrivateCrtKey.
 *
 * @param key the object implementing the RSAPrivateCrtKey interface.
 */
TempJCERSAPrivateCrtKey(
    RSAPrivateCrtKey key)
{
    this.modulus = key.getModulus();
    this.publicExponent = key.getPublicExponent();
    this.privateExponent = key.getPrivateExponent();
    this.primeP = key.getPrimeP();
    this.primeQ = key.getPrimeQ();
    this.primeExponentP = key.getPrimeExponentP();
    this.primeExponentQ = key.getPrimeExponentQ();
    this.crtCoefficient = key.getCrtCoefficient();
}
 
开发者ID:B4dT0bi,项目名称:silvertunnel-ng,代码行数:18,代码来源:TempJCERSAPrivateCrtKey.java

示例6: checkPrivateCrtKey

import java.security.interfaces.RSAPrivateCrtKey; //导入方法依赖的package包/类
private void checkPrivateCrtKey(RSAPrivateCrtKey key, int expectedKeySize) throws Exception {
  BigInteger p = key.getPrimeP();
  BigInteger q = key.getPrimeQ();
  BigInteger n = key.getModulus();
  BigInteger e = key.getPublicExponent();
  BigInteger d = key.getPrivateExponent();
  BigInteger dp = key.getPrimeExponentP();
  BigInteger dq = key.getPrimeExponentQ();
  BigInteger crtCoeff = key.getCrtCoefficient();

  // Simple test that (n,d,e) is a valid RSA key.
  assertEquals(n, p.multiply(q));
  assertEquals(expectedKeySize, n.bitLength());
  int certainty = 80;
  assertTrue(p.isProbablePrime(certainty));
  assertTrue(q.isProbablePrime(certainty));
  // Very simple checks for weak random number generators.
  RandomUtil.checkPrime(p);
  RandomUtil.checkPrime(q);
  assertTrue(d.bitLength() > expectedKeySize / 2);
  // TODO(bleichen): Keys that are very imbalanced can be broken with elliptic curve factoring.
  //   Add other checks. E.g. for the size of dp and dq
  assertTrue(p.bitLength() > 256);
  assertTrue(q.bitLength() > 256);
  BigInteger p1 = p.subtract(BigInteger.ONE);
  BigInteger q1 = q.subtract(BigInteger.ONE);
  BigInteger phi = p1.multiply(q1);
  BigInteger order = phi.divide(p1.gcd(q1)); // maximal order of elements
  assertEquals(BigInteger.ONE, d.multiply(e).mod(order));
  assertEquals(d.mod(p1), dp.mod(p1));
  assertEquals(d.mod(q1), dq.mod(q1));
  assertEquals(q.multiply(crtCoeff).mod(p), BigInteger.ONE);
}
 
开发者ID:google,项目名称:wycheproof,代码行数:34,代码来源:RsaKeyTest.java

示例7: getPrivateKeyParameters

import java.security.interfaces.RSAPrivateCrtKey; //导入方法依赖的package包/类
private RSAPrivateCrtKeyParameters getPrivateKeyParameters(RSAPrivateCrtKey privateCrtKey) {
    return new RSAPrivateCrtKeyParameters(privateCrtKey.getModulus(),
            privateCrtKey.getPublicExponent(),
            privateCrtKey.getPrivateExponent(),
            privateCrtKey.getPrimeP(), privateCrtKey.getPrimeQ(), privateCrtKey.getPrimeExponentP(),
            privateCrtKey.getPrimeExponentQ(),
            privateCrtKey.getCrtCoefficient());
}
 
开发者ID:hsiafan,项目名称:byproxy,代码行数:9,代码来源:KeyStoreGenerator.java

示例8: convertPrivateKey

import java.security.interfaces.RSAPrivateCrtKey; //导入方法依赖的package包/类
private static PrivateKey convertPrivateKey(PrivateKey key) {
if (key instanceof RSAPrivateCrtKey) {
    RSAPrivateCrtKey rsaKey = (RSAPrivateCrtKey)key;
    RawRSAPrivateKey ck = new RawRSAPrivateKey(rsaKey.getPrivateExponent(),
					       rsaKey.getPrimeP(),
					       rsaKey.getPrimeQ(),
					       rsaKey.getCrtCoefficient());
    return new X509RSAPrivateKey(ck);
} else {
    throw new IllegalArgumentException();
}
   }
 
开发者ID:NCIP,项目名称:cagrid-general,代码行数:13,代码来源:PureTLSContext.java

示例9: main

import java.security.interfaces.RSAPrivateCrtKey; //导入方法依赖的package包/类
public static void main(String[] args) throws NoSuchAlgorithmException,
        NoSuchProviderException, InvalidKeySpecException {
    // Generate the first key.
    KeyPairGenerator generator
            = KeyPairGenerator.getInstance(KEYALG, PROVIDER_NAME);
    KeyPair keyPair = generator.generateKeyPair();
    RSAPrivateKey rsaPrivateKey = (RSAPrivateKey) keyPair.getPrivate();
    if (!(rsaPrivateKey instanceof RSAPrivateCrtKey)) {
        System.err.println("rsaPrivateKey class : " + rsaPrivateKey.getClass().getName());
        throw new RuntimeException("rsaPrivateKey is not a RSAPrivateCrtKey instance");
    }

    // Generate the second key.
    KeyFactory factory = KeyFactory.getInstance(KEYALG, PROVIDER_NAME);
    RSAPrivateKeySpec rsaPrivateKeySpec = new RSAPrivateKeySpec(
            rsaPrivateKey.getModulus(), rsaPrivateKey.getPrivateExponent());
    RSAPrivateKey rsaPrivateKey2 = (RSAPrivateKey) factory.generatePrivate(
            rsaPrivateKeySpec);

    // Generate the third key.
    PKCS8EncodedKeySpec encodedKeySpec = new PKCS8EncodedKeySpec(
            rsaPrivateKey.getEncoded());
    RSAPrivateKey rsaPrivateKey3 = (RSAPrivateKey) factory.generatePrivate(
            encodedKeySpec);

    // Check for equality.
    if (rsaPrivateKey.equals(rsaPrivateKey2)) {
        throw new RuntimeException("rsaPrivateKey should not equal to rsaPrivateKey2");
    }
    if (!rsaPrivateKey3.equals(rsaPrivateKey)) {
        throw new RuntimeException("rsaPrivateKey3 should equal to rsaPrivateKey");
    }
    if (rsaPrivateKey3.equals(rsaPrivateKey2)) {
        throw new RuntimeException("rsaPrivateKey3 should not equal to rsaPrivateKey2");
    }
    if (rsaPrivateKey2.equals(rsaPrivateKey3)) {
        throw new RuntimeException("rsaPrivateKey2 should not equal to rsaPrivateKey3");
    }

    // Generate the fourth key.
    RSAPrivateCrtKey rsaPrivateCrtKey =  (RSAPrivateCrtKey)rsaPrivateKey;
    RSAPrivateCrtKeySpec rsaPrivateCrtKeySpec = new RSAPrivateCrtKeySpec(
            rsaPrivateCrtKey.getModulus(),
            rsaPrivateCrtKey.getPublicExponent(),
            rsaPrivateCrtKey.getPrivateExponent(),
            rsaPrivateCrtKey.getPrimeP(),
            rsaPrivateCrtKey.getPrimeQ(),
            rsaPrivateCrtKey.getPrimeExponentP(),
            rsaPrivateCrtKey.getPrimeExponentQ(),
            rsaPrivateCrtKey.getCrtCoefficient()
        );
    RSAPrivateCrtKey rsaPrivateKey4 = (RSAPrivateCrtKey) factory.generatePrivate(
            rsaPrivateCrtKeySpec);
    if (!rsaPrivateKey.equals(rsaPrivateKey4)) {
        throw new RuntimeException("rsaPrivateKey should equal to rsaPrivateKey4");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:58,代码来源:PrivateKeyEqualityTest.java

示例10: getInstance

import java.security.interfaces.RSAPrivateCrtKey; //导入方法依赖的package包/类
static OpenSSLKey getInstance(RSAPrivateCrtKey rsaPrivateKey) throws InvalidKeyException {
    /**
     * If the key is not encodable (PKCS11-like key), then wrap it and use
     * JNI upcalls to satisfy requests.
     */
    if (rsaPrivateKey.getFormat() == null) {
        return wrapPlatformKey(rsaPrivateKey);
    }

    BigInteger modulus = rsaPrivateKey.getModulus();
    BigInteger privateExponent = rsaPrivateKey.getPrivateExponent();

    if (modulus == null) {
        throw new InvalidKeyException("modulus == null");
    } else if (privateExponent == null) {
        throw new InvalidKeyException("privateExponent == null");
    }

    try {
        /*
         * OpenSSL uses the public modulus to do RSA blinding. If
         * the public modulus is not available, the call to
         * EVP_PKEY_new_RSA will turn off blinding for this key
         * instance.
         */
        final BigInteger publicExponent = rsaPrivateKey.getPublicExponent();
        final BigInteger primeP = rsaPrivateKey.getPrimeP();
        final BigInteger primeQ = rsaPrivateKey.getPrimeQ();
        final BigInteger primeExponentP = rsaPrivateKey.getPrimeExponentP();
        final BigInteger primeExponentQ = rsaPrivateKey.getPrimeExponentQ();
        final BigInteger crtCoefficient = rsaPrivateKey.getCrtCoefficient();

        return new OpenSSLKey(NativeCrypto.EVP_PKEY_new_RSA(
                modulus.toByteArray(),
                publicExponent == null ? null : publicExponent.toByteArray(),
                privateExponent.toByteArray(),
                primeP == null ? null : primeP.toByteArray(),
                primeQ == null ? null : primeQ.toByteArray(),
                primeExponentP == null ? null : primeExponentP.toByteArray(),
                primeExponentQ == null ? null : primeExponentQ.toByteArray(),
                crtCoefficient == null ? null : crtCoefficient.toByteArray()));
    } catch (Exception e) {
        throw new InvalidKeyException(e);
    }
}
 
开发者ID:google,项目名称:conscrypt,代码行数:46,代码来源:OpenSSLRSAPrivateCrtKey.java


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