kz.gamma.hardware.cms
Class SignerInformation

java.lang.Object
  extended by kz.gamma.hardware.cms.SignerInformation

public class SignerInformation
extends java.lang.Object

an expanded SignerInfo block from a CMS Signed message


Field Summary
private  CMSProcessable content
           
private  DERObjectIdentifier contentType
           
private  AlgorithmIdentifier digestAlgorithm
           
private  AlgorithmIdentifier encryptionAlgorithm
           
private  byte[] hash
           
private  SignerInfo info
           
private  byte[] resultDigest
           
private  SignerId sid
           
private  byte[] signature
           
private  ASN1Set signedAttributes
           
private  ASN1Set unsignedAttributes
           
 
Constructor Summary
SignerInformation(SignerInfo info, DERObjectIdentifier contentType, CMSProcessable content, byte[] digest)
           
 
Method Summary
private  DigestInfo derDecode(byte[] encoding)
           
private  boolean doVerify(java.security.PublicKey key, AttributeTable signedAttrTable, java.lang.String sigProvider)
           
private  byte[] encodeObj(DEREncodable obj)
           
 byte[] getContentDigest()
          return the content digest that was calculated during verification.
 java.lang.String getDigestAlgOID()
          return the object identifier for the signature.
 byte[] getDigestAlgParams()
          return the signature parameters, or null if there aren't any.
 byte[] getEncodedSignedAttributes()
          return the DER encoding of the signed attributes.
 java.lang.String getEncryptionAlgOID()
          return the object identifier for the signature.
 byte[] getEncryptionAlgParams()
          return the signature/encyrption algorithm parameters, or null if there aren't any.
 SignerId getSID()
           
 byte[] getSignature()
          return the encoded signature
 AttributeTable getSignedAttributes()
          return a table of the signed attributes - indexed by the OID of the attribute.
 byte[] getSignedAttributesByte()
           
 AttributeTable getUnsignedAttributes()
          return a table of the unsigned attributes indexed by the OID of the attribute.
 int getVersion()
          return the version number for this objects underlying SignerInfo structure.
private  boolean isNull(DEREncodable o)
           
static SignerInformation replaceUnsignedAttributes(SignerInformation signerInformation, AttributeTable unsignedAttributes)
          Return a signer information object with the passed in unsigned attributes replacing the ones that are current associated with the object passed in.
 SignerInfo toSignerInfo()
          Return the base ASN.1 CMS structure that this object contains.
 boolean verify(java.security.PublicKey key, java.lang.String sigProvider)
          verify that the given public key succesfully handles and confirms the signature associated with this signer.
 boolean verify(java.security.cert.X509Certificate cert, java.lang.String sigProvider)
          verify that the given certificate succesfully handles and confirms the signature associated with this signer and, if a signingTime attribute is available, that the certificate was valid at the time the signature was generated.
private  boolean verifyDigest(byte[] digest, java.security.PublicKey key, byte[] signature, java.lang.String sigProvider)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sid

private SignerId sid

info

private SignerInfo info

digestAlgorithm

private AlgorithmIdentifier digestAlgorithm

encryptionAlgorithm

private AlgorithmIdentifier encryptionAlgorithm

signedAttributes

private ASN1Set signedAttributes

unsignedAttributes

private ASN1Set unsignedAttributes

content

private CMSProcessable content

signature

private byte[] signature

contentType

private DERObjectIdentifier contentType

hash

private byte[] hash

resultDigest

private byte[] resultDigest
Constructor Detail

SignerInformation

SignerInformation(SignerInfo info,
                  DERObjectIdentifier contentType,
                  CMSProcessable content,
                  byte[] digest)
Parameters:
info -
contentType -
content -
digest -
Method Detail

encodeObj

private byte[] encodeObj(DEREncodable obj)
                  throws java.io.IOException
Parameters:
obj -
Returns:
Throws:
java.io.IOException

getSID

public SignerId getSID()
Returns:

getVersion

public int getVersion()
return the version number for this objects underlying SignerInfo structure.

Returns:

