01: package org.bouncycastle.asn1.cmp;
02:
03: import org.bouncycastle.asn1.ASN1Encodable;
04: import org.bouncycastle.asn1.ASN1EncodableVector;
05: import org.bouncycastle.asn1.ASN1OctetString;
06: import org.bouncycastle.asn1.ASN1Sequence;
07: import org.bouncycastle.asn1.DERInteger;
08: import org.bouncycastle.asn1.DERObject;
09: import org.bouncycastle.asn1.DERSequence;
10: import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
11:
12: public class PBMParameter extends ASN1Encodable {
13: private ASN1OctetString salt;
14: private AlgorithmIdentifier owf;
15: private DERInteger iterationCount;
16: private AlgorithmIdentifier mac;
17:
18: private PBMParameter(ASN1Sequence seq) {
19: salt = ASN1OctetString.getInstance(seq.getObjectAt(0));
20: owf = AlgorithmIdentifier.getInstance(seq.getObjectAt(1));
21: iterationCount = DERInteger.getInstance(seq.getObjectAt(2));
22: mac = AlgorithmIdentifier.getInstance(seq.getObjectAt(3));
23: }
24:
25: public static PBMParameter getInstance(Object o) {
26: if (o instanceof PBMParameter) {
27: return (PBMParameter) o;
28: }
29:
30: if (o instanceof ASN1Sequence) {
31: return new PBMParameter((ASN1Sequence) o);
32: }
33:
34: throw new IllegalArgumentException("Invalid object: "
35: + o.getClass().getName());
36: }
37:
38: public AlgorithmIdentifier getOwf() {
39: return owf;
40: }
41:
42: public DERInteger getIterationCount() {
43: return iterationCount;
44: }
45:
46: public AlgorithmIdentifier getMac() {
47: return mac;
48: }
49:
50: /**
51: * <pre>
52: * PBMParameter ::= SEQUENCE {
53: * salt OCTET STRING,
54: * -- note: implementations MAY wish to limit acceptable sizes
55: * -- of this string to values appropriate for their environment
56: * -- in order to reduce the risk of denial-of-service attacks
57: * owf AlgorithmIdentifier,
58: * -- AlgId for a One-Way Function (SHA-1 recommended)
59: * iterationCount INTEGER,
60: * -- number of times the OWF is applied
61: * -- note: implementations MAY wish to limit acceptable sizes
62: * -- of this integer to values appropriate for their environment
63: * -- in order to reduce the risk of denial-of-service attacks
64: * mac AlgorithmIdentifier
65: * -- the MAC AlgId (e.g., DES-MAC, Triple-DES-MAC [PKCS11],
66: * } -- or HMAC [RFC2104, RFC2202])
67: * </pre>
68: * @return a basic ASN.1 object representation.
69: */
70: public DERObject toASN1Object() {
71: ASN1EncodableVector v = new ASN1EncodableVector();
72:
73: v.add(salt);
74: v.add(owf);
75: v.add(iterationCount);
76: v.add(mac);
77:
78: return new DERSequence(v);
79: }
80: }
|