コード例 #1
0
  public PrivateKeyInfo decryptPrivateKeyInfo(InputDecryptorProvider inputDecryptorProvider)
      throws PKCSException {
    try {
      InputDecryptor decrytor =
          inputDecryptorProvider.get(encryptedPrivateKeyInfo.getEncryptionAlgorithm());

      ByteArrayInputStream encIn =
          new ByteArrayInputStream(encryptedPrivateKeyInfo.getEncryptedData());

      return PrivateKeyInfo.getInstance(Streams.readAll(decrytor.getInputStream(encIn)));
    } catch (Exception e) {
      throw new PKCSException("unable to read encrypted data: " + e.getMessage(), e);
    }
  }
コード例 #2
0
 /**
  * Reads in an EncryptedPrivateKeyInfo
  *
  * @return the X509Certificate
  * @throws java.io.IOException if an I/O error occured
  */
 public Object parseObject(PemObject obj) throws IOException {
   try {
     return new PKCS8EncryptedPrivateKeyInfo(
         EncryptedPrivateKeyInfo.getInstance(obj.getContent()));
   } catch (Exception e) {
     throw new PEMException("problem parsing ENCRYPTED PRIVATE KEY: " + e.toString(), e);
   }
 }
コード例 #3
0
 private static EncryptedPrivateKeyInfo parseBytes(byte[] pkcs8Encoding) throws IOException {
   try {
     return EncryptedPrivateKeyInfo.getInstance(ASN1Primitive.fromByteArray(pkcs8Encoding));
   } catch (ClassCastException e) {
     throw new CertIOException("malformed data: " + e.getMessage(), e);
   } catch (IllegalArgumentException e) {
     throw new CertIOException("malformed data: " + e.getMessage(), e);
   }
 }
コード例 #4
0
 public byte[] getEncoded() throws IOException {
   return encryptedPrivateKeyInfo.getEncoded();
 }