|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.security.SignatureSpi
|
+--de.flexiprovider.api.Signature
|
+--de.flexiprovider.pqc.ots.merkle.MerkleOTSSignature
This class implements the MerkleOTS (one-time signature scheme). First the message that should be signed, is hashed with a message digest. Then the hash value is concatenate with the value z. z is the quantity of zeros in the bit representation of the hash value of the message. For every bit that is 1 in the bit representation of the concatenation, the corresponding private key part of the OTSPrivateKey is set. For every 0-bit, the corresponding public key part of the MerkleOTSPublicKey is set. So the signature is a concatenation of parts of the private and public key.
Verification of a given signature only succeeds if the hash value of the signature is the MerkleOTSPublicKey.
The MerkleOTSSignature can be used like the following:
Signature merkleSign = Signature.getInstance("MerkleOTSwithSHA256", "FlexiPQC");
// create signature
merkleSign.initSign(privateKey);
merkleSign.update(data, 0, data.length);
byte[] sign = merkleSign.sign();
// verify signature
merkleSign.initVerify(publicKey);
merkleSign.update(data, 0, data.length);
boolean verify = merkleSign.verify(sign);
System.out.println(verify);
| Inner Class Summary | |
static class |
MerkleOTSSignature.SHA1andSHA1PRNG
Merkle OTS signature with SHA1 and SHA1PRNG. |
static class |
MerkleOTSSignature.SHA256andSHA1PRNG
Merkle OTS signature with SHA256 and SHA1PRNG. |
static class |
MerkleOTSSignature.SHA384andSHA1PRNG
Merkle OTS signature with SHA384 and SHA1PRNG. |
static class |
MerkleOTSSignature.SHA512andSHA1PRNG
Merkle OTS signature with SHA512 and SHA1PRNG. |
| Fields inherited from class java.security.SignatureSpi |
appRandom |
| Constructor Summary | |
protected |
MerkleOTSSignature(java.lang.String oid,
MessageDigest md)
Constructor. |
| Method Summary | |
void |
initSign(PrivateKey key,
SecureRandom random)
Initialize the signature algorithm for signing a message. |
void |
initVerify(PublicKey key)
Initialize the signature algorithm for verifying a signature. |
void |
setParameters(AlgorithmParameterSpec params)
Initialize this signature engine with the specified parameter set (not used). |
byte[] |
sign()
Sign a message. |
void |
update(byte input)
Feed a message byte to the message digest. |
void |
update(byte[] input,
int inOff,
int inLen)
Feed an array of message bytes to the message digest. |
boolean |
verify(byte[] sigBytes)
Verify a signature. |
| Methods inherited from class de.flexiprovider.api.Signature |
engineGetParameter, engineInitSign, engineInitSign, engineInitVerify, engineSetParameter, engineSetParameter, engineSign, engineUpdate, engineUpdate, engineVerify, engineVerify, initSign, sign, update, verify, verify, verify |
| Methods inherited from class java.security.SignatureSpi |
clone, engineSign |
| Methods inherited from class java.lang.Object |
|
| Constructor Detail |
protected MerkleOTSSignature(java.lang.String oid,
MessageDigest md)
oid - the OID of the algorithmmd - name of the message digest| Method Detail |
public void initSign(PrivateKey key,
SecureRandom random)
throws InvalidKeyException
initSign in class Signaturekey - the private key of the signerrandom - a source of randomness (not used)InvalidKeyException - if the key is not an instance of OTSPrivateKey.
public void initVerify(PublicKey key)
throws InvalidKeyException
initVerify in class Signaturekey - the public key of the signer.InvalidKeyException - if the public key is not an instance of
MerkleOTSPublicKey.public void setParameters(AlgorithmParameterSpec params)
setParameters in class Signatureparams - the parameters (not used)public void update(byte input)
update in class Signatureinput - the message byte
public void update(byte[] input,
int inOff,
int inLen)
update in class Signatureinput - the array of message bytesinOff - index of message startinLen - number of message bytespublic byte[] sign()
sign in class Signaturepublic boolean verify(byte[] sigBytes)
verify in class SignaturesigBytes - the signature to be verified.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||