1 package org.bouncycastle.asn1.x509;
3 import java.util.Enumeration;
5 import org.bouncycastle.asn1.*;
6 import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
10 * DigestInfo::=SEQUENCE{
11 * digestAlgorithm AlgorithmIdentifier,
12 * digest OCTET STRING }
15 public class DigestInfo
16 implements DEREncodable
18 private byte[] digest;
19 private AlgorithmIdentifier algId;
21 public static DigestInfo getInstance(
25 return getInstance(ASN1Sequence.getInstance(obj, explicit));
28 public static DigestInfo getInstance(
31 if (obj instanceof DigestInfo)
33 return (DigestInfo)obj;
35 else if (obj instanceof ASN1Sequence)
37 return new DigestInfo((ASN1Sequence)obj);
40 throw new IllegalArgumentException("unknown object in factory");
44 AlgorithmIdentifier algId,
54 Enumeration e = obj.getObjects();
56 algId = AlgorithmIdentifier.getInstance(e.nextElement());
57 digest = ((ASN1OctetString)e.nextElement()).getOctets();
60 public AlgorithmIdentifier getAlgorithmId()
65 public byte[] getDigest()
70 public DERObject getDERObject()
72 DEREncodableVector v = new DEREncodableVector();
75 v.add(new DEROctetString(digest));
77 return new DERSequence(v);