|
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.security.SignatureSpi
com.pheox.jcapi.JCAPISignature
public class JCAPISignature
This class provides the functionality for creating and verifying
RSA/DSA signatures by using RSA/DSA public keys and RSA/DSA private
keys that are stored in Microsoft Windows system stores.
Note: the implementation does not require the keys to be stored in
Microsoft Windows system stores in order to work. It can handle ordinary
Java native RSA and DSA key objects as well. If such a native key is used, then
it will be temporary imported into the Microsoft Windows system store for
the wanted operation and then removed when the operation has finished.
All cryptographic operations are delegated from JCAPI to (using JNI) Microsoft CryptoAPI (MS CAPI) and executed inside the MS CAPI layer
The following signature algorithms are supported:
JCAPISignature.NONEwithRSAJCAPISignature.MD2withRSAJCAPISignature.MD4withRSAJCAPISignature.MD5withRSAJCAPISignature.SHA1withRSAJCAPISignature.SHAMD5withRSAJCAPISignature.SHA256withRSAJCAPISignature.SHA384withRSAJCAPISignature.SHA512withRSAJCAPISignature.SHA1withDSA
Here is an example of how to create a JCAPI signature instance through
the JCE framework:
Signature s = Signature.getInstance("SHA1withRSA", "JCAPI");
To learn more about how this class can be used, please look at the following example
programs that can be found in JCAPI's examples directory, by default located in
C:\<application data directory>\JCAPI\examples:
cryptofactory\signature\DynamicSignatureDSA.javacryptofactory\signature\DynamicSignatureRSA.javasignature\SignatureDSA.javasignature\SignatureRSA.java
| Nested Class Summary | |
|---|---|
static class |
JCAPISignature.MD2withRSA
The MD2 hashing class used for defining MD2withRSA in signatures. |
static class |
JCAPISignature.MD4withRSA
The MD4 hashing class used for defining MD4withRSA in signatures. |
static class |
JCAPISignature.MD5withRSA
The MD5 hashing class used for defining MD5withRSA in signatures. |
static class |
JCAPISignature.NONEwithRSA
This class is used for defining NONEwithRSA in RSA signatures. |
static class |
JCAPISignature.SHA1withDSA
The SHA-1 hashing class used for defining SHA1withDSA in DSA signatures. |
static class |
JCAPISignature.SHA1withRSA
The SHA-1 hashing class used for defining SHA1withRSA in signatures. |
static class |
JCAPISignature.SHA256withRSA
The SHA-256 hashing class used for defining SHA256withRSA in signatures. |
static class |
JCAPISignature.SHA384withRSA
The SHA-384 hashing class used for defining SHA384withRSA in signatures. |
static class |
JCAPISignature.SHA512withRSA
The SHA-512 hashing class used for defining SHA512withRSA in signatures. |
static class |
JCAPISignature.SHAMD5withRSA
The SHA-1 & MD5 hashing class used for defining SHAMD5withRSA in signatures. |
| Field Summary |
|---|
| Fields inherited from class java.security.SignatureSpi |
|---|
appRandom |
| Method Summary | |
|---|---|
java.lang.Object |
engineGetParameter(java.lang.String param)
Will always return null since parameters
are not supported by the JCAPI signature class. |
void |
engineInitSign(java.security.PrivateKey privateKey)
Initializes this signature object with the specified private key for signing operations. |
void |
engineInitVerify(java.security.PublicKey publicKey)
Initializes this signature object with the specified public key for verification operations. |
void |
engineSetParameter(java.lang.String param,
java.lang.Object value)
Not supported. |
byte[] |
engineSign()
Returns the RSA or DSA signature bytes of all the data updated so far. |
int |
engineSign(byte[] outbuf,
int offset,
int len)
Finishes this signature operation and stores the resulting RSA or DSA signature bytes in the provided buffer outbuf,
starting at offset. |
void |
engineUpdate(byte b)
Updates the data to be signed or verified using the specified byte. |
void |
engineUpdate(byte[] b,
int off,
int len)
Updates the data to be signed or verified, using the specified array of bytes, starting at the specified offset. |
boolean |
engineVerify(byte[] sigBytes)
Verifies the passed-in RSA/DSA signature. |
boolean |
engineVerify(byte[] sigBytes,
int offset,
int length)
Verifies the passed-in RSA/DSA signature in the specified array of bytes, starting at the specified offset. |
| Methods inherited from class java.security.SignatureSpi |
|---|
clone, engineGetParameters, engineInitSign, engineSetParameter, engineUpdate |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public java.lang.Object engineGetParameter(java.lang.String param)
null since parameters
are not supported by the JCAPI signature class.
engineGetParameter in class java.security.SignatureSpiparam - is ignored.
null.
public void engineInitSign(java.security.PrivateKey privateKey)
throws java.security.InvalidKeyException
java.security.interfaces.RSAPrivateCrtKey
or JCAPIRSAPrivateKey, and DSA private keys of
type java.security.spec.DSAPrivateKeySpec or
JCAPIDSAPrivateKey.
engineInitSign in class java.security.SignatureSpiprivateKey - the RSA/DSA private key of the identity whose
signature will be generated.
java.security.InvalidKeyException - if the key is not an instance of
java.security.interfaces.RSAPrivateCrtKey,
JCAPIRSAPrivateKey, java.security.spec.DSAPrivateKeySpec,
or JCAPIDSAPrivateKey.
public void engineInitVerify(java.security.PublicKey publicKey)
throws java.security.InvalidKeyException
Note: The JCAPI provider only accept RSA and DSA public keys.
engineInitVerify in class java.security.SignatureSpipublicKey - the RSA/DSA public key of the identity whose
signature is going to be verified.
java.security.InvalidKeyException - if the key is not an instance of
java.security.interfaces.RSAPublicKey or
java.security.interfaces.DSAPublicKey.
public void engineSetParameter(java.lang.String param,
java.lang.Object value)
throws java.security.InvalidParameterException
InvalidParameterException
when called upon.
engineSetParameter in class java.security.SignatureSpiparam - is ignored.value - is ignored.
java.security.InvalidParameterException - is always thrown.
public byte[] engineSign()
throws java.security.SignatureException
The signature implementation is reset to its initial state
(the state it was in after a call to one of the engineInitSign
methods) and can be reused to generate further RSA/DSA signatures
with the same private key.
engineSign in class java.security.SignatureSpijava.security.SignatureException - if the engine is not initialized properly,
or if the signature could not be created.
JCAPIJNIOperationCancelledException - if the user cancels the
input of a password/PIN code required for accessing the
private key.
JCAPIJNIInvalidPINCodeException - if the private key is protected
and an invalid password/PIN code was given.
JCAPIJNIRuntimeException - if an unexpected error occur inside MS CAPI.
JCAPIJNIPKCS11RuntimeException - if an unexpected error occur inside
the JCAPI PKCS#11 layer.
public int engineSign(byte[] outbuf,
int offset,
int len)
throws java.security.SignatureException
outbuf,
starting at offset.
The signature implementation is reset to its initial state
(the state it was in after a call to one of the engineInitSign
methods) and can be reused to generate further RSA/DSA signatures
with the same private key.
engineSign in class java.security.SignatureSpioutbuf - buffer for the RSA/DSA signature result.offset - offset into outbuf where the signature is stored.len - number of bytes within outbuf allotted
for the RSA signature.
outbuf.
java.security.SignatureException - if an error occurs or len
is less than the actual RSA/DSA signature.
JCAPIJNIOperationCancelledException - if the user cancels the
input of a password/PIN code required for accessing the
private key.
JCAPIJNIInvalidPINCodeException - if the private key is protected
and an invalid password/PIN code was given.
JCAPIJNIRuntimeException - if an unexpected error occur inside MS CAPI.
public void engineUpdate(byte b)
throws java.security.SignatureException
engineUpdate in class java.security.SignatureSpib - the byte to use for the update.
java.security.SignatureException - if the engine is not initialized properly.
JCAPIJNIRuntimeException - if an unexpected error occur inside MS CAPI.
public void engineUpdate(byte[] b,
int off,
int len)
throws java.security.SignatureException
engineUpdate in class java.security.SignatureSpib - the array of bytes.off - the offset to start from in the array of bytes.len - the number of bytes to use, starting at offset.
java.security.SignatureException - if the engine is not initialized properly.
JCAPIJNIRuntimeException - if an unexpected error occur inside MS CAPI.
public boolean engineVerify(byte[] sigBytes)
throws java.security.SignatureException
engineVerify in class java.security.SignatureSpisigBytes - - the signature bytes to be verified.
true if the RSA/DSA signature was
verified, false if not.
java.security.SignatureException - if the engine is not initialized
properly, or the passed-in signature is improperly
encoded or of the wrong type, etc.
JCAPIJNIRuntimeException - if an unexpected error occur inside MS CAPI.
public boolean engineVerify(byte[] sigBytes,
int offset,
int length)
throws java.security.SignatureException
engineVerify in class java.security.SignatureSpisigBytes - the signature bytes to be verified.offset - the offset to start from in the array of bytes.length - the number of bytes to use, starting at offset.
true if the RSA/DSA signature was
verified, false if not.
java.security.SignatureException - if the engine is not initialized
properly, or the passed-in signature is improperly
encoded or of the wrong type, etc.
JCAPIJNIRuntimeException - if an unexpected error occur inside MS CAPI.
|
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||