getDigestAlgOID

public java.lang.String getDigestAlgOID()
return the object identifier for the signature.

Returns:

getDigestAlgParams

public byte[] getDigestAlgParams()
return the signature parameters, or null if there aren't any.

Returns:

getContentDigest

public byte[] getContentDigest()
return the content digest that was calculated during verification.

Returns:

getEncryptionAlgOID

public java.lang.String getEncryptionAlgOID()
return the object identifier for the signature.

Returns:

getEncryptionAlgParams

public byte[] getEncryptionAlgParams()
return the signature/encyrption algorithm parameters, or null if there aren't any.

Returns:

getSignedAttributes

public AttributeTable getSignedAttributes()
return a table of the signed attributes - indexed by the OID of the attribute.

Returns:

getSignedAttributesByte

public byte[] getSignedAttributesByte()

getUnsignedAttributes

public AttributeTable getUnsignedAttributes()
return a table of the unsigned attributes indexed by the OID of the attribute.

Returns:

getSignature

public byte[] getSignature()
return the encoded signature

Returns:

getEncodedSignedAttributes

public byte[] getEncodedSignedAttributes()
                                  throws java.io.IOException
return the DER encoding of the signed attributes.

Returns:
Throws:
java.io.IOException - if an encoding error occurs.

doVerify

private boolean doVerify(java.security.PublicKey key,
                         AttributeTable signedAttrTable,
                         java.lang.String sigProvider)
                  throws CMSException,
                         java.security.NoSuchAlgorithmException,
                         java.security.NoSuchProviderException
Parameters:
key -
signedAttrTable -
sigProvider -
Returns:
Throws:
CMSException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException

isNull

private boolean isNull(DEREncodable o)
Parameters:
o -
Returns:

derDecode

private DigestInfo derDecode(byte[] encoding)
                      throws java.io.IOException,
                             CMSException
Parameters:
encoding -
Returns:
Throws:
java.io.IOException
CMSException

verifyDigest

private boolean verifyDigest(byte[] digest,
                             java.security.PublicKey key,
                             byte[] signature,
                             java.lang.String sigProvider)
                      throws java.security.NoSuchAlgorithmException,
                             java.security.NoSuchProviderException,
                             CMSException
Parameters:
digest -
key -
signature -
sigProvider -
Returns:
Throws:
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
CMSException

verify

public boolean verify(java.security.PublicKey key,
                      java.lang.String sigProvider)
               throws java.security.NoSuchAlgorithmException,
                      java.security.NoSuchProviderException,
                      CMSException
verify that the given public key succesfully handles and confirms the signature associated with this signer.

Parameters:
key -
sigProvider -
Returns:
Throws:
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
CMSException

verify

public boolean verify(java.security.cert.X509Certificate cert,
                      java.lang.String sigProvider)
               throws java.security.NoSuchAlgorithmException,
                      java.security.NoSuchProviderException,
                      java.security.cert.CertificateExpiredException,
                      java.security.cert.CertificateNotYetValidException,
                      CMSException
verify that the given certificate succesfully handles and confirms the signature associated with this signer and, if a signingTime attribute is available, that the certificate was valid at the time the signature was generated.

Parameters:
cert -
sigProvider -
Returns:
Throws:
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
java.security.cert.CertificateExpiredException
java.security.cert.CertificateNotYetValidException
CMSException

toSignerInfo

public SignerInfo toSignerInfo()
Return the base ASN.1 CMS structure that this object contains.

Returns:
an object containing a CMS SignerInfo structure.

replaceUnsignedAttributes

public static SignerInformation replaceUnsignedAttributes(SignerInformation signerInformation,
                                                          AttributeTable unsignedAttributes)
Return a signer information object with the passed in unsigned attributes replacing the ones that are current associated with the object passed in.

Parameters:
signerInformation - the signerInfo to be used as the basis.
unsignedAttributes - the unsigned attributes to add.
Returns:
a copy of the original SignerInformationObject with the changed attributes.


Copyright © 2013 Gamma Technologies. All Rights Reserved.