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

CA认证

开发平台:

Java

  1. package org.bouncycastle.asn1.misc;
  2. import org.bouncycastle.asn1.*;
  3. public class CAST5CBCParameters
  4.     implements DEREncodable
  5. {
  6.     DERInteger      keyLength;
  7.     ASN1OctetString iv;
  8.     public static CAST5CBCParameters getInstance(
  9.         Object  o)
  10.     {
  11.         if (o instanceof CAST5CBCParameters)
  12.         {
  13.             return (CAST5CBCParameters)o;
  14.         }
  15.         else if (o instanceof ASN1Sequence)
  16.         {
  17.             return new CAST5CBCParameters((ASN1Sequence)o);
  18.         }
  19.         throw new IllegalArgumentException("unknown object in CAST5CBCParameter factory");
  20.     }
  21.     public CAST5CBCParameters(
  22.         byte[]  iv,
  23.         int     keyLength)
  24.     {
  25.         this.iv = new DEROctetString(iv);
  26.         this.keyLength = new DERInteger(keyLength);
  27.     }
  28.     public CAST5CBCParameters(
  29.         ASN1Sequence  seq)
  30.     {
  31.         iv = (ASN1OctetString)seq.getObjectAt(0);
  32.         keyLength = (DERInteger)seq.getObjectAt(1);
  33.     }
  34.     public byte[] getIV()
  35.     {
  36.         return iv.getOctets();
  37.     }
  38.     public int getKeyLength()
  39.     {
  40.         return keyLength.getValue().intValue();
  41.     }
  42.     /**
  43.      * <pre>
  44.      * cast5CBCParameters ::= SEQUENCE {
  45.      *                           iv         OCTET STRING DEFAULT 0,
  46.      *                                  -- Initialization vector
  47.      *                           keyLength  INTEGER
  48.      *                                  -- Key length, in bits
  49.      *                      }
  50.      * </pre>
  51.      */
  52.     public DERObject getDERObject()
  53.     {
  54.         ASN1EncodableVector  v = new ASN1EncodableVector();
  55.         v.add(iv);
  56.         v.add(keyLength);
  57.         return new DERSequence(v);
  58.     }
  59. }