Class SignerInfo
- Namespace
- iText.Signatures.Cms
- Assembly
- itext.sign.dll
This class represents the SignerInfo structure from rfc5652 Cryptographic Message Syntax (CMS)
public class SignerInfo
- Inheritance
-
SignerInfo
- Inherited Members
Constructors
SignerInfo()
Creates an empty SignerInfo structure.
public SignerInfo()
SignerInfo(IAsn1Encodable, ICollection<IX509Certificate>)
Creates a SignerInfo structure from an ASN1 structure.
public SignerInfo(IAsn1Encodable signerInfoStructure, ICollection<IX509Certificate> certificates)
Parameters
signerInfoStructure
IAsn1Encodablethe ASN1 structure containing signerInfo
certificates
ICollection<IX509Certificate>the certificates of the CMS, it should contain the signing certificate
Methods
AddSignedAttribute(CmsAttribute)
Adds a new attribute to the signed attributes.
public virtual void AddSignedAttribute(CmsAttribute attribute)
Parameters
attribute
CmsAttributethe attribute to add
Remarks
Adds a new attribute to the signed attributes. This become readonly after retrieving the serialized version SerializeSignedAttributes().
AddSignerCertificateToSignedAttributes(IX509Certificate, string)
Adds the signer certificate to the signed attributes as a SigningCertificateV2 structure.
public virtual void AddSignerCertificateToSignedAttributes(IX509Certificate cert, string digestAlgorithmOid)
Parameters
cert
IX509Certificatethe certificate to add
digestAlgorithmOid
stringthe digest algorithm oid that will be used
AddUnSignedAttribute(CmsAttribute)
Optional.
public virtual void AddUnSignedAttribute(CmsAttribute attribute)
Parameters
attribute
CmsAttributethe attribute to add
Remarks
Optional.
Adds attribute that should not or can not be part of the signed content.GetAsDerSequence()
Serializes the SignerInfo structure and makes the signed attributes readonly.
public virtual IDerSequence GetAsDerSequence()
Returns
- IDerSequence
the encoded SignerInfo structure.
GetCmsVersion()
Value 0 when no signerIdentifier is available.
public virtual int GetCmsVersion()
Returns
- int
CMS version.
Remarks
Value 0 when no signerIdentifier is available. Value 1 when signerIdentifier is of type issuerAndSerialNumber. Value 3 when signerIdentifier is of type subjectKeyIdentifier.
GetDigestAlgorithm()
Returns the algorithmId to create the digest of the data to sign.
public virtual AlgorithmIdentifier GetDigestAlgorithm()
Returns
- AlgorithmIdentifier
the OID of the digest algorithm.
GetEstimatedSize()
Calculates an estimate size for the SignerInfo structure.
public virtual long GetEstimatedSize()
Returns
- long
the estimated size of the structure.
Remarks
Calculates an estimate size for the SignerInfo structure. This takes into account the values added including the signature, but does not account for unset items like a timestamp response added after actual signing.
GetSignatureData()
Gets the signature data.
public virtual byte[] GetSignatureData()
Returns
- byte[]
the signature data.
GetSignedAttributes()
Optional.
public virtual ICollection<CmsAttribute> GetSignedAttributes()
Returns
- ICollection<CmsAttribute>
collection of the signed attributes.
Remarks
Optional.
Attributes that should be part of the signed content optional, but it MUST be present if the content type of the EncapsulatedContentInfo value being signed is not id-data. In that case it must at least contain the following two attributes: A content-type attribute having as its value the content type of the EncapsulatedContentInfo value being signed. Section 11.1 defines the content-type attribute. However, the content-type attribute MUST NOT be used as part of a countersignature unsigned attribute as defined in Section 11.4. A message-digest attribute, having as its value the message digest of the content. Section 11.2 defines the message-digest attribute.GetSigningCertificate()
Gets the certificate that is used to sign.
public virtual IX509Certificate GetSigningCertificate()
Returns
- IX509Certificate
the certificate that is used to sign.
GetUnSignedAttributes()
Retrieves the optional unsigned attributes.
public virtual ICollection<CmsAttribute> GetUnSignedAttributes()
Returns
- ICollection<CmsAttribute>
the optional unsigned attributes.
SerializeSignedAttributes()
Retrieves the encoded signed attributes of the signer info.
public virtual byte[] SerializeSignedAttributes()
Returns
- byte[]
the encoded signed attributes of the signer info.
Remarks
Retrieves the encoded signed attributes of the signer info. This makes the signed attributes read only.
SetCrlResponses(ICollection<byte[]>)
Adds a set of CRL responses as signed attributes.
public virtual void SetCrlResponses(ICollection<byte[]> crlResponses)
Parameters
crlResponses
ICollection<byte[]>a set of binary representations of CRL responses.
SetDigestAlgorithm(AlgorithmIdentifier)
Sets the algorithmId to create the digest of the data to sign.
public virtual void SetDigestAlgorithm(AlgorithmIdentifier algorithmId)
Parameters
algorithmId
AlgorithmIdentifierthe OID of the algorithm
SetMessageDigest(byte[])
Adds or replaces the message digest signed attribute.
public virtual void SetMessageDigest(byte[] digest)
Parameters
digest
byte[]ASN.1 type MessageDigest
SetOcspResponses(ICollection<byte[]>)
Adds a set of OCSP responses as signed attributes.
public virtual void SetOcspResponses(ICollection<byte[]> ocspResponses)
Parameters
ocspResponses
ICollection<byte[]>a set of binary representations of OCSP responses.
SetSerializedSignedAttributes(byte[])
Sets the signed attributes from a serialized version.
public void SetSerializedSignedAttributes(byte[] serializedSignedAttributes)
Parameters
serializedSignedAttributes
byte[]the encoded signed attributes.
Remarks
Sets the signed attributes from a serialized version. This makes the signed attributes read only.
SetSignature(byte[])
Sets the actual signature.
public virtual void SetSignature(byte[] signatureData)
Parameters
signatureData
byte[]a byte array containing the signature
SetSignatureAlgorithm(AlgorithmIdentifier)
Optional.
public virtual void SetSignatureAlgorithm(AlgorithmIdentifier algorithm)
Parameters
algorithm
AlgorithmIdentifierThe OID and parameters of the algorithm that will be used to create the signature.
Remarks
Optional. Sets the OID and parameters of the algorithm that will be used to create the signature. This will be overwritten when setting the signing certificate.
SetSigningCertificate(IX509Certificate)
Sets the certificate that is used to sign.
public virtual void SetSigningCertificate(IX509Certificate certificate)
Parameters
certificate
IX509Certificatethe certificate that is used to sign
SetSigningCertificateAndAddToSignedAttributes(IX509Certificate, string)
Sets the certificate that is used to sign a document and adds it to the signed attributes.
public virtual void SetSigningCertificateAndAddToSignedAttributes(IX509Certificate certificate, string digestAlgorithmOid)
Parameters
certificate
IX509Certificatethe certificate that is used to sign
digestAlgorithmOid
stringthe oid of the digest algorithm to be added to the signed attributes