public class ExternalSignatureSignerInfoGenerator
extends java.lang.Object
org.bouncycastle.asn1.cms.SignerInfo
generator, where
encryption operations are kept external.
The class is a reimplementation of the original nested
org.bouncycastle.cms.CMSSignedDataGenerator$SignerInf
class.
The key methods are
getBytesToSign(DERObjectIdentifier, CMSProcessable, String)
, which
calculates the bytes to digest and encrypt externally, and
setSignedBytes(byte[])
which stores the result. Actually the
generate()
method (defined package private) is used only in
ExternalSignatureCMSSignedDataGenerator.generate(CMSProcessable, boolean)
.
For an usage example, see
ExternalSignatureCMSSignedDataGenerator
and CLITest
.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
ExternalSignatureSignerInfoGenerator.DigOutputStream
Class wrapping a
MessageDigest update in form of an output
stream. |
Modifier and Type | Field and Description |
---|---|
(package private) java.security.cert.X509Certificate |
cert
The signer certificate, needed to extract
IssuerAndSerialNumber CMS information. |
(package private) java.lang.String |
digestOID
Digesting algorithm OID.
|
(package private) java.lang.String |
encOID
Encryption algorithm OID.
|
(package private) org.bouncycastle.asn1.cms.AttributeTable |
sAttr
The externally set 'authenticated attributes' to be signed, other than
contentType, messageDigest, signingTime;
currently not used (no setter method). |
(package private) org.bouncycastle.asn1.ASN1Set |
signedAttr
The set of authenticated attributes, calculated in
getBytesToSign(DERObjectIdentifier, CMSProcessable, String)
method,that will be externally signed. |
(package private) byte[] |
signedBytes
The (externally) encrypted digest of
getBytesToSign(DERObjectIdentifier, CMSProcessable, String) . *
This has to be set, along cert , before calling
generate() . |
(package private) org.bouncycastle.asn1.cms.AttributeTable |
unsAttr
The externally set attributes NOT to be signed;
currently not used (no setter method). |
(package private) org.bouncycastle.asn1.ASN1Set |
unsignedAttr
The set of authenticated attributes, calculated in
getBytesToSign(DERObjectIdentifier, CMSProcessable, String)
method,that will NOT be signed. |
Constructor and Description |
---|
ExternalSignatureSignerInfoGenerator(java.lang.String digestOID,
java.lang.String encOID)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
private org.bouncycastle.asn1.cms.Attribute |
buildSigningCertificateV2Attribute(java.lang.String sigProvider)
Builds the SignerCertificateV2 attribute according to RFC2634(Enhanced
Security Services (ESS)) + RFC5035(ESS Update: AddingCertID Algorithm
Agility).
|
private byte[] |
doDigest(org.bouncycastle.cms.CMSProcessable content,
java.lang.String sigProvider) |
(package private) org.bouncycastle.asn1.cms.SignerInfo |
generate()
Generates the SignerInfo CMS structure information for a single signer.
|
byte[] |
getBytesToSign(org.bouncycastle.asn1.DERObjectIdentifier contentType,
byte[] hash,
java.util.Date signingDate,
java.lang.String sigProvider)
Calculates the bytes to be externally signed (digested and encrypted with
signer private key).
|
byte[] |
getBytesToSign(org.bouncycastle.asn1.DERObjectIdentifier contentType,
org.bouncycastle.cms.CMSProcessable content,
java.lang.String sigProvider)
Calculates the bytes to be externally signed (digested and encrypted with
signer private key).
|
byte[] |
getBytesToSign(org.bouncycastle.asn1.DERObjectIdentifier contentType,
java.util.Date signingTime,
org.bouncycastle.cms.CMSProcessable content,
java.lang.String sigProvider)
Calculates the bytes to be externally signed (digested and encrypted with
signer private key).
|
java.security.cert.X509Certificate |
getCertificate()
Gets the signer certificate.
|
(package private) java.lang.String |
getDigestAlgName()
Return the digest algorithm using one of the standard JCA string
representations rather the the algorithm identifier (if possible).
|
(package private) java.lang.String |
getDigestAlgOID() |
(package private) byte[] |
getDigestAlgParams() |
(package private) java.lang.String |
getEncryptionAlgName()
Return the digest encryption algorithm using one of the standard JCA
string representations rather the the algorithm identifier (if possible).
|
(package private) java.lang.String |
getEncryptionAlgOID() |
(package private) org.bouncycastle.asn1.cms.AttributeTable |
getSignedAttributes() |
(package private) org.bouncycastle.asn1.cms.AttributeTable |
getUnsignedAttributes() |
void |
setCertificate(java.security.cert.X509Certificate c)
Sets the signer certificate.
|
void |
setSignedBytes(byte[] signedBytes) |
java.security.cert.X509Certificate cert
IssuerAndSerialNumber
CMS information. This has to be set,
along signedBytes
, before calling generate()
.byte[] signedBytes
getBytesToSign(DERObjectIdentifier, CMSProcessable, String)
. *
This has to be set, along cert
, before calling
generate()
.java.lang.String digestOID
java.lang.String encOID
org.bouncycastle.asn1.cms.AttributeTable sAttr
org.bouncycastle.asn1.cms.AttributeTable unsAttr
org.bouncycastle.asn1.ASN1Set signedAttr
getBytesToSign(DERObjectIdentifier, CMSProcessable, String)
method,org.bouncycastle.asn1.ASN1Set unsignedAttr
getBytesToSign(DERObjectIdentifier, CMSProcessable, String)
method,public ExternalSignatureSignerInfoGenerator(java.lang.String digestOID, java.lang.String encOID)
digestOID
- the digesting algorithm OIDencOID
- the encryption algorithm OIDpublic java.security.cert.X509Certificate getCertificate()
public void setCertificate(java.security.cert.X509Certificate c)
c
- the X509 certificate corresponding to the private key used to
sign.java.lang.String getDigestAlgOID()
byte[] getDigestAlgParams()
java.lang.String getEncryptionAlgOID()
org.bouncycastle.asn1.cms.AttributeTable getSignedAttributes()
org.bouncycastle.asn1.cms.AttributeTable getUnsignedAttributes()
java.lang.String getDigestAlgName()
java.lang.String getEncryptionAlgName()
org.bouncycastle.asn1.cms.SignerInfo generate() throws java.security.cert.CertificateEncodingException, java.io.IOException
cert
signedBytes
.org.bouncycastle.asn1.cms.SignerInfo
object for
a signer.java.security.cert.CertificateEncodingException
java.io.IOException
private byte[] doDigest(org.bouncycastle.cms.CMSProcessable content, java.lang.String sigProvider) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, java.io.IOException, org.bouncycastle.cms.CMSException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
java.io.IOException
org.bouncycastle.cms.CMSException
public byte[] getBytesToSign(org.bouncycastle.asn1.DERObjectIdentifier contentType, java.util.Date signingTime, org.bouncycastle.cms.CMSProcessable content, java.lang.String sigProvider) throws java.io.IOException, java.security.SignatureException, java.security.InvalidKeyException, java.security.NoSuchProviderException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateEncodingException, org.bouncycastle.cms.CMSException
getBytesToSign(DERObjectIdentifier contentType, byte[] hash, Date signingDate, String sigProvider)
contentType
- the org.bouncycastle.asn1.DERObjectIdentifier
of
the content.content
- the content to be signed.content
- the content to be signed.signingTime
- The time of the signature; if null, the current system date
will be used.byte[]
containing the raw bytes to be signed.java.io.IOException
java.security.SignatureException
java.security.InvalidKeyException
java.security.NoSuchProviderException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateEncodingException
org.bouncycastle.cms.CMSException
public byte[] getBytesToSign(org.bouncycastle.asn1.DERObjectIdentifier contentType, org.bouncycastle.cms.CMSProcessable content, java.lang.String sigProvider) throws java.io.IOException, java.security.SignatureException, java.security.InvalidKeyException, java.security.NoSuchProviderException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateEncodingException, org.bouncycastle.cms.CMSException
getBytesToSign(DERObjectIdentifier contentType, byte[] hash, Date signingDate, String sigProvider)
contentType
- the org.bouncycastle.asn1.DERObjectIdentifier
of
the content.content
- the content to be signed.sigProvider
- the cryptographic provider to use for calculating the digest
of the content.byte[]
containing the raw bytes to be signed.java.io.IOException
java.security.SignatureException
java.security.InvalidKeyException
java.security.NoSuchProviderException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateEncodingException
org.bouncycastle.cms.CMSException
public byte[] getBytesToSign(org.bouncycastle.asn1.DERObjectIdentifier contentType, byte[] hash, java.util.Date signingDate, java.lang.String sigProvider) throws java.io.IOException, java.security.SignatureException, java.security.InvalidKeyException, java.security.NoSuchProviderException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateEncodingException, org.bouncycastle.cms.CMSException
contentType
- the org.bouncycastle.asn1.DERObjectIdentifier
of
the content.hash
- the content hash.sigProvider
- the cryptographic provider to use for calculating the digest
of the content.byte[]
containing the raw bytes to be signed.java.io.IOException
java.security.SignatureException
java.security.InvalidKeyException
java.security.NoSuchProviderException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateEncodingException
org.bouncycastle.cms.CMSException
private org.bouncycastle.asn1.cms.Attribute buildSigningCertificateV2Attribute(java.lang.String sigProvider) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, java.security.cert.CertificateEncodingException, java.io.IOException
sigProvider
- the provider to use for digest calculation.java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
java.security.cert.CertificateEncodingException
java.io.IOException
public void setSignedBytes(byte[] signedBytes)
signedBytes
- The signedBytes to set.