01: package org.bouncycastle.asn1.cryptopro;
02:
03: import org.bouncycastle.asn1.ASN1Encodable;
04: import org.bouncycastle.asn1.ASN1EncodableVector;
05: import org.bouncycastle.asn1.ASN1Sequence;
06: import org.bouncycastle.asn1.ASN1TaggedObject;
07: import org.bouncycastle.asn1.DERObject;
08: import org.bouncycastle.asn1.DERObjectIdentifier;
09: import org.bouncycastle.asn1.DERSequence;
10:
11: public class GOST3410PublicKeyAlgParameters extends ASN1Encodable {
12: private DERObjectIdentifier publicKeyParamSet;
13: private DERObjectIdentifier digestParamSet;
14: private DERObjectIdentifier encryptionParamSet;
15:
16: public static GOST3410PublicKeyAlgParameters getInstance(
17: ASN1TaggedObject obj, boolean explicit) {
18: return getInstance(ASN1Sequence.getInstance(obj, explicit));
19: }
20:
21: public static GOST3410PublicKeyAlgParameters getInstance(Object obj) {
22: if (obj == null
23: || obj instanceof GOST3410PublicKeyAlgParameters) {
24: return (GOST3410PublicKeyAlgParameters) obj;
25: }
26:
27: if (obj instanceof ASN1Sequence) {
28: return new GOST3410PublicKeyAlgParameters(
29: (ASN1Sequence) obj);
30: }
31:
32: throw new IllegalArgumentException(
33: "Invalid GOST3410Parameter: "
34: + obj.getClass().getName());
35: }
36:
37: public GOST3410PublicKeyAlgParameters(
38: DERObjectIdentifier publicKeyParamSet,
39: DERObjectIdentifier digestParamSet) {
40: this .publicKeyParamSet = publicKeyParamSet;
41: this .digestParamSet = digestParamSet;
42: this .encryptionParamSet = null;
43: }
44:
45: public GOST3410PublicKeyAlgParameters(
46: DERObjectIdentifier publicKeyParamSet,
47: DERObjectIdentifier digestParamSet,
48: DERObjectIdentifier encryptionParamSet) {
49: this .publicKeyParamSet = publicKeyParamSet;
50: this .digestParamSet = digestParamSet;
51: this .encryptionParamSet = encryptionParamSet;
52: }
53:
54: public GOST3410PublicKeyAlgParameters(ASN1Sequence seq) {
55: this .publicKeyParamSet = (DERObjectIdentifier) seq
56: .getObjectAt(0);
57: this .digestParamSet = (DERObjectIdentifier) seq.getObjectAt(1);
58:
59: if (seq.size() > 2) {
60: this .encryptionParamSet = (DERObjectIdentifier) seq
61: .getObjectAt(2);
62: }
63: }
64:
65: public DERObjectIdentifier getPublicKeyParamSet() {
66: return publicKeyParamSet;
67: }
68:
69: public DERObjectIdentifier getDigestParamSet() {
70: return digestParamSet;
71: }
72:
73: public DERObjectIdentifier getEncryptionParamSet() {
74: return encryptionParamSet;
75: }
76:
77: public DERObject toASN1Object() {
78: ASN1EncodableVector v = new ASN1EncodableVector();
79:
80: v.add(publicKeyParamSet);
81: v.add(digestParamSet);
82:
83: if (encryptionParamSet != null) {
84: v.add(encryptionParamSet);
85: }
86:
87: return new DERSequence(v);
88: }
89: }
|