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


Java RSAKeyParameters.getExponent方法代码示例

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


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

示例1: makeV1Certificate

import org.bouncycastle.crypto.params.RSAKeyParameters; //导入方法依赖的package包/类
public static X509CertificateHolder makeV1Certificate(AsymmetricCipherKeyPair subKP, String _subDN, AsymmetricCipherKeyPair issKP, String _issDN)
    throws IOException, OperatorCreationException
{
    RSAKeyParameters lwPubKey = (RSAKeyParameters)subKP.getPublic();

    X509v1CertificateBuilder v1CertGen = new X509v1CertificateBuilder(
        new X500Name(_issDN),
        allocateSerialNumber(),
        new Date(System.currentTimeMillis()),
        new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 100)),
        new X500Name(_subDN),
        new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE), new RSAPublicKey(lwPubKey.getModulus(), lwPubKey.getExponent()))
    );

    AlgorithmIdentifier sigAlgId = new DefaultSignatureAlgorithmIdentifierFinder().find("SHA1WithRSAEncryption");
    AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId);

    ContentSigner sigGen = new BcRSAContentSignerBuilder(sigAlgId, digAlgId).build((AsymmetricKeyParameter)issKP.getPrivate());


    return v1CertGen.build(sigGen);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:23,代码来源:CMSTestUtil.java

示例2: makeCertificate

import org.bouncycastle.crypto.params.RSAKeyParameters; //导入方法依赖的package包/类
public static X509CertificateHolder makeCertificate(AsymmetricCipherKeyPair subKP, String _subDN, AsymmetricCipherKeyPair issKP, String _issDN, boolean _ca)
    throws IOException, OperatorCreationException
{
    RSAKeyParameters lwPubKey = (RSAKeyParameters)subKP.getPublic();

    X509v3CertificateBuilder v3CertGen = new X509v3CertificateBuilder(
        new X500Name(_issDN),
        allocateSerialNumber(),
        new Date(System.currentTimeMillis()),
        new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 100)),
        new X500Name(_subDN),
        new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE), new RSAPublicKey(lwPubKey.getModulus(), lwPubKey.getExponent()))
    );

    AlgorithmIdentifier sigAlgId = new DefaultSignatureAlgorithmIdentifierFinder().find("SHA1WithRSAEncryption");
    AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId);

    ContentSigner sigGen = new BcRSAContentSignerBuilder(sigAlgId, digAlgId).build((AsymmetricKeyParameter)issKP.getPrivate());

    v3CertGen.addExtension(
        X509Extension.basicConstraints,
        false,
        new BasicConstraints(_ca));

    return v3CertGen.build(sigGen);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:27,代码来源:CMSTestUtil.java

示例3: getPublicKey

import org.bouncycastle.crypto.params.RSAKeyParameters; //导入方法依赖的package包/类
public PublicKey getPublicKey() {
	try {
		SubjectPublicKeyInfo subjectPublicKeyInfo = getCertificate().getSubjectPublicKeyInfo();
		RSAKeyParameters rsa = (RSAKeyParameters) PublicKeyFactory.createKey(subjectPublicKeyInfo);

		RSAPublicKeySpec rsaSpec = new RSAPublicKeySpec(rsa.getModulus(), rsa.getExponent());

		KeyFactory kf = KeyFactory.getInstance(DEFAULT_KEY_ALG);
		PublicKey rsaPub = kf.generatePublic(rsaSpec);

		return rsaPub;

	} catch (Exception e) {
		throw new RuntimeException("Error while getting Public Key: " + e.getMessage(), e);
	}
}
 
开发者ID:fabiusks,项目名称:cert-services,代码行数:17,代码来源:IdentityContainer.java

示例4: BCRSAPublicKey

