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

CA认证

开发平台:

Java

  1. package org.bouncycastle.asn1.pkcs;
  2. import java.math.BigInteger;
  3. import org.bouncycastle.asn1.*;
  4. public class PKCS12PBEParams
  5.     implements DEREncodable
  6. {
  7.     DERInteger      iterations;
  8.     ASN1OctetString iv;
  9.     public PKCS12PBEParams(
  10.         byte[]      salt,
  11.         int         iterations)
  12.     {
  13.         this.iv = new DEROctetString(salt);
  14.         this.iterations = new DERInteger(iterations);
  15.     }
  16.     public PKCS12PBEParams(
  17.         ASN1Sequence  seq)
  18.     {
  19.         iv = (ASN1OctetString)seq.getObjectAt(0);
  20.         iterations = (DERInteger)seq.getObjectAt(1);
  21.     }
  22.     public static PKCS12PBEParams getInstance(
  23.         Object  obj)
  24.     {
  25.         if (obj instanceof PKCS12PBEParams)
  26.         {
  27.             return (PKCS12PBEParams)obj;
  28.         }
  29.         else if (obj instanceof ASN1Sequence)
  30.         {
  31.             return new PKCS12PBEParams((ASN1Sequence)obj);
  32.         }
  33.         throw new IllegalArgumentException("unknown object in factory");
  34.     }
  35.     public BigInteger getIterations()
  36.     {
  37.         return iterations.getValue();
  38.     }
  39.     public byte[] getIV()
  40.     {
  41.         return iv.getOctets();
  42.     }
  43.     public DERObject getDERObject()
  44.     {
  45.         ASN1EncodableVector  v = new ASN1EncodableVector();
  46.         v.add(iv);
  47.         v.add(iterations);
  48.         return new DERSequence(v);
  49.     }
  50. }