|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.crypto.PKCS1SignatureSigner
public final class PKCS1SignatureSigner
The PKCS1SignatureSigner
object can sign messages using the RSA PKCS#1 signature scheme.
We implemented the PKCS1 signing as per the PKCS #1 version 2.1 document.
For a code sample using the PKCS1 signature signer, click here.
For information on cryptographic algorithms, see Crypto Algorithms.
PKCS1SignatureVerifier
Constructor Summary | ||
---|---|---|
|
PKCS1SignatureSigner(RSAPrivateKey key)
Constructs an RSA PKCS1SignatureSigner (version 2.0) object which uses the SHA1 digest. |
|
|
PKCS1SignatureSigner(RSAPrivateKey key,
boolean useASN1)
Constructs an RSA PKCS1SignatureSigner object (version 2.0) signing object which uses the given digest. |
|
|
PKCS1SignatureSigner(RSAPrivateKey key,
Digest digest)
Constructs an RSA PKCS1SignatureSigner object (version 2.0) signing object which uses the given digest. |
|
|
PKCS1SignatureSigner(RSAPrivateKey key,
Digest digest,
boolean useASN1)
Constructs an RSA PKCS1SignatureSigner (version 1.5 or 2.0) object that uses the given digest. |
Method Summary | ||
---|---|---|
|
String |
getAlgorithm()
Returns a String containing the name of the algorithm (eg "RSA_PKCS1_V15/<DigestAlgorithm>" or "RSA_PKCS1_V20/<DigestAlgorithm>"). |
|
String |
getDigestAlgorithm()
Returns the name of the digest algorithm used, eg "SHA1", etc. |
|
int |
getLength()
Returns the length of the signature in bytes. |
|
static boolean |
isVersion20Supported()
Returns true if PKCS1 version 2.0 is supported. |
|
void |
reset()
Reinitializes the signer, preparing it to generate another signature. |
|
void |
sign(byte[] signature,
int signatureOffset)
Signs the formatted signature data that has been generated from the values passed through the update function. |
|
void |
update(byte[] data)
Adds additional message data to the signature. |
|
void |
update(byte[] data,
int offset,
int length)
Adds additional message data to the signature. |
|
void |
update(int data)
Adds additional message data to the signature. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PKCS1SignatureSigner(RSAPrivateKey key) throws CryptoUnsupportedOperationException
PKCS1SignatureSigner
(version 2.0) object which uses the SHA1
digest.
key
- The private key to use for signing.
CryptoUnsupportedOperationException
public PKCS1SignatureSigner(RSAPrivateKey key, boolean useASN1) throws CryptoUnsupportedOperationException
PKCS1SignatureSigner
object (version 2.0) signing object which uses the given digest.
key
- The private key to use for signing.useASN1
- A boolean that determines whether or not to ASN1-encode the digest before it is signed.
Set this to false for version 1.5 (which does not use ASN1) or true for version 2.0
(which does use ASN1).
CryptoUnsupportedOperationException
- Thrown if the OID for the given digest is unknown.public PKCS1SignatureSigner(RSAPrivateKey key, Digest digest) throws CryptoUnsupportedOperationException
PKCS1SignatureSigner
object (version 2.0) signing object which uses the given digest.
key
- The private key to use for signing.digest
- The digest to use to process the message.
CryptoUnsupportedOperationException
- Thrown if the OID for the given digest is unknown.public PKCS1SignatureSigner(RSAPrivateKey key, Digest digest, boolean useASN1) throws CryptoUnsupportedOperationException
PKCS1SignatureSigner
(version 1.5 or 2.0) object that uses the given digest.
key
- The private key to use for signingdigest
- The digest to use to process the message. If digest
is null, then
if useASN1
is set to true then a SHA1Digest is created, else a MD5Digest is created.useASN1
- A boolean that determines whether or not to ASN1-encode the digest before it is signed.
Set this to false for version 1.5 (which does not use ASN1) or true for version 2.0
(which does use ASN1).
CryptoUnsupportedOperationException
- Thrown if the OID for the given digest is unknown.Method Detail |
---|
public static boolean isVersion20Supported()
public String getAlgorithm()
getAlgorithm
in interface SignatureSigner
public String getDigestAlgorithm()
getDigestAlgorithm
in interface SignatureSigner
public void reset()
SignatureSigner
reset
in interface SignatureSigner
public void update(int data)
SignatureSigner
update
in interface SignatureSigner
data
- The byte to be hashed.public void update(byte[] data)
SignatureSigner
update
in interface SignatureSigner
data
- The message data to hash.public void update(byte[] data, int offset, int length)
SignatureSigner
update
in interface SignatureSigner
data
- The message data to hash.offset
- The offset, or the initial position to start reading in the data.length
- How much data to read.public int getLength()
public void sign(byte[] signature, int signatureOffset) throws CryptoTokenException, CryptoUnsupportedOperationException
signature
- A byte array to contain the signature.signatureOffset
- The offset, or starting position, of the signature
within the array.
CryptoTokenException
- Thrown if an error occurs with the crypto
token or the crypto token is invalid.
CryptoUnsupportedOperationException
- Thrown if a call is made to
an unsupported operation.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal