1 package org.bouncycastle.asn1.x509;
3 import java.util.Enumeration;
5 import org.bouncycastle.asn1.*;
9 * DigestInfo::=SEQUENCE{
10 * digestAlgorithm AlgorithmIdentifier,
11 * digest OCTET STRING }
14 public class DigestInfo
15 implements DEREncodable
17 private byte[] digest;
18 private AlgorithmIdentifier algId;
20 public static DigestInfo getInstance(
24 return getInstance(ASN1Sequence.getInstance(obj, explicit));
27 public static DigestInfo getInstance(
30 if (obj instanceof DigestInfo)
32 return (DigestInfo)obj;
34 else if (obj instanceof ASN1Sequence)
36 return new DigestInfo((ASN1Sequence)obj);
39 throw new IllegalArgumentException("unknown object in factory");
43 AlgorithmIdentifier algId,
53 Enumeration e = obj.getObjects();
55 algId = AlgorithmIdentifier.getInstance(e.nextElement());
56 digest = ((ASN1OctetString)e.nextElement()).getOctets();
59 public AlgorithmIdentifier getAlgorithmId()
64 public byte[] getDigest()
69 public DERObject getDERObject()
71 DEREncodableVector v = new DEREncodableVector();
74 v.add(new DEROctetString(digest));
76 return new DERSequence(v);