01: package org.bouncycastle.asn1.pkcs;
02:
03: import java.util.Enumeration;
04:
05: import org.bouncycastle.asn1.ASN1Encodable;
06: import org.bouncycastle.asn1.ASN1EncodableVector;
07: import org.bouncycastle.asn1.ASN1Sequence;
08: import org.bouncycastle.asn1.DERObject;
09: import org.bouncycastle.asn1.DERSequence;
10:
11: public class PBES2Parameters extends ASN1Encodable implements
12: PKCSObjectIdentifiers {
13: private KeyDerivationFunc func;
14: private EncryptionScheme scheme;
15:
16: public PBES2Parameters(ASN1Sequence obj) {
17: Enumeration e = obj.getObjects();
18: ASN1Sequence funcSeq = (ASN1Sequence) e.nextElement();
19:
20: if (funcSeq.getObjectAt(0).equals(id_PBKDF2)) {
21: func = new KeyDerivationFunc(id_PBKDF2, PBKDF2Params
22: .getInstance(funcSeq.getObjectAt(1)));
23: } else {
24: func = new KeyDerivationFunc(funcSeq);
25: }
26:
27: scheme = new EncryptionScheme((ASN1Sequence) e.nextElement());
28: }
29:
30: public KeyDerivationFunc getKeyDerivationFunc() {
31: return func;
32: }
33:
34: public EncryptionScheme getEncryptionScheme() {
35: return scheme;
36: }
37:
38: public DERObject toASN1Object() {
39: ASN1EncodableVector v = new ASN1EncodableVector();
40:
41: v.add(func);
42: v.add(scheme);
43:
44: return new DERSequence(v);
45: }
46: }
|