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


Java PKCS8EncryptedPrivateKeyInfoBuilder.build方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:xipki,项目名称:xitk,代码行数:10,代码来源:PrivateKeyCryptor.java

示例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()));
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:15,代码来源:PfxPduTest.java

示例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()));
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:15,代码来源:PfxPduTest.java

示例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()));
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:15,代码来源:PfxPduTest.java


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