RC2CBCParameter.java
资源名称:security.rar [点击查看]
上传用户:lior1029
上传日期:2013-05-07
资源大小:209k
文件大小:2k
源码类别:
CA认证
开发平台:
Java
- package org.bouncycastle.asn1.pkcs;
- import java.math.BigInteger;
- import org.bouncycastle.asn1.*;
- public class RC2CBCParameter
- implements DEREncodable
- {
- DERInteger version;
- ASN1OctetString iv;
- public static RC2CBCParameter getInstance(
- Object o)
- {
- if (o instanceof ASN1Sequence)
- {
- return new RC2CBCParameter((ASN1Sequence)o);
- }
- throw new IllegalArgumentException("unknown object in RC2CBCParameter factory");
- }
- public RC2CBCParameter(
- byte[] iv)
- {
- this.version = null;
- this.iv = new DEROctetString(iv);
- }
- public RC2CBCParameter(
- int parameterVersion,
- byte[] iv)
- {
- this.version = new DERInteger(parameterVersion);
- this.iv = new DEROctetString(iv);
- }
- public RC2CBCParameter(
- ASN1Sequence seq)
- {
- if (seq.size() == 1)
- {
- version = null;
- iv = (ASN1OctetString)seq.getObjectAt(0);
- }
- else
- {
- version = (DERInteger)seq.getObjectAt(0);
- iv = (ASN1OctetString)seq.getObjectAt(1);
- }
- }
- public BigInteger getRC2ParameterVersion()
- {
- if (version == null)
- {
- return null;
- }
- return version.getValue();
- }
- public byte[] getIV()
- {
- return iv.getOctets();
- }
- public DERObject getDERObject()
- {
- ASN1EncodableVector v = new ASN1EncodableVector();
- if (version != null)
- {
- v.add(version);
- }
- v.add(iv);
- return new DERSequence(v);
- }
- }