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


Java PKCS8EncryptedPrivateKeyInfoBuilder类代码示例

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


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

示例1: encryptKey

import org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfoBuilder; //导入依赖的package包/类
private static byte[] encryptKey(KeyPair key, String resource, PasswordCallback newPassword) throws IOException {
	char[] passwordChars = newPassword.queryPassword(resource);

	if (passwordChars == null) {
		throw new PasswordRequiredException(resource);
	}

	byte[] encoded;

	try {
		PKCS8EncryptedPrivateKeyInfoBuilder encryptedPrivateKeyInfoBuilder = new PKCS8EncryptedPrivateKeyInfoBuilder(
				KeyHelper.encodePrivateKey(key.getPrivate()));
		OutputEncryptor encryptor = OUTPUT_ENCRYPTOR_BUILDER.build(passwordChars);

		encoded = encryptedPrivateKeyInfoBuilder.build(encryptor).getEncoded();
	} catch (OperatorCreationException e) {
		throw new CertProviderException(e);
	}
	return encoded;
}
 
开发者ID:hdecarne,项目名称:certmgr,代码行数:21,代码来源:DERCertReaderWriter.java

示例2: encrypt

import org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfoBuilder; //导入依赖的package包/类
PKCS8EncryptedPrivateKeyInfo encrypt(PrivateKey privateKey) {
    ParamUtil.requireNonNull("privateKey", privateKey);
    PrivateKeyInfo privateKeyInfo = PrivateKeyInfo.getInstance(privateKey.getEncoded());
    PKCS8EncryptedPrivateKeyInfoBuilder builder = new PKCS8EncryptedPrivateKeyInfoBuilder(
            privateKeyInfo);
    synchronized (encryptor) {
        return builder.build(encryptor);
    }
}
 
开发者ID:xipki,项目名称:xitk,代码行数:10,代码来源:PrivateKeyCryptor.java

示例3: testBcEncryptedPrivateKeyInfo

import org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfoBuilder; //导入依赖的package包/类
public void testBcEncryptedPrivateKeyInfo()
    throws Exception
{
    KeyFactory fact = KeyFactory.getInstance("RSA", BC);
    PrivateKey privKey = fact.generatePrivate(privKeySpec);

    PKCS8EncryptedPrivateKeyInfoBuilder builder = new JcaPKCS8EncryptedPrivateKeyInfoBuilder(privKey);

    PKCS8EncryptedPrivateKeyInfo priv = builder.build(new BcPKCS12PBEOutputEncryptorBuilder(PKCSObjectIdentifiers.pbeWithSHAAnd3_KeyTripleDES_CBC, new CBCBlockCipher(new DESedeEngine())).build(passwd));

    PrivateKeyInfo info = priv.decryptPrivateKeyInfo(new BcPKCS12PBEInputDecryptorProviderBuilder().build(passwd));

    assertTrue(Arrays.areEqual(info.getEncoded(), privKey.getEncoded()));
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:15,代码来源:PfxPduTest.java

示例4: testEncryptedPrivateKeyInfo

import org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfoBuilder; //导入依赖的package包/类
public void testEncryptedPrivateKeyInfo()
    throws Exception
{
    KeyFactory fact = KeyFactory.getInstance("RSA", BC);
    PrivateKey privKey = fact.generatePrivate(privKeySpec);

    PKCS8EncryptedPrivateKeyInfoBuilder builder = new JcaPKCS8EncryptedPrivateKeyInfoBuilder(privKey);

    PKCS8EncryptedPrivateKeyInfo priv = builder.build(new JcePKCSPBEOutputEncryptorBuilder(PKCSObjectIdentifiers.pbeWithSHAAnd3_KeyTripleDES_CBC).build(passwd));

    PrivateKeyInfo info = priv.decryptPrivateKeyInfo(new JcePKCSPBEInputDecryptorProviderBuilder().build(passwd));

    assertTrue(Arrays.areEqual(info.getEncoded(), privKey.getEncoded()));
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:15,代码来源:PfxPduTest.java

示例5: testEncryptedPrivateKeyInfoPKCS5

import org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfoBuilder; //导入依赖的package包/类
public void testEncryptedPrivateKeyInfoPKCS5()
    throws Exception
{
    KeyFactory fact = KeyFactory.getInstance("RSA", BC);
    PrivateKey privKey = fact.generatePrivate(privKeySpec);

    PKCS8EncryptedPrivateKeyInfoBuilder builder = new JcaPKCS8EncryptedPrivateKeyInfoBuilder(privKey);

    PKCS8EncryptedPrivateKeyInfo priv = builder.build(new JcePKCSPBEOutputEncryptorBuilder(NISTObjectIdentifiers.id_aes256_CBC).build(passwd));

    PrivateKeyInfo info = priv.decryptPrivateKeyInfo(new JcePKCSPBEInputDecryptorProviderBuilder().build(passwd));

    assertTrue(Arrays.areEqual(info.getEncoded(), privKey.getEncoded()));
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:15,代码来源:PfxPduTest.java


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