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

CA认证

开发平台:

Java

  1. package org.bouncycastle.asn1.misc;
  2. import org.bouncycastle.asn1.*;
  3. public class IDEACBCPar
  4.     implements DEREncodable
  5. {
  6.     ASN1OctetString  iv;
  7.     public static IDEACBCPar getInstance(
  8.         Object  o)
  9.     {
  10.         if (o instanceof IDEACBCPar)
  11.         {
  12.             return (IDEACBCPar)o;
  13.         }
  14.         else if (o instanceof ASN1Sequence)
  15.         {
  16.             return new IDEACBCPar((ASN1Sequence)o);
  17.         }
  18.         throw new IllegalArgumentException("unknown object in IDEACBCPar factory");
  19.     }
  20.     public IDEACBCPar(
  21.         byte[]  iv)
  22.     {
  23.         this.iv = new DEROctetString(iv);
  24.     }
  25.     public IDEACBCPar(
  26.         ASN1Sequence  seq)
  27.     {
  28.         if (seq.size() == 1)
  29.         {
  30.             iv = (ASN1OctetString)seq.getObjectAt(0);
  31.         }
  32.         else
  33.         {
  34.             iv = null;
  35.         }
  36.     }
  37.     public byte[] getIV()
  38.     {
  39.         if (iv != null)
  40.         {
  41.             return iv.getOctets();
  42.         }
  43.         else
  44.         {
  45.             return null;
  46.         }
  47.     }
  48.     /**
  49.      * <pre>
  50.      * IDEA-CBCPar ::= SEQUENCE {
  51.      *                      iv    OCTET STRING OPTIONAL -- exactly 8 octets
  52.      *                  }
  53.      * </pre>
  54.      */
  55.     public DERObject getDERObject()
  56.     {
  57.         ASN1EncodableVector  v = new ASN1EncodableVector();
  58.         if (iv != null)
  59.         {
  60.             v.add(iv);
  61.         }
  62.         return new DERSequence(v);
  63.     }
  64. }