01: package org.bouncycastle.asn1.pkcs;
02:
03: import java.util.Enumeration;
04:
05: import org.bouncycastle.asn1.ASN1EncodableVector;
06: import org.bouncycastle.asn1.ASN1Sequence;
07: import org.bouncycastle.asn1.DERObject;
08: import org.bouncycastle.asn1.DERObjectIdentifier;
09: import org.bouncycastle.asn1.DERSequence;
10: import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
11:
12: /**
13: * @deprecated - use AlgorithmIdentifier and PBES2Parameters
14: */
15: public class PBES2Algorithms extends AlgorithmIdentifier implements
16: PKCSObjectIdentifiers {
17: private DERObjectIdentifier objectId;
18: private KeyDerivationFunc func;
19: private EncryptionScheme scheme;
20:
21: public PBES2Algorithms(ASN1Sequence obj) {
22: super (obj);
23:
24: Enumeration e = obj.getObjects();
25:
26: objectId = (DERObjectIdentifier) e.nextElement();
27:
28: ASN1Sequence seq = (ASN1Sequence) e.nextElement();
29:
30: e = seq.getObjects();
31:
32: ASN1Sequence funcSeq = (ASN1Sequence) e.nextElement();
33:
34: if (funcSeq.getObjectAt(0).equals(id_PBKDF2)) {
35: func = new KeyDerivationFunc(id_PBKDF2, PBKDF2Params
36: .getInstance(funcSeq.getObjectAt(1)));
37: } else {
38: func = new KeyDerivationFunc(funcSeq);
39: }
40:
41: scheme = new EncryptionScheme((ASN1Sequence) e.nextElement());
42: }
43:
44: public DERObjectIdentifier getObjectId() {
45: return objectId;
46: }
47:
48: public KeyDerivationFunc getKeyDerivationFunc() {
49: return func;
50: }
51:
52: public EncryptionScheme getEncryptionScheme() {
53: return scheme;
54: }
55:
56: public DERObject getDERObject() {
57: ASN1EncodableVector v = new ASN1EncodableVector();
58: ASN1EncodableVector subV = new ASN1EncodableVector();
59:
60: v.add(objectId);
61:
62: subV.add(func);
63: subV.add(scheme);
64: v.add(new DERSequence(subV));
65:
66: return new DERSequence(v);
67: }
68: }
|