Oracle Security Developer Tools Crypto Java API Reference
10g Release 2 (10.1.2.0.2)

B15565-01


oracle.security.crypto.core
Class RSAMDSignature

java.lang.Object
  extended byoracle.security.crypto.core.Signature
      extended byoracle.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 rsaSHASigOID
static ASN1ObjectID rsaSHASigOldOID

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 pk, ASN1ObjectID sigAlgOID)
Deprecated. Use RSAMDSignature(RSAPublicKey, AlgorithmIdentifier)
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.
RSAMDSignature(RSAPublicKey pk, RSAPrivateKey priv)
Deprecated. Use RSAMDSignature(RSAPrivateKey) and setPublicKey(PublicKey)
RSAMDSignature(RSAPublicKey pk, RSAPrivateKey priv, byte[] doc)
Deprecated. Use RSAMDSignature(RSAPrivateKey, byte[]) and setPublicKey(PublicKey)

Method Summary
java.lang.String algName()
Returns the name of the signing algorithm.
ASN1ObjectID algorithmOID()
Deprecated. Instead, use getAlgID().getOID().
AlgorithmIdentifier getAlgID()
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)
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
getBytes, getDocument, getInstance, getInstance, getInstance, getSigBytes, setBytes, 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

rsaSHASigOldOID

public static final ASN1ObjectID rsaSHASigOldOID

Constructor Detail

RSAMDSignature

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

RSAMDSignature

public RSAMDSignature(RSAPublicKey pk,
                      RSAPrivateKey priv)
Deprecated. Use RSAMDSignature(RSAPrivateKey) and setPublicKey(PublicKey)
Creates a signature object.

RSAMDSignature

public RSAMDSignature(RSAPublicKey pk,
                      RSAPrivateKey priv,
                      byte[] doc)
               throws SignatureException
Deprecated. Use RSAMDSignature(RSAPrivateKey, byte[]) and setPublicKey(PublicKey)
Creates a signature object, and signs the byte[] doc.

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,
                      ASN1ObjectID sigAlgOID)
Deprecated. Use RSAMDSignature(RSAPublicKey, AlgorithmIdentifier)
Creates a signature object for verifying a signature made with the given public key. sigAlgOID specifies the required signature type for the signature.

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
Specified by:
setAlgID in class Signature
Throws:
AlgorithmIdentifierException

getAlgID

public AlgorithmIdentifier getAlgID()
Specified by:
getAlgID in class Signature

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"

algorithmOID

public ASN1ObjectID algorithmOID()
Deprecated. Instead, use getAlgID().getOID().
Returns the OID of this signature algorithm. The value returned depends on the message digest type.

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()

Oracle Security Developer Tools Crypto Java API Reference
10g Release 2 (10.1.2.0.2)

B15565-01


Copyright © 2005 , Oracle. All rights reserved.