|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.security.SignatureSpi | +--java.security.Signature | +--cryptix.provider.rsa.Any_RSA_PKCS1Signature
An abstract class to digest a message and sign/verify the resulting hash value, using any JCA MessageDigest algorithm with the RSA digital signature scheme, and the formatting and padding conventions defined by PKCS#1. These conventions are compatible with PEM (RFC-1423).
References:
Copyright © 1997
Systemics Ltd on behalf of the
Cryptix Development Team.
All rights reserved.
$Revision: 1.9 $
Inner classes inherited from class java.security.Signature |
java.security.Signature.Delegate |
Fields inherited from class java.security.Signature |
SIGN, state, UNINITIALIZED, VERIFY |
Fields inherited from class java.security.SignatureSpi |
appRandom |
Constructor Summary | |
protected |
Any_RSA_PKCS1Signature(java.lang.String mdAlgorithm)
Constructor for an Any_RSA_PKCS1Signature. |
Method Summary | |
protected java.lang.Object |
engineGetParameter(java.lang.String param)
|
protected void |
engineInitSign(java.security.PrivateKey key)
SPI: Initializes this signature object for signing, using the given private key. |
protected void |
engineInitVerify(java.security.PublicKey key)
SPI: Initializes this signature object for verification, using the given public key. |
protected void |
engineSetParameter(java.lang.String param,
java.lang.Object value)
|
protected byte[] |
engineSign()
Terminates the update process and returns the signature bytes of all the data signed so far. |
protected void |
engineUpdate(byte b)
Updates the data to be signed or verified, using one byte. |
protected void |
engineUpdate(byte[] in,
int offset,
int length)
Updates the data to be signed or verified, using the specified sub-array of bytes, starting at the specified offset. |
protected boolean |
engineVerify(byte[] signature)
Terminates the update process and verifies that the passed signature equals that of a generated one based on the updated data so far. |
protected abstract byte[] |
getAlgorithmEncoding()
Returns the ASN.1 bytes of the AlgorithmIdentifier token described in engineSign() method above. |
Methods inherited from class java.security.Signature |
clone, getAlgorithm, getInstance, getInstance, getParameter, getProvider, initSign, initSign, initVerify, initVerify, setParameter, setParameter, sign, sign, toString, update, update, update, verify |
Methods inherited from class java.security.SignatureSpi |
engineInitSign, engineSetParameter, engineSign |
Methods inherited from class java.lang.Object |
|
Constructor Detail |
protected Any_RSA_PKCS1Signature(java.lang.String mdAlgorithm)
mdAlgorithm
- the standard JCA algorithm name of the message
digest to be used.Method Detail |
protected void engineInitSign(java.security.PrivateKey key) throws java.security.InvalidKeyException
engineInitSign
in class java.security.SignatureSpi
key
- the private key to be used to generate signatures.java.security.InvalidKeyException
- If the key class does not implement
java.security.interfaces.RSAPrivateKey or
If the size of the minimal PKCS#1 frame generated by the
engineSign() method will be larger than the public key modulus.protected void engineInitVerify(java.security.PublicKey key) throws java.security.InvalidKeyException
engineInitVerify
in class java.security.SignatureSpi
key
- the public key this signature is assumed to have
been generated with.java.security.InvalidKeyException
- If the key class does not implement java.security.interfaces.RSAPrivateKey
or
If the size of the minimal PKCS#1 frame generated by the
engineSign() method will be larger than the public key modulus.protected void engineUpdate(byte b) throws java.security.SignatureException
engineUpdate
in class java.security.SignatureSpi
b
- the byte to use for the update process.java.security.SignatureException
- if the engine is not initialised properly.protected void engineUpdate(byte[] in, int offset, int length) throws java.security.SignatureException
engineUpdate
in class java.security.SignatureSpi
in
- the array of bytes.offset
- the offset to start from in in.length
- the number of bytes to use, starting at offset.java.security.SignatureException
- if the engine is not initialised properly.protected byte[] engineSign() throws java.security.SignatureException
NOTES: Sun's documentation talks about the bytes returned being X.509-encoded. For this RSA/PKCS#1 implementation, they conform to PKCS#1 section 10. Practically, the return value will be formed by concatenating a leading NULL byte, a block type BT, a padding block PS, another NULLbyte, and finally a data block D; ie:
return = 0x00 || BT || PS || 0x00 || D.For signing, PKCS#1 block type 01 encryption-block formatting scheme is employed. The block type BT is a single byte valued 0x01 and the padding block PS is enough 0xFF bytes to make the length of the complete RSA Multi Precision Integer equal to the length of the public modulus. The data block D consists of the MIC -- Message Integrity Check, or message digest value-- and the MIC algorithm ASN.1 encoded identifier. The formal syntax in ASN.1 notation is:
SEQUENCE { digestAlgorithm AlgorithmIdentifier, digest OCTET STRING } AlgorithmIdentifier ::= SEQUENCE { algorithm OBJECT IDENTIFIER, parameters ANY DEFINED BY algorithm OPTIONAL }
engineSign
in class java.security.SignatureSpi
java.security.SignatureException
- if the engine is not initialised properly.protected boolean engineVerify(byte[] signature) throws java.security.SignatureException
NOTES: Sun's documentation talks about the bytes received
being X.509-encoded. For this RSA/PKCS#1 implementation, the bytes
received are assumed to conform to PKCS#1 section 10, or have
been generated by a previous invocation of the engineSign
method.
engineVerify
in class java.security.SignatureSpi
signature
- the signature bytes to be verified.java.security.SignatureException
- if the engine is not initialised
properly, the received signature data is improperly
encoded or of the wrong type, etc.protected void engineSetParameter(java.lang.String param, java.lang.Object value) throws java.security.InvalidParameterException
engineSetParameter
in class java.security.SignatureSpi
protected java.lang.Object engineGetParameter(java.lang.String param) throws java.security.InvalidParameterException
engineGetParameter
in class java.security.SignatureSpi
protected abstract byte[] getAlgorithmEncoding()
engineSign()
method above.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |