public static EncryptedPrivateKeyInfo getInstance( Object obj) { if (obj instanceof EncryptedPrivateKeyInfo) { return (EncryptedPrivateKeyInfo)obj; } else if (obj != null) { return new EncryptedPrivateKeyInfo(ASN1Sequence.getInstance(obj)); } return null; }
public static EncryptedPrivateKeyInfo getInstance( Object obj) { if (obj instanceof EncryptedData) { return (EncryptedPrivateKeyInfo)obj; } else if (obj != null) { return new EncryptedPrivateKeyInfo(ASN1Sequence.getInstance(obj)); } return null; }
public PKCS8EncryptedPrivateKeyInfo build( OutputEncryptor encryptor) { try { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); OutputStream cOut = encryptor.getOutputStream(bOut); cOut.write(privateKeyInfo.getEncoded()); cOut.close(); return new PKCS8EncryptedPrivateKeyInfo(new EncryptedPrivateKeyInfo(encryptor.getAlgorithmIdentifier(), bOut.toByteArray())); } catch (IOException e) { throw new IllegalStateException("cannot encode privateKeyInfo"); } } }
public PKCS8EncryptedPrivateKeyInfo build( OutputEncryptor encryptor) { try { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); OutputStream cOut = encryptor.getOutputStream(bOut); cOut.write(privateKeyInfo.getEncoded()); cOut.close(); return new PKCS8EncryptedPrivateKeyInfo(new EncryptedPrivateKeyInfo(encryptor.getAlgorithmIdentifier(), bOut.toByteArray())); } catch (IOException e) { throw new IllegalStateException("cannot encode privateKeyInfo"); } } }
private PemObject generate(PrivateKeyInfo key, OutputEncryptor encryptor) throws PemGenerationException { try { byte[] keyData = key.getEncoded(); if (encryptor == null) { return new PemObject("PRIVATE KEY", keyData); } ByteArrayOutputStream bOut = new ByteArrayOutputStream(); OutputStream cOut = encryptor.getOutputStream(bOut); cOut.write(key.getEncoded()); cOut.close(); EncryptedPrivateKeyInfo info = new EncryptedPrivateKeyInfo(encryptor.getAlgorithmIdentifier(), bOut.toByteArray()); return new PemObject("ENCRYPTED PRIVATE KEY", info.getEncoded()); } catch (IOException e) { throw new PemGenerationException("unable to process encoded key data: " + e.getMessage(), e); } } }
private PemObject generate(PrivateKeyInfo key, OutputEncryptor encryptor) throws PemGenerationException { try { byte[] keyData = key.getEncoded(); if (encryptor == null) { return new PemObject("PRIVATE KEY", keyData); } ByteArrayOutputStream bOut = new ByteArrayOutputStream(); OutputStream cOut = encryptor.getOutputStream(bOut); cOut.write(key.getEncoded()); cOut.close(); EncryptedPrivateKeyInfo info = new EncryptedPrivateKeyInfo(encryptor.getAlgorithmIdentifier(), bOut.toByteArray()); return new PemObject("ENCRYPTED PRIVATE KEY", info.getEncoded()); } catch (IOException e) { throw new PemGenerationException("unable to process encoded key data: " + e.getMessage(), e); } } }
EncryptedPrivateKeyInfo keyInfo = new EncryptedPrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.id_PBES2, pbeParams), encryptedKey);
byte[] kBytes = wrapKey(keyAlgorithm.getId(), privKey, kParams, password); AlgorithmIdentifier kAlgId = new AlgorithmIdentifier(keyAlgorithm, kParams.toASN1Primitive()); org.spongycastle.asn1.pkcs.EncryptedPrivateKeyInfo kInfo = new org.spongycastle.asn1.pkcs.EncryptedPrivateKeyInfo(kAlgId, kBytes); boolean attrSet = false; ASN1EncodableVector kName = new ASN1EncodableVector();
byte[] kBytes = wrapKey(keyAlgorithm.getId(), privKey, kParams, password); AlgorithmIdentifier kAlgId = new AlgorithmIdentifier(keyAlgorithm, kParams.toASN1Primitive()); org.spongycastle.asn1.pkcs.EncryptedPrivateKeyInfo kInfo = new org.spongycastle.asn1.pkcs.EncryptedPrivateKeyInfo(kAlgId, kBytes); boolean attrSet = false; ASN1EncodableVector kName = new ASN1EncodableVector();