Skip navigation links

Oracle Security Developer Tools Crypto FIPS Java API Reference
11g (11.1.1)

E10696-02


oracle.security.crypto.core
Class RSAMDSignature

java.lang.Object
  extended by oracle.security.crypto.core.Signature
      extended by oracle.security.crypto.core.RSAMDSignature


public final class RSAMDSignature
extends Signature

Signatures using RSA encryption in conjunction with the MD2, MD5, or SHA message digest algorithm. The signature bytes are encoded in PKCS #1 format.


Field Summary
static ASN1ObjectID rsaKeyOID
          The ASN.1 Object Identifier rsaEncryption, as defined in PKCS #1 to identify the RSA encryption algorithm.
static ASN1ObjectID rsaMD2SigOID
          The ASN.1 Object Identifier md2WithRSAEncryption, defined in PKCS#1.
static ASN1ObjectID rsaMD5SigOID
          The ASN.1 Object Identifier md5WithRSAEncryption, defined in PKCS#1.
static ASN1ObjectID rsaSHA256SigOID
          The ASN.1 Object Identifier sha256WithRSAEncryption, defined in PKCS#1.
static ASN1ObjectID rsaSHASigOID
          The ASN.1 Object Identifier sha_1WithRSAEncryption, defined in PKCS#1.
static ASN1ObjectID rsaSHASigOldOID
          The old OIW ASN.1 Object Identifier SHA1 With RSAEncryption.

 

Fields inherited from class oracle.security.crypto.core.Signature
document, signatureBytes

 

Constructor Summary
RSAMDSignature()
          Creates a new RSAMDSignature with the default digest algorithm (MD5).
RSAMDSignature(RSAPrivateKey priv)
          Creates a new RSAMDSignature with the default digest algorithm (MD5), and sets the signature key.
RSAMDSignature(RSAPrivateKey priv, AlgorithmIdentifier messageDigestAlgID)
           
RSAMDSignature(RSAPrivateKey priv, AlgorithmIdentifier messageDigestAlgID, byte[] doc)
          Creates a new signature object with the given private key, message digest algorithm, and document, and generates the signature bytes.
RSAMDSignature(RSAPrivateKey priv, byte[] doc)
          Creates a new signature object with the given private key and document, and generates the signature bytes.
RSAMDSignature(RSAPublicKey pk)
          Creates a new RSAMDSignature with the default digest algorithm (MD5), and sets the verification key.
RSAMDSignature(RSAPublicKey pk, AlgorithmIdentifier messageDigestAlgID)
          Create a signature object for verifying a signature made with the given public key.
RSAMDSignature(RSAPublicKey k, byte[] sigBytes, byte[] doc)
          Creates a new instance ready to verify a signature using the given public key, signature bytes and original document.

 

Method Summary
 java.lang.String algName()
          Returns the name of the signing algorithm.
 AlgorithmIdentifier getAlgID()
          Gets the algorithm identifier of this Signature object.
 AlgorithmIdentifier getDigestEncryptionAlgID()
          Returns the algorithm identifier of the message digest encryption for this signature.
 AlgorithmIdentifier getMessageDigestAlgID()
          Gets the message digest algorithm for this RSA signature .
 void setAlgID(AlgorithmIdentifier algID)
          Sets the signature algorithm identifier to use,
 void setHash(byte[] hash)
          Sets the document digest to be used in the signature calculation, bypassing the digesting step.
 void setMessageDigestAlgID(AlgorithmIdentifier messageDigestAlgID)
          Sets the message digest Algorithm for this RSA signature .
 void setPrivateKey(PrivateKey privateKey)
          Sets the private key to be used for signing.
 void setPublicKey(PublicKey publicKey)
          Sets the public key to be used for verification.
 void setRandomBitsSource(RandomBitsSource rbs)
          Sets the random bits source used to generate signatures.
 byte[] sign()
          Signs the document.
 boolean verify()
          Verify that the signature matches the document.

 

Methods inherited from class oracle.security.crypto.core.Signature
getDocument, getInstance, getInstance, getInstance, getSigBytes, setDocument, setSigBytes

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

rsaKeyOID

public static final ASN1ObjectID rsaKeyOID
The ASN.1 Object Identifier rsaEncryption, as defined in PKCS #1 to identify the RSA encryption algorithm.

rsaMD2SigOID

public static final ASN1ObjectID rsaMD2SigOID
The ASN.1 Object Identifier md2WithRSAEncryption, defined in PKCS#1.

rsaMD5SigOID

public static final ASN1ObjectID rsaMD5SigOID
The ASN.1 Object Identifier md5WithRSAEncryption, defined in PKCS#1.

rsaSHASigOID

public static final ASN1ObjectID rsaSHASigOID
The ASN.1 Object Identifier sha_1WithRSAEncryption, defined in PKCS#1.

rsaSHA256SigOID

public static final ASN1ObjectID rsaSHA256SigOID
The ASN.1 Object Identifier sha256WithRSAEncryption, defined in PKCS#1.

rsaSHASigOldOID

public static final ASN1ObjectID rsaSHASigOldOID
The old OIW ASN.1 Object Identifier SHA1 With RSAEncryption.

Constructor Detail

RSAMDSignature

public RSAMDSignature()
Creates a new RSAMDSignature with the default digest algorithm (MD5).

RSAMDSignature

public RSAMDSignature(RSAPublicKey pk)
Creates a new RSAMDSignature with the default digest algorithm (MD5), and sets the verification key.

