1 20 package com.novosec.pkix.asn1.crmf; 21 22 import org.bouncycastle.asn1.ASN1EncodableVector; 23 import org.bouncycastle.asn1.ASN1Sequence; 24 import org.bouncycastle.asn1.ASN1TaggedObject; 25 import org.bouncycastle.asn1.DEREncodable; 26 import org.bouncycastle.asn1.DERInteger; 27 import org.bouncycastle.asn1.DERObject; 28 import org.bouncycastle.asn1.DEROctetString; 29 import org.bouncycastle.asn1.DERSequence; 30 import org.bouncycastle.asn1.x509.AlgorithmIdentifier; 31 32 45 public class PBMParameter implements DEREncodable 46 { 47 DEROctetString salt; 48 AlgorithmIdentifier owf; 49 DERInteger iterationCount; 50 AlgorithmIdentifier mac; 51 52 public static PBMParameter getInstance( ASN1TaggedObject obj, boolean explicit ) 53 { 54 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 55 } 56 57 public static PBMParameter getInstance( Object obj ) 58 { 59 if (obj instanceof PBMParameter) 60 { 61 return (PBMParameter)obj; 62 } 63 else if (obj instanceof ASN1Sequence) 64 { 65 return new PBMParameter((ASN1Sequence)obj); 66 } 67 68 throw new IllegalArgumentException ("unknown object in factory"); 69 } 70 71 public PBMParameter( ASN1Sequence seq ) 72 { 73 this.salt = (DEROctetString)seq.getObjectAt(0); 74 this.owf = AlgorithmIdentifier.getInstance(seq.getObjectAt(1)); 75 this.iterationCount = DERInteger.getInstance(seq.getObjectAt(2)); 76 this.mac = AlgorithmIdentifier.getInstance(seq.getObjectAt(3)); 77 } 78 79 public PBMParameter( DEROctetString salt, AlgorithmIdentifier owf, DERInteger iterationCount, AlgorithmIdentifier mac ) 80 { 81 this.salt = salt; 82 this.owf = owf; 83 this.iterationCount = iterationCount; 84 this.mac = mac; 85 } 86 87 public DEROctetString getSalt() 88 { 89 return salt; 90 } 91 92 public AlgorithmIdentifier getOwf() 93 { 94 return owf; 95 } 96 97 public DERInteger getIterationCount() 98 { 99 return iterationCount; 100 } 101 102 public AlgorithmIdentifier getMac() 103 { 104 return mac; 105 } 106 107 public DERObject getDERObject() 108 { 109 ASN1EncodableVector v = new ASN1EncodableVector(); 110 111 v.add( salt ); 112 v.add( owf ); 113 v.add( iterationCount ); 114 v.add( mac ); 115 116 return new DERSequence(v); 117 } 118 119 public String toString() 120 { 121 return "PBMParameter: (salt = " + this.getSalt() + ", " + 122 "owf = " + this.getOwf() + ", " + 123 "iterationCount = " + this.getIterationCount() + ", " + 124 "mac = " + this.getMac() + ")"; 125 } 126 } 127 | Popular Tags |