public abstract class AbstractAtsHashIndex
extends iaik.asn1.structures.AttributeValue
ats-hash-index
attribute and
its successor, the ats-hash-index-v3
attribute. It implements all
functionality, that these attributes have in common.
An ats-hash-index includes references to all essential components for a signature verification
(certificates, revocation information, signature timestamps, etc.) and is part of an archive
timestamp ( ArchiveTimeStampv3
).
An ats-hash-index identifies all components that are protected by an archival timestamp. These
components shall then be used for verifying the signature, the archive timestamp has been applied
to. Only the components identified by an ats-hash-index are considered to be trusted.
An example code to identify the protected components may look like this:
CadesSignatureStream cadesSig = new CadesSignatureStream(in, data);
SignerInfo signerInfo = cadesSig.getSignerInfos()[signerInfoIndex];
ArchiveTimeStamp[] archiveTsps = cadesSig.getArchiveTimeStamps(signerInfoIndex);
for (ArchiveTimeStamp archiveTimestamp : archiveTsps) {
archiveTimestamp.verifyTimestampToken(null);
AbstractAtsHashIndex atsHashIndex = archiveTimestamp.getAtsHashIndex();
Certificate[] indexedCertificates = atsHashIndex.getIndexedCertificates(cadesSig);
X509CRL[] indexedCrls = atsHashIndex.getIndexedCrls(cadesSig);
BasicOCSPResponse[] indexedOcspResponses = atsHashIndex.getIndexedOcspResponses(cadesSig);
Attribute[] indexedUnsignedAttrs;
AttributeValue[] indexedUnsignedAttrValues;
if(atsHashIndex instanceof AtsHashIndex)
indexedUnsignedAttrs = (AtsHashIndex)atsHashIndex.getIndexedUnsignedAttributes(signerInfo);
else if(atsHashIndex instanceof AtsHashIndexv3)
indexedUnsignedAttrValues = atsHashIndex.getIndexedUnsignedAttrValues(signerInfo);
}
Modifier and Type | Field and Description |
---|---|
static iaik.asn1.structures.AlgorithmID |
DEFAULTHASHALGORITHM
Default digest algorithm SHA-256, used to calculate the digest values of all included
components (certificates, revocation information, signature timestamps) if no other algorithm
is specified.
|
Modifier and Type | Method and Description |
---|---|
void |
addCertificate(iaik.cms.CertificateChoices certificate)
Calculate and add the certificate's hash.
|
void |
addCertificateHash(byte[] certHash)
Add a certificate's hash value to be included in this ats-hash-index attribute.
|
void |
addRevocatioInfo(iaik.cms.RevocationInfoChoice revocationInfo)
Calculate and add the revocation info's hash.
|
void |
addRevocationInfoHash(byte[] revocationInfoHash)
Add a revocation info (CRL or OCSP response) hash value to be included in this ats-hash-index
attribute.
|
boolean |
containsCertificateHash(byte[] certificateHash)
Returns true if the given certificate hash is included in this ats-hash-index.
|
boolean |
containsReferencesWithoutOriginalValues(AbstractCadesSignature archivedSignature,
iaik.cms.SignerInfo archivedSignerInfo)
Checks whether this ats-hash-index contains any references, for which no corresponding
objects (certificates, revocation infos, unsigned attributes) can be found in the given
signature.
|
boolean |
containsRevocationInfoHash(byte[] revocationInfoHash)
Returns true if the given revocation info hash (of a CRL or OCSP response) is included in this
ats-hash-index.
|
void |
decode(iaik.asn1.ASN1Object obj)
Decodes the given ASN.1 ats-hash-index object
|
boolean |
equals(java.lang.Object obj)
Compares this
ats-hash-index to the specified object. |
abstract iaik.asn1.ObjectID |
getAttributeType() |
java.util.Vector<byte[]> |
getCertificateHashes()
Returns all included certificate hashes.
|
java.util.ArrayList<byte[]> |
getCertificateReferencesWithoutOriginalValues(AbstractCadesSignature archivedSignature)
Returns all certificate references (certificate hashes) included in this ats-hash-index, for
which no corresponding certificates can be found in the given signature.
|
java.security.cert.Certificate[] |
getIndexedCertificates(AbstractCadesSignature archivedSignature)
Returns all certificates included in the given signature, whose hash values are contained in
this ats-hash-index.
|
iaik.x509.X509CRL[] |
getIndexedCrls(AbstractCadesSignature archivedSignature)
Returns all CRLs included in the given signature, whose hash values are contained in this
ats-hash-index.
|
byte[][] |
getIndexedEncodedCrls(AbstractCadesSignature archivedSignature)
Returns the encodings of all CRLs included in the given signature, whose hash values are
contained in this ats-hash-index.
|
iaik.x509.ocsp.BasicOCSPResponse[] |
getIndexedOcspResponses(AbstractCadesSignature archivedSignature)
Returns all OCSP responses included in the given signature, whose hash values are contained in
this ats-hash-index.
|
java.security.cert.CRL[] |
getIndexedOtherRevocationInfos(AbstractCadesSignature archivedSignature)
Returns all revocation infos included in the given signature, that are not of type CRL or OCSP
response and whose hash values are contained in this ats-hash-index.
|
java.util.Vector<byte[]> |
getRevocationInfoHashes()
Returns all included revocation information (CRL and/or OCSP responses) hashes.
|
java.util.ArrayList<byte[]> |
getRevocationInfoReferencesWithoutOriginalValues(AbstractCadesSignature archivedSignature)
Returns all revocation info references (revocation info hashes) included in this
ats-hash-index, for which no corresponding revocation info object can be found in the given
signature.
|
abstract boolean |
multipleAllowed() |
iaik.asn1.ASN1Object |
toASN1Object()
Returns this ats-hash-index as ASN1Object.
|
java.lang.String |
toString() |
public static final iaik.asn1.structures.AlgorithmID DEFAULTHASHALGORITHM
public void addCertificate(iaik.cms.CertificateChoices certificate) throws iaik.asn1.CodingException
certificate
- certificate of which to calculate and include the hashiaik.asn1.CodingException
- if the certificate could not be encoded for hash calculationpublic void addRevocatioInfo(iaik.cms.RevocationInfoChoice revocationInfo) throws iaik.asn1.CodingException
revocationInfo
- revocation information (CRL or OCSP response) of which to calculate and include the
hashiaik.asn1.CodingException
- if the revocation information could not be encoded for hash calculationpublic java.security.cert.Certificate[] getIndexedCertificates(AbstractCadesSignature archivedSignature) throws iaik.asn1.CodingException
archivedSignature
- the signature (CadesSignature or CadesSignatureStream) that was archived by the
corresponding archive timestampiaik.asn1.CodingException
- if the certificates could not be encoded for hash calculationpublic java.util.ArrayList<byte[]> getCertificateReferencesWithoutOriginalValues(AbstractCadesSignature archivedSignature) throws iaik.asn1.CodingException
archivedSignature
- the signature containing the certificates to match against the certificate hashes of
this ats-hash-indexiaik.asn1.CodingException
- if a certificate of the given signature can't be encoded for the hash calculationpublic iaik.x509.X509CRL[] getIndexedCrls(AbstractCadesSignature archivedSignature) throws iaik.asn1.CodingException, CmsCadesException
archivedSignature
- the signature (CadesSignature or CadesSignatureStream) that was archived by the
corresponding archive timestampiaik.asn1.CodingException
- if the CRLs can't be encoded for hash calculationCmsCadesException
- if the included CRLs can't be parsedpublic byte[][] getIndexedEncodedCrls(AbstractCadesSignature archivedSignature) throws iaik.asn1.CodingException, CmsCadesException
archivedSignature
- the signature (CadesSignature or CadesSignatureStream) that was archived by the
corresponding archive timestampiaik.asn1.CodingException
- if the CRLs can't be encoded for hash calculationCmsCadesException
- if the included CRLs can't be parsedpublic iaik.x509.ocsp.BasicOCSPResponse[] getIndexedOcspResponses(AbstractCadesSignature archivedSignature) throws iaik.asn1.CodingException, CmsCadesException
archivedSignature
- the signature (CadesSignature or CadesSignatureStream) that was archived by the
corresponding archive timestampiaik.asn1.CodingException
- if the OCSP responses can't be encoded for hash calculationCmsCadesException
- if the included revocation infos can't be parsedpublic java.security.cert.CRL[] getIndexedOtherRevocationInfos(AbstractCadesSignature archivedSignature) throws iaik.asn1.CodingException, CmsCadesException
archivedSignature
- the signature (CadesSignature or CadesSignatureStream) that was archived by the
corresponding archive timestampiaik.asn1.CodingException
- if the other revocation info can't be encoded for hash calculationCmsCadesException
- if a revocation info can't be parsed to determine its typepublic java.util.ArrayList<byte[]> getRevocationInfoReferencesWithoutOriginalValues(AbstractCadesSignature archivedSignature) throws iaik.asn1.CodingException, CmsCadesException
archivedSignature
- the signature containing the revocation infos to match against the revocation info
hashes of this ats-hash-indexiaik.asn1.CodingException
- if a revocation info of the given signature can't be encoded for the hash calculationCmsCadesException
- if a revocation info can't be parsed to determine its typepublic boolean containsReferencesWithoutOriginalValues(AbstractCadesSignature archivedSignature, iaik.cms.SignerInfo archivedSignerInfo) throws iaik.asn1.CodingException, CmsCadesException
archivedSignature
- the signature containing the certificates and revocation infos to match the references
of this ats-hash-index againstarchivedSignerInfo
- the signer info containing the unsigned attributes to match the references of this
ats-hash-index againstiaik.asn1.CodingException
- if an error occurs when encoding for hash calculationCmsCadesException
- if another error occurspublic java.util.Vector<byte[]> getCertificateHashes()
public java.util.Vector<byte[]> getRevocationInfoHashes()
public void addCertificateHash(byte[] certHash)
certHash
- the hash value of a certificatepublic void addRevocationInfoHash(byte[] revocationInfoHash)
revocationInfoHash
- the hash value of a revocation infopublic boolean containsCertificateHash(byte[] certificateHash)
certificateHash
- the hash to be searched forpublic boolean containsRevocationInfoHash(byte[] revocationInfoHash)
revocationInfoHash
- the hash to be searched forpublic void decode(iaik.asn1.ASN1Object obj) throws iaik.asn1.CodingException
obj
- the ats-hash-index as ASN1Objectiaik.asn1.CodingException
- if the ASN1Object could not be parsedpublic iaik.asn1.ASN1Object toASN1Object() throws iaik.asn1.CodingException
iaik.asn1.CodingException
- if an de/encoding error occurspublic java.lang.String toString()
toString
in class iaik.asn1.structures.AttributeValue
public boolean equals(java.lang.Object obj)
ats-hash-index
to the specified object.equals
in class java.lang.Object
obj
- the object to compare this ats-hash-index
against.true
, if the given object is equal to this ats-hash-index
,
false
otherwisepublic abstract iaik.asn1.ObjectID getAttributeType()
getAttributeType
in class iaik.asn1.structures.AttributeValue
public abstract boolean multipleAllowed()
multipleAllowed
in class iaik.asn1.structures.AttributeValue