RSAMDSignature

public RSAMDSignature(RSAPublicKey pk,
                      AlgorithmIdentifier messageDigestAlgID)
Create a signature object for verifying a signature made with the given public key. The messageDigestAlgID parameter specifies the required hash type for the signature.
Throws:
java.lang.IllegalArgumentException - If messageDigestAlgID is not recognized.

RSAMDSignature

public RSAMDSignature(RSAPrivateKey priv)
Creates a new RSAMDSignature with the default digest algorithm (MD5), and sets the signature key.

RSAMDSignature

public RSAMDSignature(RSAPrivateKey priv,
                      AlgorithmIdentifier messageDigestAlgID)

RSAMDSignature

public RSAMDSignature(RSAPrivateKey priv,
                      byte[] doc)
               throws SignatureException
Creates a new signature object with the given private key and document, and generates the signature bytes. (That is, sign() is called automatically.) The default digest algorithm is used (MD5).
Throws:
SignatureException - if the signature could not be generated for some reason

RSAMDSignature

public RSAMDSignature(RSAPrivateKey priv,
                      AlgorithmIdentifier messageDigestAlgID,
                      byte[] doc)
               throws SignatureException
Creates a new signature object with the given private key, message digest algorithm, and document, and generates the signature bytes. (That is, sign() is called automatically.)
Throws:
SignatureException - if the signature could not be generated for some reason

RSAMDSignature

public RSAMDSignature(RSAPublicKey k,
                      byte[] sigBytes,
                      byte[] doc)
Creates a new instance ready to verify a signature using the given public key, signature bytes and original document.

Method Detail

setAlgID

public void setAlgID(AlgorithmIdentifier algID)
              throws AlgorithmIdentifierException
Description copied from class: Signature
Sets the signature algorithm identifier to use,
Specified by:
setAlgID in class Signature
Parameters:
algID - The AlgorithmIdentifier to use to perform signature and verification.
Throws:
AlgorithmIdentifierException

getAlgID

public AlgorithmIdentifier getAlgID()
Description copied from class: Signature
Gets the algorithm identifier of this Signature object.
Specified by:
getAlgID in class Signature
Returns:
An AlgorithIdentifier object representing the signature algorithm of this instance.

getDigestEncryptionAlgID

public AlgorithmIdentifier getDigestEncryptionAlgID()
Description copied from class: Signature
Returns the algorithm identifier of the message digest encryption for this signature. All concrete subclasses should override this method.
Overrides:
getDigestEncryptionAlgID in class Signature

setMessageDigestAlgID

public void setMessageDigestAlgID(AlgorithmIdentifier messageDigestAlgID)
Sets the message digest Algorithm for this RSA signature .

getMessageDigestAlgID

public AlgorithmIdentifier getMessageDigestAlgID()
Gets the message digest algorithm for this RSA signature .

algName

public java.lang.String algName()
Returns the name of the signing algorithm.
Specified by:
algName in class Signature
Returns:
"RSA/SHA", "RSA/MD2", or "RSA/MD5"

setPublicKey

public void setPublicKey(PublicKey publicKey)
                  throws InvalidKeyException
Sets the public key to be used for verification. The specified key must be an instance of RSAPublicKey.
Specified by:
setPublicKey in class Signature
Parameters:
publicKey - the public key
Throws:
InvalidKeyException

setPrivateKey

public void setPrivateKey(PrivateKey privateKey)
                   throws InvalidKeyException
Sets the private key to be used for signing. The specified key must be an instance of RSAPrivateKey.
Specified by:
setPrivateKey in class Signature
Parameters:
privateKey - the private key
Throws:
InvalidKeyException

setHash

public void setHash(byte[] hash)
Sets the document digest to be used in the signature calculation, bypassing the digesting step. Calling this method sets the document to null.
Specified by:
setHash in class Signature
Parameters:
hash - the DER encoding for a PKCS #1 DigestInfo element.
See Also:
Signature.setDocument(byte[])

setRandomBitsSource

public void setRandomBitsSource(RandomBitsSource rbs)
Sets the random bits source used to generate signatures.
Overrides:
setRandomBitsSource in class Signature
Parameters:
rbs - the random bits source to be used to generate signatures

verify

public boolean verify()
               throws AuthenticationException
Verify that the signature matches the document. The signature, public key and document must first have been specified via setSigBytes, setPublicKey and setDocument, or an appropriate constructor.
Specified by:
verify in class Signature
Returns:
true if the signature is valid, and false if it is invalid
Throws:
AuthenticationException - if the verification could not be performed for some reason
See Also:
Signature.setSigBytes(byte[]), setPublicKey(oracle.security.crypto.core.PublicKey), Signature.setDocument(byte[])

sign

public byte[] sign()
            throws SignatureException
Signs the document. The bytes of the signature are returned, and may also be retrieved via getSigBytes.

The document and private key must first have been specified via setDocument and setPrivateKey, or an appropriate constructor.

Specified by:
sign in class Signature
Returns:
the signature
Throws:
SignatureException - if the signature could not be generated for some reason
See Also:
Signature.setDocument(byte[]), setPrivateKey(oracle.security.crypto.core.PrivateKey), Signature.getSigBytes()

Skip navigation links

Oracle Security Developer Tools Crypto FIPS Java API Reference
11g (11.1.1)

E10696-02


Copyright © 2005, 2009, Oracle. All rights reserved.