本文整理汇总了Java中org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfoBuilder.build方法的典型用法代码示例。如果您正苦于以下问题:Java PKCS8EncryptedPrivateKeyInfoBuilder.build方法的具体用法?Java PKCS8EncryptedPrivateKeyInfoBuilder.build怎么用?Java PKCS8EncryptedPrivateKeyInfoBuilder.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.pkcs.PKCS8EncryptedPrivateKeyInfoBuilder
的用法示例。
在下文中一共展示了PKCS8EncryptedPrivateKeyInfoBuilder.build方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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()));
}
示例3: 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()));
}
示例4: 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()));
}