Package eu.europa.esig.dss.spi
Class DSSASN1Utils
java.lang.Object
eu.europa.esig.dss.spi.DSSASN1Utils
Utility class that contains some ASN1 related method.
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.bouncycastle.asn1.ASN1PrimitivebuildSPDocSpecificationId(String oidOrUri) Builds SPDocSpecification attribute from the givenoidOrUriSPDocSpecification ::= CHOICE { oid OBJECT IDENTIFIER, uri IA5String }static byte[]computeSkiFromCert(CertificateToken certificateToken) Computes SHA-1 hash of thecertificateToken's public keystatic byte[]computeSkiFromCertPublicKey(PublicKey publicKey) Computes SHA-1 hash of the givenpublicKey'sstatic org.bouncycastle.asn1.cms.AttributeTableemptyIfNull(org.bouncycastle.asn1.cms.AttributeTable originalAttributeTable) Deprecated.since DSS 6.1.static byte[]ensurePlainSignatureValue(EncryptionAlgorithm algorithm, byte[] signatureValue) Converts the ANS.1 binary signature value to the concatenated (plain) R || S format if required NOTE: used in XAdES and JAdESstatic StringextractAttributeFromX500Principal(org.bouncycastle.asn1.ASN1ObjectIdentifier identifier, X500PrincipalHelper principal) Extract attribute with theidentifierfromX500PrincipalHelperstatic List<org.bouncycastle.tsp.TimeStampToken> findArchiveTimeStampTokens(org.bouncycastle.asn1.cms.AttributeTable unsignedAttributes) Deprecated.since DSS 6.1.get(X500Principal x500Principal) Gets a map of X500 attribute names and the valuesstatic org.bouncycastle.asn1.x509.AlgorithmIdentifiergetAlgorithmIdentifier(DigestAlgorithm digestAlgorithm) Gets the ASN.1 algorithm identifier structure corresponding to a digest algorithmstatic org.bouncycastle.asn1.x509.AlgorithmIdentifiergetAlgorithmIdentifier(org.bouncycastle.asn1.ASN1Sequence atsHashIndexValue) Gets the ASN.1 algorithm identifier structure corresponding to the algorithm found in the provided Timestamp Hash Index Table, if such algorithm is presentstatic org.bouncycastle.asn1.cms.Attribute[]getAsn1Attributes(org.bouncycastle.asn1.cms.AttributeTable attributeTable, org.bouncycastle.asn1.ASN1ObjectIdentifier oid) Returns an array ofAttributes for a givenoidfound in theattributeTablestatic org.bouncycastle.asn1.ASN1SetgetAsn1AttributeSet(org.bouncycastle.asn1.cms.AttributeTable attributeTable, org.bouncycastle.asn1.ASN1ObjectIdentifier oid) Deprecated.since DSS 6.1.static org.bouncycastle.asn1.ASN1EncodablegetAsn1Encodable(org.bouncycastle.asn1.cms.Attribute attribute) Deprecated.since DSS 6.1.static org.bouncycastle.asn1.ASN1EncodablegetAsn1Encodable(org.bouncycastle.asn1.cms.AttributeTable attributeTable, org.bouncycastle.asn1.ASN1ObjectIdentifier oid) Deprecated.since DSS 6.1.static org.bouncycastle.asn1.ASN1IntegergetAsn1IntegerFromDerOctetString(byte[] bytes) This method returns theASN1Integerencapsulated inDEROctetString.static org.bouncycastle.asn1.ASN1SequencegetAsn1SequenceFromDerOctetString(byte[] bytes) This method returns theASN1Sequenceencapsulated inDEROctetString.static byte[]getAsn1SignaturePolicyDigest(DigestAlgorithm digestAlgorithm, byte[] policyBytes) This method computes the digest of an ASN1 signature policy (used in CAdES) TS 101 733 5.8.1 : If the signature policy is defined using ASN.1, then the hash is calculated on the value without the outer type and length fields, and the hashing algorithm shall be as specified in the field sigPolicyHash.static org.bouncycastle.asn1.ASN1SequencegetAtsHashIndex(org.bouncycastle.asn1.cms.AttributeTable timestampUnsignedAttributes) Deprecated.since DSS 6.1.static org.bouncycastle.asn1.ASN1SequencegetAtsHashIndexByVersion(org.bouncycastle.asn1.cms.AttributeTable timestampUnsignedAttributes, org.bouncycastle.asn1.ASN1ObjectIdentifier atsHashIndexVersionIdentifier) Deprecated.since DSS 6.1.static List<byte[]> getATSHashIndexV3OctetString(org.bouncycastle.asn1.ASN1ObjectIdentifier attributeIdentifier, org.bouncycastle.asn1.ASN1Set attributeValues) Deprecated.since DSS 6.1.static org.bouncycastle.asn1.ASN1ObjectIdentifiergetAtsHashIndexVersionIdentifier(org.bouncycastle.asn1.cms.AttributeTable timestampUnsignedAttributes) Deprecated.since DSS 6.1.static byte[]getBEREncoded(org.bouncycastle.asn1.ASN1Encodable asn1Encodable) This method returns BER encoded ASN1 attribute.static CertificateTokengetCertificate(org.bouncycastle.cert.X509CertificateHolder x509CertificateHolder) Extract the certificate token fromX509CertificateHolderstatic CertificateRefgetCertificateRef(org.bouncycastle.asn1.ess.OtherCertID otherCertId) Converts theOtherCertIDtoCertificateRefstatic org.bouncycastle.asn1.ASN1SequencegetCertificatesHashIndex(org.bouncycastle.asn1.ASN1Sequence atsHashIndexValue) Deprecated.since DSS 6.1.static org.bouncycastle.cms.CMSSignedDatagetCMSSignedData(org.bouncycastle.asn1.cms.Attribute attribute) Deprecated.since DSS 6.1.static org.bouncycastle.asn1.ASN1SequencegetCRLHashIndex(org.bouncycastle.asn1.ASN1Sequence atsHashIndexValue) Deprecated.since DSS 6.1.static DategetDate(org.bouncycastle.asn1.ASN1Encodable encodable) Reads theencodableand returns aDatestatic byte[]getDEREncoded(byte[] bytes) Returns the ASN.1 encoded representation ofbytearray.static byte[]getDEREncoded(TimestampBinary timestampBinary) Returns the ASN.1 encoded representation ofTimestampBinary.static byte[]getDEREncoded(org.bouncycastle.asn1.ASN1Encodable asn1Encodable) This method returns DER encoded ASN1 attribute.static byte[]getDEREncoded(org.bouncycastle.cms.CMSSignedData data) Returns the ASN.1 encoded representation ofCMSSignedData.static byte[]getDEREncoded(org.bouncycastle.tsp.TimeStampToken timeStampToken) Gets the DER encoded binaries ofTimeStampTokenstatic List<org.bouncycastle.asn1.DEROctetString> getDEROctetStrings(org.bouncycastle.asn1.ASN1Sequence asn1Sequence) Returns list ofDEROctetStringfrom anASN1SequenceUseful when needed to get a list of hash valuesstatic StringgetDirectoryStringValue(org.bouncycastle.asn1.ASN1Encodable directoryStringInstance) Returns a value of an ASN.1 DirectoryString instance Returns null if an error occurs during the transformationstatic byte[]getEncoded(org.bouncycastle.cert.ocsp.BasicOCSPResp basicOCSPResp) Gets the DER-encoded binaries of theBasicOCSPRespstatic byte[]getEncoded(org.bouncycastle.cms.CMSSignedData cmsSignedData) Returns an ASN.1 encoded bytes representing theCMSSignedDatastatic byte[]getEncoded(org.bouncycastle.tsp.TimeStampToken timeStampToken) Returns an ASN.1 encoded bytes representing theTimeStampTokengetExtendedKeyUsage(CertificateToken certToken) Extracts all extended key usages for the certificate tokenstatic org.bouncycastle.cms.SignerInformationgetFirstSignerInformation(org.bouncycastle.cms.CMSSignedData cms) Returns the firstSignerInformationextracted fromCMSSignedData.static StringExtracts the pretty printed name of the certificate tokenstatic StringgetHumanReadableName(X500PrincipalHelper x500PrincipalHelper) Extracts the pretty printed name from theX500PrincipalHelperstatic org.bouncycastle.asn1.x509.IssuerSerialgetIssuerSerial(byte[] binaries) Gets theIssuerSerialobjectstatic org.bouncycastle.asn1.x509.IssuerSerialgetIssuerSerial(CertificateToken certToken) This method returns a new IssuerSerial based on the certificate tokenstatic List<byte[]> getOctetStringForAtsHashIndex(org.bouncycastle.asn1.cms.Attribute attribute, org.bouncycastle.asn1.ASN1ObjectIdentifier atsHashIndexVersionIdentifier) Deprecated.since DSS 6.1.static BigIntegergetOrderFromSignatureValue(byte[] signatureValue) Gets the order parameter corresponding the givensignatureValuestatic org.bouncycastle.asn1.esf.RevocationValuesgetRevocationValues(org.bouncycastle.asn1.ASN1Encodable encodable) ReturnsRevocationValuesfrom the given encodablestatic intgetSignatureValueBitLength(byte[] signatureValue) This method returns a bit length of the provided signature valuestatic StringgetString(org.bouncycastle.asn1.ASN1Encodable attributeValue) ConvertsASN1Encodableto aStringvalue.static StringExtracts the Subject Common name from the certificate tokenstatic List<org.bouncycastle.asn1.ASN1ObjectIdentifier> Deprecated.since DSS 6.1.static org.bouncycastle.tsp.TimeStampTokengetTimeStampToken(org.bouncycastle.asn1.cms.Attribute attribute) Deprecated.since DSS 6.1.static DategetTimeStampTokenGenerationTime(org.bouncycastle.tsp.TimeStampToken timeStampToken) Returns generation time for the providedtimeStampTokenstatic org.bouncycastle.asn1.ASN1SequencegetUnsignedAttributesHashIndex(org.bouncycastle.asn1.ASN1Sequence atsHashIndexValue) Deprecated.since DSS 6.1.static org.bouncycastle.cert.X509CertificateHoldergetX509CertificateHolder(CertificateToken certToken) Returns aX509CertificateHolderencapsulating the givenX509Certificate.static booleanisArchiveTimeStampToken(org.bouncycastle.asn1.cms.Attribute attribute) Deprecated.since DSS 6.1.static booleanisAsn1Encoded(byte[] binaries) Checks if the binaries are ASN.1 encoded.static booleanisAsn1EncodedSignatureValue(byte[] binaries) Checks if the SignatureValue binaries are ASN.1 encoded.static booleanisASN1SequenceTag(byte tagByte) Checks if the byte defines an ASN1 Sequencestatic booleanisAttributeOfType(org.bouncycastle.asn1.cms.Attribute attribute, org.bouncycastle.asn1.ASN1ObjectIdentifier asn1ObjectIdentifier) Deprecated.since DSS 6.1.static booleanisDEROctetStringNull(org.bouncycastle.asn1.DEROctetString derOctetString) This method checks if a givenDEROctetStringis null.static booleanisEmpty(org.bouncycastle.asn1.cms.AttributeTable attributeTable) Deprecated.since DSS 6.1.static booleanisSkiEqual(byte[] ski, CertificateToken certificateToken) Checks if the provided ski matches to a ski computed from a certificateToken's public keystatic <T extends org.bouncycastle.asn1.ASN1Primitive>
TtoASN1Primitive(byte[] bytes) This method returnsT extends ASN1Primitivecreated from array of bytes.static org.bouncycastle.cert.ocsp.BasicOCSPResptoBasicOCSPResp(org.bouncycastle.asn1.ocsp.OCSPResponse ocspResponse) Converts an object ofOCSPResponseclass toBasicOCSPRespstatic org.bouncycastle.cert.ocsp.BasicOCSPResp[]toBasicOCSPResps(org.bouncycastle.asn1.ocsp.BasicOCSPResponse[] basicOCSPResponses) Converts an array ofBasicOCSPResponses to an array ofBasicOCSPRespsstatic org.bouncycastle.cert.ocsp.BasicOCSPResp[]toBasicOCSPResps(org.bouncycastle.asn1.ocsp.OCSPResponse[] ocspResponses) Converts an array ofOCSPResponses to an array ofBasicOCSPRespsstatic DatetoDate(org.bouncycastle.asn1.ASN1GeneralizedTime asn1Date) ConvertsASN1GeneralizedTimetoDatestatic byte[]toPlainDSASignatureValue(byte[] asn1SignatureValue) Converts an ASN.1 value to a concatenation string of R and S from ECDSA/DSA encryption algorithm The JAVA JCE ECDSA/DSA Signature algorithm creates ASN.1 encoded (r,s) value pairs.static SignerIdentifiertoSignerIdentifier(X500Principal issuerX500Principal, BigInteger serialNumber, byte[] ski) This method transforms token's issuer and serial number information into aCertificateIdentifierobjectstatic SignerIdentifiertoSignerIdentifier(org.bouncycastle.asn1.x509.IssuerSerial issuerAndSerial) Transforms an object of classIssuerSerialinto instance ofCertificateIdentifierstatic SignerIdentifiertoSignerIdentifier(org.bouncycastle.cms.SignerId signerId) This method transforms token's signerId into aSignerIdentifierobjectstatic byte[]toStandardDSASignatureValue(byte[] signatureValue) Converts a plainsignatureValueto its corresponding ASN.1 formatstatic StringtoString(org.bouncycastle.asn1.ASN1OctetString value) ReadsASN1OctetStringvalue and returnsstatic X500PrincipaltoX500Principal(org.bouncycastle.asn1.x500.X500Name x500Name) Transforms x500Name to X500Principalstatic booleanx500PrincipalAreEquals(X500Principal firstX500Principal, X500Principal secondX500Principal) This method compares twoX500Principals.
-
Method Details
-
toASN1Primitive
public static <T extends org.bouncycastle.asn1.ASN1Primitive> T toASN1Primitive(byte[] bytes) This method returnsT extends ASN1Primitivecreated from array of bytes. TheIOExceptionis transformed inDSSException.- Type Parameters:
T- the expected return type- Parameters:
bytes- array of bytes to be transformed toASN1Primitive- Returns:
- new
T extends ASN1Primitive
-
isDEROctetStringNull
public static boolean isDEROctetStringNull(org.bouncycastle.asn1.DEROctetString derOctetString) This method checks if a givenDEROctetStringis null.- Parameters:
derOctetString- theDEROctetStringto check- Returns:
- true if the
DEROctetStringcontains DERNull
-
getDEREncoded
public static byte[] getDEREncoded(org.bouncycastle.asn1.ASN1Encodable asn1Encodable) This method returns DER encoded ASN1 attribute. TheIOExceptionis transformed inDSSException.- Parameters:
asn1Encodable- asn1Encodable to be DER encoded- Returns:
- array of bytes representing the DER encoded asn1Encodable
-
getBEREncoded
public static byte[] getBEREncoded(org.bouncycastle.asn1.ASN1Encodable asn1Encodable) This method returns BER encoded ASN1 attribute. TheIOExceptionis transformed inDSSException.- Parameters:
asn1Encodable- asn1Encodable to be BER encoded- Returns:
- array of bytes representing the BER encoded asn1Encodable
-
getEncoded
public static byte[] getEncoded(org.bouncycastle.cert.ocsp.BasicOCSPResp basicOCSPResp) Gets the DER-encoded binaries of theBasicOCSPResp- Parameters:
basicOCSPResp-BasicOCSPResp- Returns:
- DER-encoded binaries
-
toDate
-
toString
-
getEncoded
public static byte[] getEncoded(org.bouncycastle.tsp.TimeStampToken timeStampToken) Returns an ASN.1 encoded bytes representing theTimeStampToken- Parameters:
timeStampToken-TimeStampToken- Returns:
- the DER encoded
TimeStampToken
-
getEncoded
public static byte[] getEncoded(org.bouncycastle.cms.CMSSignedData cmsSignedData) Returns an ASN.1 encoded bytes representing theCMSSignedData- Parameters:
cmsSignedData-CMSSignedData- Returns:
- the binary of the
CMSSignedData@ if theCMSSignedDataencoding fails
-
getDEREncoded
public static byte[] getDEREncoded(org.bouncycastle.tsp.TimeStampToken timeStampToken) Gets the DER encoded binaries ofTimeStampToken- Parameters:
timeStampToken-TimeStampToken- Returns:
- DER encoded binaries
-
getDEREncoded
public static byte[] getDEREncoded(org.bouncycastle.cms.CMSSignedData data) Returns the ASN.1 encoded representation ofCMSSignedData.- Parameters:
data- the CMSSignedData to be encoded- Returns:
- the DER encoded CMSSignedData
-
getDEREncoded
Returns the ASN.1 encoded representation ofTimestampBinary.- Parameters:
timestampBinary- theTimestampBinaryto be encoded- Returns:
- the DER encoded timestampBinary
-
getDEREncoded
public static byte[] getDEREncoded(byte[] bytes) Returns the ASN.1 encoded representation ofbytearray.- Parameters:
bytes- the binary array to encode- Returns:
- the DER encoded bytes
-
getAsn1SequenceFromDerOctetString
public static org.bouncycastle.asn1.ASN1Sequence getAsn1SequenceFromDerOctetString(byte[] bytes) This method returns theASN1Sequenceencapsulated inDEROctetString. TheDEROctetStringis represented asbytearray.- Parameters:
bytes-byterepresentation ofDEROctetString- Returns:
- encapsulated
ASN1Sequenceor exception in case of a decoding problem
-
getAsn1IntegerFromDerOctetString
public static org.bouncycastle.asn1.ASN1Integer getAsn1IntegerFromDerOctetString(byte[] bytes) This method returns theASN1Integerencapsulated inDEROctetString. TheDEROctetStringis represented asbytearray.- Parameters:
bytes-byterepresentation ofDEROctetString- Returns:
- encapsulated
ASN1Integeror exception in case of a decoding problem
-
getAsn1SignaturePolicyDigest
public static byte[] getAsn1SignaturePolicyDigest(DigestAlgorithm digestAlgorithm, byte[] policyBytes) This method computes the digest of an ASN1 signature policy (used in CAdES) TS 101 733 5.8.1 : If the signature policy is defined using ASN.1, then the hash is calculated on the value without the outer type and length fields, and the hashing algorithm shall be as specified in the field sigPolicyHash.- Parameters:
digestAlgorithm- the digest algorithm to be usedpolicyBytes- the ASN.1 policy content- Returns:
- the expected digest value
-
getAlgorithmIdentifier
public static org.bouncycastle.asn1.x509.AlgorithmIdentifier getAlgorithmIdentifier(org.bouncycastle.asn1.ASN1Sequence atsHashIndexValue) Gets the ASN.1 algorithm identifier structure corresponding to the algorithm found in the provided Timestamp Hash Index Table, if such algorithm is present- Parameters:
atsHashIndexValue- ats-hash-index table from a timestamp- Returns:
- the ASN.1 algorithm identifier structure
-
getAlgorithmIdentifier
public static org.bouncycastle.asn1.x509.AlgorithmIdentifier getAlgorithmIdentifier(DigestAlgorithm digestAlgorithm) Gets the ASN.1 algorithm identifier structure corresponding to a digest algorithm- Parameters:
digestAlgorithm- the digest algorithm to encode- Returns:
- the ASN.1 algorithm identifier structure
-
getCertificatesHashIndex
@Deprecated public static org.bouncycastle.asn1.ASN1Sequence getCertificatesHashIndex(org.bouncycastle.asn1.ASN1Sequence atsHashIndexValue) Deprecated.since DSS 6.1. Please useCMSUtils#getCertificatesHashIndexmethod insteadExtract the Unsigned Attribute Archive Timestamp Cert Hash Index from a timestampToken- Parameters:
atsHashIndexValue-ASN1Sequence- Returns:
ASN1Sequence
-
getCRLHashIndex
@Deprecated public static org.bouncycastle.asn1.ASN1Sequence getCRLHashIndex(org.bouncycastle.asn1.ASN1Sequence atsHashIndexValue) Deprecated.since DSS 6.1. Please useCMSUtils#getCRLHashIndexmethod insteadExtract the Unsigned Attribute Archive Timestamp Crl Hash Index from a timestampToken- Parameters:
atsHashIndexValue-ASN1Sequence- Returns:
ASN1Sequence
-
getUnsignedAttributesHashIndex
@Deprecated public static org.bouncycastle.asn1.ASN1Sequence getUnsignedAttributesHashIndex(org.bouncycastle.asn1.ASN1Sequence atsHashIndexValue) Deprecated.since DSS 6.1. Please useCMSUtils#getUnsignedAttributesHashIndexmethod insteadExtract the Unsigned Attribute Archive Timestamp Attribute Hash Index from a timestampToken- Parameters:
atsHashIndexValue-ASN1Sequence- Returns:
ASN1Sequence
-
getDEROctetStrings
public static List<org.bouncycastle.asn1.DEROctetString> getDEROctetStrings(org.bouncycastle.asn1.ASN1Sequence asn1Sequence) Returns list ofDEROctetStringfrom anASN1SequenceUseful when needed to get a list of hash values- Parameters:
asn1Sequence-ASN1Sequenceto get list from- Returns:
- list of
DEROctetStrings
-
computeSkiFromCert
Computes SHA-1 hash of thecertificateToken's public key- Parameters:
certificateToken-CertificateTokento compute digest for- Returns:
- byte array of public key's SHA-1 hash
-
computeSkiFromCertPublicKey
-
isSkiEqual
Checks if the provided ski matches to a ski computed from a certificateToken's public key- Parameters:
ski- a byte array representing ski value (SHA-1 of the public key)certificateToken-CertificateTokento check- Returns:
- TRUE if the SKI equals, FALSE otherwise
-
getX509CertificateHolder
public static org.bouncycastle.cert.X509CertificateHolder getX509CertificateHolder(CertificateToken certToken) Returns aX509CertificateHolderencapsulating the givenX509Certificate.- Parameters:
certToken- the certificate to be encapsulated- Returns:
- a X509CertificateHolder holding this certificate
-
getCertificate
public static CertificateToken getCertificate(org.bouncycastle.cert.X509CertificateHolder x509CertificateHolder) Extract the certificate token fromX509CertificateHolder- Parameters:
x509CertificateHolder-X509CertificateHolder- Returns:
CertificateToken
-
toSignerIdentifier
This method transforms token's signerId into aSignerIdentifierobject- Parameters:
signerId-SignerIdto be transformed- Returns:
SignerIdentifier
-
toX500Principal
Transforms x500Name to X500Principal- Parameters:
x500Name-X500Name- Returns:
X500Principal
-
toSignerIdentifier
public static SignerIdentifier toSignerIdentifier(X500Principal issuerX500Principal, BigInteger serialNumber, byte[] ski) This method transforms token's issuer and serial number information into aCertificateIdentifierobject- Parameters:
issuerX500Principal-X500Principalof the issuerserialNumber-BigIntegerof the tokenski- a byte array representing a SubjectKeyIdentifier (SHA-1 digest of the public key)- Returns:
SignerIdentifier
-
getIssuerSerial
This method returns a new IssuerSerial based on the certificate token- Parameters:
certToken- the certificate token- Returns:
- a IssuerSerial
-
x500PrincipalAreEquals
public static boolean x500PrincipalAreEquals(X500Principal firstX500Principal, X500Principal secondX500Principal) This method compares twoX500Principals.X500Principal.CANONICALandX500Principal.RFC2253forms are compared.- Parameters:
firstX500Principal- the first X500Principal object to be comparedsecondX500Principal- the second X500Principal object to be compared- Returns:
- true if the two parameters contain the same key/values
-
get
Gets a map of X500 attribute names and the values- Parameters:
x500Principal-X500Principal- Returns:
- a map of X500 attribute names and the values
-
getString
ConvertsASN1Encodableto aStringvalue. The method preserves the object class and structure and returns hash-encoded String value, unless the object is an instance ofASN1String.- Parameters:
attributeValue-ASN1Encodableto read- Returns:
Stringvalue
-
extractAttributeFromX500Principal
public static String extractAttributeFromX500Principal(org.bouncycastle.asn1.ASN1ObjectIdentifier identifier, X500PrincipalHelper principal) Extract attribute with theidentifierfromX500PrincipalHelper- Parameters:
identifier-ASN1ObjectIdentifieroid of the attribute to get valueprincipal-X500PrincipalHelperto extract the attribute value from- Returns:
Stringvalue
-
getSubjectCommonName
Extracts the Subject Common name from the certificate token- Parameters:
cert-CertificateToken- Returns:
String
-
getHumanReadableName
Extracts the pretty printed name of the certificate token- Parameters:
cert-CertificateToken- Returns:
String
-
getHumanReadableName
Extracts the pretty printed name from theX500PrincipalHelper- Parameters:
x500PrincipalHelper-X500PrincipalHelper- Returns:
String
-
getFirstSignerInformation
public static org.bouncycastle.cms.SignerInformation getFirstSignerInformation(org.bouncycastle.cms.CMSSignedData cms) Returns the firstSignerInformationextracted fromCMSSignedData.- Parameters:
cms- CMSSignedData- Returns:
- returns
SignerInformation
-
isASN1SequenceTag
public static boolean isASN1SequenceTag(byte tagByte) Checks if the byte defines an ASN1 Sequence- Parameters:
tagByte- byte to check- Returns:
- TRUE if the byte defines an ASN1 Sequence, FALSE otherwise
-
getDate
-
isEmpty
Deprecated.since DSS 6.1. Please useCMSUtils#isEmptymethod insteadChecks if theattributeTableis empty- Parameters:
attributeTable-AttributeTable- Returns:
- TRUE if the attribute table is empty, FALSE otherwise
-
emptyIfNull
@Deprecated public static org.bouncycastle.asn1.cms.AttributeTable emptyIfNull(org.bouncycastle.asn1.cms.AttributeTable originalAttributeTable) Deprecated.since DSS 6.1. Please useCMSUtils#emptyIfNullmethod insteadReturns the currentoriginalAttributeTableif instantiated, an emptyAttributeTableif null- Parameters:
originalAttributeTable-AttributeTable- Returns:
AttributeTable
-
getExtendedKeyUsage
Extracts all extended key usages for the certificate token- Parameters:
certToken-CertificateToken- Returns:
- a list of
Strings
-
getIssuerSerial
public static org.bouncycastle.asn1.x509.IssuerSerial getIssuerSerial(byte[] binaries) Gets theIssuerSerialobject- Parameters:
binaries- representing theIssuerSerial- Returns:
IssuerSerialif able to parse, null otherwise
-
toSignerIdentifier
public static SignerIdentifier toSignerIdentifier(org.bouncycastle.asn1.x509.IssuerSerial issuerAndSerial) Transforms an object of classIssuerSerialinto instance ofCertificateIdentifier- Parameters:
issuerAndSerial-IssuerSerialto transform- Returns:
SignerIdentifier
-
getAtsHashIndex
@Deprecated public static org.bouncycastle.asn1.ASN1Sequence getAtsHashIndex(org.bouncycastle.asn1.cms.AttributeTable timestampUnsignedAttributes) Deprecated.since DSS 6.1. Please useCMSUtils#getAtsHashIndexmethod insteadReturns ats-hash-index table, with a related version present in from timestamp's unsigned properties- Parameters:
timestampUnsignedAttributes-AttributeTableunsigned properties of the timestamp- Returns:
- the content of SignedAttribute: ATS-hash-index unsigned attribute with a present version
-
getAtsHashIndexByVersion
@Deprecated public static org.bouncycastle.asn1.ASN1Sequence getAtsHashIndexByVersion(org.bouncycastle.asn1.cms.AttributeTable timestampUnsignedAttributes, org.bouncycastle.asn1.ASN1ObjectIdentifier atsHashIndexVersionIdentifier) Deprecated.since DSS 6.1. Please useCMSUtils#getAtsHashIndexByVersionmethod insteadReturns ats-hash-index table, with a specified version present in from timestamp's unsigned properties- Parameters:
timestampUnsignedAttributes-AttributeTableunsigned properties of the timestampatsHashIndexVersionIdentifier-ASN1ObjectIdentifieridentifier of ats-hash-index table to get- Returns:
- the content of SignedAttribute: ATS-hash-index unsigned attribute with a requested version if present
-
getAtsHashIndexVersionIdentifier
@Deprecated public static org.bouncycastle.asn1.ASN1ObjectIdentifier getAtsHashIndexVersionIdentifier(org.bouncycastle.asn1.cms.AttributeTable timestampUnsignedAttributes) Deprecated.since DSS 6.1. Please useCMSUtils#getAtsHashIndexVersionIdentifiermethod insteadReturnsASN1ObjectIdentifierof the found AtsHashIndex- Parameters:
timestampUnsignedAttributes-AttributeTableof the timestamp's unsignedAttributes- Returns:
ASN1ObjectIdentifierof the AtsHashIndex element version
-
getOctetStringForAtsHashIndex
@Deprecated public static List<byte[]> getOctetStringForAtsHashIndex(org.bouncycastle.asn1.cms.Attribute attribute, org.bouncycastle.asn1.ASN1ObjectIdentifier atsHashIndexVersionIdentifier) Deprecated.since DSS 6.1. Please useCMSUtils#getOctetStringForAtsHashIndexmethod insteadReturns octets from the given attribute by defined atsh-hash-index type- Parameters:
attribute-Attributeto get byte array fromatsHashIndexVersionIdentifier-ASN1ObjectIdentifierto specify rules- Returns:
- byte array
-
getATSHashIndexV3OctetString
@Deprecated public static List<byte[]> getATSHashIndexV3OctetString(org.bouncycastle.asn1.ASN1ObjectIdentifier attributeIdentifier, org.bouncycastle.asn1.ASN1Set attributeValues) Deprecated.since DSS 6.1. Please useCMSUtils#getATSHashIndexV3OctetStringmethod insteadReturns octets from the given attribute for ATS-Hash-Index-v3 table- Parameters:
attributeIdentifier-ASN1ObjectIdentifierof the corresponding AttributeattributeValues-ASN1Setof the corresponding Attribute- Returns:
- byte array representing an octet string
-
getAsn1Encodable
@Deprecated public static org.bouncycastle.asn1.ASN1Encodable getAsn1Encodable(org.bouncycastle.asn1.cms.AttributeTable attributeTable, org.bouncycastle.asn1.ASN1ObjectIdentifier oid) Deprecated.since DSS 6.1. Please useDSSASN1Utils.getAsn1Attributes(attributeTable, oid)ReturnsASN1Encodablefor a givenoidfound in theunsignedAttributes- Parameters:
attributeTable-AttributeTableoid- targetASN1ObjectIdentifier- Returns:
ASN1Encodable
-
getAsn1AttributeSet
@Deprecated public static org.bouncycastle.asn1.ASN1Set getAsn1AttributeSet(org.bouncycastle.asn1.cms.AttributeTable attributeTable, org.bouncycastle.asn1.ASN1ObjectIdentifier oid) Deprecated.since DSS 6.1. Please useDSSASN1Utils.getAsn1Attributes(attributeTable, oid)Returns an Attribute values for a givenoidfound in theunsignedAttributes- Parameters:
attributeTable-AttributeTableoid- targetASN1ObjectIdentifier- Returns:
ASN1Set
-
getAsn1Attributes
public static org.bouncycastle.asn1.cms.Attribute[] getAsn1Attributes(org.bouncycastle.asn1.cms.AttributeTable attributeTable, org.bouncycastle.asn1.ASN1ObjectIdentifier oid) Returns an array ofAttributes for a givenoidfound in theattributeTable- Parameters:
attributeTable-AttributeTableoid- targetASN1ObjectIdentifier- Returns:
Attributes array
-
findArchiveTimeStampTokens
@Deprecated public static List<org.bouncycastle.tsp.TimeStampToken> findArchiveTimeStampTokens(org.bouncycastle.asn1.cms.AttributeTable unsignedAttributes) Deprecated.since DSS 6.1. Please useCMSUtils#findArchiveTimeStampTokensmethod insteadFinds archiveTimeStampTokens- Parameters:
unsignedAttributes-AttributeTableto obtain timestamps from- Returns:
- a list of
TimeStampTokens
-
getTimestampOids
Deprecated.since DSS 6.1. Please useCMSUtils#getTimestampOidsmethod insteadReturns a list of all CMS timestamp identifiers- Returns:
- a list of
ASN1ObjectIdentifiers
-
isArchiveTimeStampToken
@Deprecated public static boolean isArchiveTimeStampToken(org.bouncycastle.asn1.cms.Attribute attribute) Deprecated.since DSS 6.1. Please useCMSUtils#isArchiveTimeStampTokenmethod insteadChecks if the attribute is of an allowed archive timestamp type- Parameters:
attribute-Attributeto check- Returns:
- true if the attribute represents an archive timestamp element, false otherwise
-
isAttributeOfType
@Deprecated public static boolean isAttributeOfType(org.bouncycastle.asn1.cms.Attribute attribute, org.bouncycastle.asn1.ASN1ObjectIdentifier asn1ObjectIdentifier) Deprecated.since DSS 6.1. Please useCMSUtils#isAttributeOfTypemethod insteadChecks if the given attribute is an instance of the expected asn1ObjectIdentifier type- Parameters:
attribute-Attributeto checkasn1ObjectIdentifier-ASN1ObjectIdentifiertype to check against- Returns:
- TRUE if the attribute is of type asn1ObjectIdentifier, FALSE otherwise
-
getTimeStampToken
@Deprecated public static org.bouncycastle.tsp.TimeStampToken getTimeStampToken(org.bouncycastle.asn1.cms.Attribute attribute) Deprecated.since DSS 6.1. Please useCMSUtils#getTimeStampTokenmethod insteadCreates a TimeStampToken from the providedattribute- Parameters:
attribute-Attributeto generateTimeStampTokenfrom- Returns:
TimeStampToken
-
getCMSSignedData
@Deprecated public static org.bouncycastle.cms.CMSSignedData getCMSSignedData(org.bouncycastle.asn1.cms.Attribute attribute) throws org.bouncycastle.cms.CMSException, IOException Deprecated.since DSS 6.1. Please useCMSUtils#getCMSSignedDatamethod insteadCreates a CMSSignedData from the providedattribute- Parameters:
attribute-Attributeto generateCMSSignedDatafrom- Returns:
CMSSignedData- Throws:
IOException- in case of encoding exceptionorg.bouncycastle.cms.CMSException- in case if the providedattributecannot be converted toCMSSignedData
-
getAsn1Encodable
@Deprecated public static org.bouncycastle.asn1.ASN1Encodable getAsn1Encodable(org.bouncycastle.asn1.cms.Attribute attribute) Deprecated.since DSS 6.1. Please useCMSUtils#getAsn1Encodablemethod insteadReturnsASN1Encodableof theattribute- Parameters:
attribute-Attribute- Returns:
ASN1Encodable
-
getTimeStampTokenGenerationTime
-
getRevocationValues
public static org.bouncycastle.asn1.esf.RevocationValues getRevocationValues(org.bouncycastle.asn1.ASN1Encodable encodable) ReturnsRevocationValuesfrom the given encodable- Parameters:
encodable- the encoded data to be parsed- Returns:
- an instance of RevocationValues or null if the parsing failed
-
getCertificateRef
Converts theOtherCertIDtoCertificateRef- Parameters:
otherCertId-OtherCertID- Returns:
CertificateRef
-
isAsn1Encoded
public static boolean isAsn1Encoded(byte[] binaries) Checks if the binaries are ASN.1 encoded.- Parameters:
binaries- byte array to check.- Returns:
- if the SignatureValue binaries are ASN.1 encoded.
-
isAsn1EncodedSignatureValue
public static boolean isAsn1EncodedSignatureValue(byte[] binaries) Checks if the SignatureValue binaries are ASN.1 encoded.- Parameters:
binaries- byte array to check.- Returns:
- if the SignatureValue binaries are ASN.1 encoded.
-
ensurePlainSignatureValue
public static byte[] ensurePlainSignatureValue(EncryptionAlgorithm algorithm, byte[] signatureValue) Converts the ANS.1 binary signature value to the concatenated (plain) R || S format if required NOTE: used in XAdES and JAdES- Parameters:
algorithm- Encryption algorithm used to create the signatureValuesignatureValue- the originally computed signature value- Returns:
- the converted signature value
-
toPlainDSASignatureValue
public static byte[] toPlainDSASignatureValue(byte[] asn1SignatureValue) Converts an ASN.1 value to a concatenation string of R and S from ECDSA/DSA encryption algorithm The JAVA JCE ECDSA/DSA Signature algorithm creates ASN.1 encoded (r,s) value pairs.- Parameters:
asn1SignatureValue- the ASN1 signature value- Returns:
- the decoded bytes
- See Also:
-
toStandardDSASignatureValue
public static byte[] toStandardDSASignatureValue(byte[] signatureValue) Converts a plainsignatureValueto its corresponding ASN.1 format- Parameters:
signatureValue- the plain signature value- Returns:
- the encoded bytes
- See Also:
-
getOrderFromSignatureValue
Gets the order parameter corresponding the givensignatureValue- Parameters:
signatureValue- byte array- Returns:
BigInteger
-
getSignatureValueBitLength
public static int getSignatureValueBitLength(byte[] signatureValue) This method returns a bit length of the provided signature value- Parameters:
signatureValue- byte array representing the signature value- Returns:
- bit length of the signature value
-
getDirectoryStringValue
public static String getDirectoryStringValue(org.bouncycastle.asn1.ASN1Encodable directoryStringInstance) Returns a value of an ASN.1 DirectoryString instance Returns null if an error occurs during the transformation- Parameters:
directoryStringInstance-ASN1Encodableto get DirectoryString value from- Returns:
Stringvalue
-
toBasicOCSPResp
public static org.bouncycastle.cert.ocsp.BasicOCSPResp toBasicOCSPResp(org.bouncycastle.asn1.ocsp.OCSPResponse ocspResponse) throws org.bouncycastle.cert.ocsp.OCSPException Converts an object ofOCSPResponseclass toBasicOCSPResp- Parameters:
ocspResponse-OCSPResponseto convert- Returns:
BasicOCSPResp- Throws:
org.bouncycastle.cert.ocsp.OCSPException- in case of a conversion error
-
toBasicOCSPResps
public static org.bouncycastle.cert.ocsp.BasicOCSPResp[] toBasicOCSPResps(org.bouncycastle.asn1.ocsp.OCSPResponse[] ocspResponses) Converts an array ofOCSPResponses to an array ofBasicOCSPResps- Parameters:
ocspResponses- an array ofOCSPResponses to convert- Returns:
- an array of
BasicOCSPResp
-
toBasicOCSPResps
public static org.bouncycastle.cert.ocsp.BasicOCSPResp[] toBasicOCSPResps(org.bouncycastle.asn1.ocsp.BasicOCSPResponse[] basicOCSPResponses) Converts an array ofBasicOCSPResponses to an array ofBasicOCSPResps- Parameters:
basicOCSPResponses- an array ofBasicOCSPResponses to convert- Returns:
- an array of
BasicOCSPResp
-
buildSPDocSpecificationId
-