EncryptedPrivateKeyInfo.java
上传用户:lior1029
上传日期:2013-05-07
资源大小:209k
文件大小:1k
源码类别:

CA认证

开发平台:

Java

  1. package org.bouncycastle.asn1.pkcs;
  2. import java.io.*;
  3. import java.util.Enumeration;
  4. import java.math.BigInteger;
  5. import org.bouncycastle.asn1.*;
  6. import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
  7. public class EncryptedPrivateKeyInfo
  8.     implements PKCSObjectIdentifiers, DEREncodable
  9. {
  10.     private AlgorithmIdentifier algId;
  11.     private ASN1OctetString     data;
  12.     public EncryptedPrivateKeyInfo(
  13.         ASN1Sequence  seq)
  14.     {
  15.         Enumeration e = seq.getObjects();
  16.         algId = new AlgorithmIdentifier((ASN1Sequence)e.nextElement());
  17.         data = (ASN1OctetString)e.nextElement();
  18.     }
  19.     public EncryptedPrivateKeyInfo(
  20.         AlgorithmIdentifier algId,
  21.         byte[]              encoding)
  22.     {
  23.         this.algId = algId;
  24.         this.data = new DEROctetString(encoding);
  25.     }
  26.     public AlgorithmIdentifier getEncryptionAlgorithm()
  27.     {
  28.         return algId;
  29.     }
  30.     public byte[] getEncryptedData()
  31.     {
  32.         return data.getOctets();
  33.     }
  34.     /**
  35.      * EncryptedPrivateKeyInfo ::= SEQUENCE {
  36.      *      encryptionAlgorithm AlgorithmIdentifier {{KeyEncryptionAlgorithms}},
  37.      *      encryptedData EncryptedData
  38.      * }
  39.      *
  40.      * EncryptedData ::= OCTET STRING
  41.      *
  42.      * KeyEncryptionAlgorithms ALGORITHM-IDENTIFIER ::= {
  43.      *          ... -- For local profiles
  44.      * }
  45.      */
  46.     public DERObject getDERObject()
  47.     {
  48.         ASN1EncodableVector v = new ASN1EncodableVector();
  49.         v.add(algId);
  50.         v.add(data);
  51.         return new DERSequence(v);
  52.     }
  53. }