import org.bouncycastle.crypto.params.RSAKeyParameters; //导入方法依赖的package包/类
BCRSAPublicKey(
    RSAKeyParameters key)
{
    this.algorithmIdentifier = DEFAULT_ALGORITHM_IDENTIFIER;
    this.modulus = key.getModulus();
    this.publicExponent = key.getExponent();
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:8,代码来源:BCRSAPublicKey.java

示例5: JCERSAPublicKey

import org.bouncycastle.crypto.params.RSAKeyParameters; //导入方法依赖的package包/类
JCERSAPublicKey(
    RSAKeyParameters key)
{
    this.modulus = key.getModulus();
    this.publicExponent = key.getExponent();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:7,代码来源:JCERSAPublicKey.java

示例6: JCERSAPrivateKey

import org.bouncycastle.crypto.params.RSAKeyParameters; //导入方法依赖的package包/类
JCERSAPrivateKey(
    RSAKeyParameters key)
{
    this.modulus = key.getModulus();
    this.privateExponent = key.getExponent();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:7,代码来源:JCERSAPrivateKey.java

示例7: BCRSAPublicKey

import org.bouncycastle.crypto.params.RSAKeyParameters; //导入方法依赖的package包/类
BCRSAPublicKey(
    RSAKeyParameters key)
{
    this.modulus = key.getModulus();
    this.publicExponent = key.getExponent();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:7,代码来源:BCRSAPublicKey.java

示例8: BCRSAPrivateKey

import org.bouncycastle.crypto.params.RSAKeyParameters; //导入方法依赖的package包/类
BCRSAPrivateKey(
    RSAKeyParameters key)
{
    this.modulus = key.getModulus();
    this.privateExponent = key.getExponent();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:7,代码来源:BCRSAPrivateKey.java

示例9: rsaCreationTest

import org.bouncycastle.crypto.params.RSAKeyParameters; //导入方法依赖的package包/类
private void rsaCreationTest()
    throws Exception
{
    //
    // a lightweight key pair.
    //
    RSAKeyParameters lwPubKey = new RSAKeyParameters(
        false,
        new BigInteger("b4a7e46170574f16a97082b22be58b6a2a629798419be12872a4bdba626cfae9900f76abfb12139dce5de56564fab2b6543165a040c606887420e33d91ed7ed7", 16),
        new BigInteger("11", 16));

    RSAPrivateCrtKeyParameters lwPrivKey = new RSAPrivateCrtKeyParameters(
        new BigInteger("b4a7e46170574f16a97082b22be58b6a2a629798419be12872a4bdba626cfae9900f76abfb12139dce5de56564fab2b6543165a040c606887420e33d91ed7ed7", 16),
        new BigInteger("11", 16),
        new BigInteger("9f66f6b05410cd503b2709e88115d55daced94d1a34d4e32bf824d0dde6028ae79c5f07b580f5dce240d7111f7ddb130a7945cd7d957d1920994da389f490c89", 16),
        new BigInteger("c0a0758cdf14256f78d4708c86becdead1b50ad4ad6c5c703e2168fbf37884cb", 16),
        new BigInteger("f01734d7960ea60070f1b06f2bb81bfac48ff192ae18451d5e56c734a5aab8a5", 16),
        new BigInteger("b54bb9edff22051d9ee60f9351a48591b6500a319429c069a3e335a1d6171391", 16),
        new BigInteger("d3d83daf2a0cecd3367ae6f8ae1aeb82e9ac2f816c6fc483533d8297dd7884cd", 16),
        new BigInteger("b8f52fc6f38593dabb661d3f50f8897f8106eee68b1bce78a95b132b4e5b5d19", 16));

    //
    // distinguished name table.
    //
    X500NameBuilder builder = new X500NameBuilder(BCStyle.INSTANCE);

    builder.addRDN(BCStyle.C, "AU");
    builder.addRDN(BCStyle.O, "The Legion of the Bouncy Castle");
    builder.addRDN(BCStyle.L, "Melbourne");
    builder.addRDN(BCStyle.ST, "Victoria");
    builder.addRDN(BCStyle.E, "[email protected]");

    //
    // extensions
    //

    //
    // create the certificate - version 3 - without extensions
    //
    AlgorithmIdentifier sigAlgId = new DefaultSignatureAlgorithmIdentifierFinder().find("SHA256WithRSAEncryption");
    AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId);

    ContentSigner sigGen = new BcRSAContentSignerBuilder(sigAlgId, digAlgId).build(lwPrivKey);
    SubjectPublicKeyInfo pubInfo = new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE), new RSAPublicKey(lwPubKey.getModulus(), lwPubKey.getExponent()));

    X500NameBuilder x500NameBld = new X500NameBuilder(BCStyle.INSTANCE);

    x500NameBld.addRDN(BCStyle.C, "AU");
    x500NameBld.addRDN(BCStyle.O, "The Legion of the Bouncy Castle");
    x500NameBld.addRDN(BCStyle.L, "Melbourne");
    x500NameBld.addRDN(BCStyle.ST, "Victoria");
    x500NameBld.addRDN(BCStyle.EmailAddress, "[email protected]");

    X500Name    subject = x500NameBld.build();

    PKCS10CertificationRequestBuilder requestBuilder = new PKCS10CertificationRequestBuilder(subject, pubInfo);
                        
    PKCS10CertificationRequest req1 = requestBuilder.build(sigGen);

    PKCS10CertificationRequest req2 = new PKCS10CertificationRequest(req1.getEncoded());

    if (!req2.isSignatureValid(new BcRSAContentVerifierProviderBuilder(new DefaultDigestAlgorithmIdentifierFinder()).build(lwPubKey)))
    {
        fail("Failed verify check.");
    }

    if (!Arrays.areEqual(req2.getSubjectPublicKeyInfo().getEncoded(), req1.getSubjectPublicKeyInfo().getEncoded()))
    {
        fail("Failed public key check.");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:72,代码来源:PKCS10Test.java

示例10: checkCreation1

import org.bouncycastle.crypto.params.RSAKeyParameters; //导入方法依赖的package包/类
/**
     * we generate a self signed certificate for the sake of testing - RSA
     */
    public void checkCreation1()
        throws Exception
    {
//
        // a lightweight key pair.
        //
        RSAKeyParameters lwPubKey = new RSAKeyParameters(
            false,
            new BigInteger("b4a7e46170574f16a97082b22be58b6a2a629798419be12872a4bdba626cfae9900f76abfb12139dce5de56564fab2b6543165a040c606887420e33d91ed7ed7", 16),
            new BigInteger("11", 16));

        RSAPrivateCrtKeyParameters lwPrivKey = new RSAPrivateCrtKeyParameters(
            new BigInteger("b4a7e46170574f16a97082b22be58b6a2a629798419be12872a4bdba626cfae9900f76abfb12139dce5de56564fab2b6543165a040c606887420e33d91ed7ed7", 16),
            new BigInteger("11", 16),
            new BigInteger("9f66f6b05410cd503b2709e88115d55daced94d1a34d4e32bf824d0dde6028ae79c5f07b580f5dce240d7111f7ddb130a7945cd7d957d1920994da389f490c89", 16),
            new BigInteger("c0a0758cdf14256f78d4708c86becdead1b50ad4ad6c5c703e2168fbf37884cb", 16),
            new BigInteger("f01734d7960ea60070f1b06f2bb81bfac48ff192ae18451d5e56c734a5aab8a5", 16),
            new BigInteger("b54bb9edff22051d9ee60f9351a48591b6500a319429c069a3e335a1d6171391", 16),
            new BigInteger("d3d83daf2a0cecd3367ae6f8ae1aeb82e9ac2f816c6fc483533d8297dd7884cd", 16),
            new BigInteger("b8f52fc6f38593dabb661d3f50f8897f8106eee68b1bce78a95b132b4e5b5d19", 16));

        //
        // distinguished name table.
        //
        X500NameBuilder builder = new X500NameBuilder(BCStyle.INSTANCE);
        
        builder.addRDN(BCStyle.C, "AU");
        builder.addRDN(BCStyle.O, "The Legion of the Bouncy Castle");
        builder.addRDN(BCStyle.L, "Melbourne");
        builder.addRDN(BCStyle.ST, "Victoria");
        builder.addRDN(BCStyle.E, "[email protected]");

        //
        // extensions
        //

        //
        // create the certificate - version 3 - without extensions
        //
        AlgorithmIdentifier sigAlgId = new DefaultSignatureAlgorithmIdentifierFinder().find("SHA256WithRSAEncryption");
        AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId);

        ContentSigner sigGen = new BcRSAContentSignerBuilder(sigAlgId, digAlgId).build(lwPrivKey);
        SubjectPublicKeyInfo pubInfo = new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE), new RSAPublicKey(lwPubKey.getModulus(), lwPubKey.getExponent()));
        X509v3CertificateBuilder certGen = new X509v3CertificateBuilder(builder.build(), BigInteger.valueOf(1), new Date(System.currentTimeMillis() - 50000), new Date(System.currentTimeMillis() + 50000), builder.build(), pubInfo);

        X509CertificateHolder certHolder = certGen.build(sigGen);

        ContentVerifierProvider contentVerifierProvider = new BcRSAContentVerifierProviderBuilder(new DefaultDigestAlgorithmIdentifierFinder()).build(lwPubKey);

        if (!certHolder.isSignatureValid(contentVerifierProvider))
        {
            fail("lw sig verification failed");
        }
    }
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:59,代码来源:CertTest.java

示例11: toRSAPublicKey

import org.bouncycastle.crypto.params.RSAKeyParameters; //导入方法依赖的package包/类
public static RSAPublicKey toRSAPublicKey(RSAKeyParameters k) throws Exception
{
	return new RSAPublicKey(k.getModulus(), k.getExponent());
}
 
开发者ID:andy-goryachev,项目名称:PasswordSafe,代码行数:5,代码来源:Crypto.java

示例12: TempJCERSAPrivateKey

import org.bouncycastle.crypto.params.RSAKeyParameters; //导入方法依赖的package包/类
TempJCERSAPrivateKey(
    RSAKeyParameters key)
{
    this.modulus = key.getModulus();
    this.privateExponent = key.getExponent();
}
 
开发者ID:rovemonteux,项目名称:silvertunnel-monteux,代码行数:7,代码来源:TempJCERSAPrivateKey.java

示例13: TempJCERSAPublicKey

import org.bouncycastle.crypto.params.RSAKeyParameters; //导入方法依赖的package包/类
TempJCERSAPublicKey(
    RSAKeyParameters key)
{
    this.modulus = key.getModulus();
    this.publicExponent = key.getExponent();
}
 
开发者ID:rovemonteux,项目名称:silvertunnel-monteux,代码行数:7,代码来源:TempJCERSAPublicKey.java

示例14: testCreateCsrFromPemV2_bcprov_jdk15on_1_50

import org.bouncycastle.crypto.params.RSAKeyParameters; //导入方法依赖的package包/类
/**
 * Read the pkcs#10 CSR pem text and create a BC CSR object for subsequent
 * verifying and manipulation. This test uses bcprov-jdk15on-1.50.jar and
 * bcpkix-jdk15on-1.50.jar
 *
 * @throws Exception
 */
@Test
public void testCreateCsrFromPemV2_bcprov_jdk15on_1_50() throws Exception {
    SignatureAlgorithmIdentifierFinder algFinder = new DefaultSignatureAlgorithmIdentifierFinder();
    String csrPemStr = this.getCsrIrregularOrderDN();

    PemReader pemReader = new PemReader(new StringReader(csrPemStr));
    PemObject obj = pemReader.readPemObject();
    pemReader.close();
    byte[] pembytes = obj.getContent();
    PKCS10CertificationRequest req = new PKCS10CertificationRequest(pembytes);

    assertEquals("CN=some body,C=UK,L=DL,O=eScience,OU=CLRC", req.getSubject().toString());
    //System.out.println(req.getSubject().toString());
    SubjectPublicKeyInfo pkInfo = req.getSubjectPublicKeyInfo();

    // get the algorithm of the pubkey RSA  
    AlgorithmIdentifier pubKeyAlgId = pkInfo.getAlgorithm();
    //System.out.println(pubKeyAlgId.getAlgorithm().getId());   // 1.2.840.113549.1.1.1
    //System.out.println(pubKeyAlgId.getAlgorithm().toString());// 1.2.840.113549.1.1.1
    assertEquals("1.2.840.113549.1.1.1", pubKeyAlgId.getAlgorithm().getId());

    // get the algorithm of the request (we expect SHA1 with RSA)  
    AlgorithmIdentifier reqSigAlgId = req.getSignatureAlgorithm();
    AlgorithmIdentifier algIdExpected = algFinder.find("SHA1WITHRSAENCRYPTION"); // or "SHA1withRSA", "SHA1withRSAEncryption" 
    assertEquals(reqSigAlgId.getAlgorithm().getId(), algIdExpected.getAlgorithm().getId());
    assertEquals("1.2.840.113549.1.1.5", algIdExpected.getAlgorithm().getId());

    // Get java.security.PublicKey so we can validate and get the DB formatted pub key  
    // Looks like we can get the public key in two ways: 
    //
    // 1) 
    //http://stackoverflow.com/questions/11028932/how-to-get-publickey-from-pkcs10certificationrequest-using-new-bouncy-castle-lib
    RSAKeyParameters rsa = (RSAKeyParameters) PublicKeyFactory.createKey(pkInfo);
    assertEquals(2048, rsa.getModulus().bitLength());
    RSAPublicKeySpec rsaSpec = new RSAPublicKeySpec(rsa.getModulus(), rsa.getExponent());
    KeyFactory kf = KeyFactory.getInstance("RSA");
    PublicKey pubKey1 = kf.generatePublic(rsaSpec);
    String pubkey1DBFormat = getDBFormattedRSAPublicKey(pubKey1);
    boolean valid = req.isSignatureValid((new JcaContentVerifierProviderBuilder()).build(pubKey1));
    assertTrue(valid);
    //
    // 2) 
    JcaPKCS10CertificationRequest jcaReq = new JcaPKCS10CertificationRequest(req);
    PublicKey pubKey2 = jcaReq.getPublicKey();
    RSAPublicKey rsa2 = (RSAPublicKey) pubKey2;
    assertEquals(2048, rsa2.getModulus().bitLength());

    String pubkey2DBFormat = getDBFormattedRSAPublicKey(pubKey2);
    assertTrue(jcaReq.isSignatureValid((new JcaContentVerifierProviderBuilder()).build(pubKey2)));

    // Test that the two DB formated pubkeys are the same 
    assertEquals(pubkey1DBFormat, pubkey2DBFormat);

}
 
开发者ID:UKCA,项目名称:CAPortal,代码行数:62,代码来源:TestBC_PKCS10.java


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