public final class MyDSASignature extends java.lang.Object implements IMySignature
Modifier and Type | Field and Description |
---|---|
private mybouncycastle.org.bouncycastle.crypto.digests.SHA1Digest |
m_Digest |
private mybouncycastle.org.bouncycastle.crypto.signers.DSASigner |
m_SignatureAlgorithm |
private static mybouncycastle.org.bouncycastle.asn1.x509.AlgorithmIdentifier |
ms_identifier |
Constructor and Description |
---|
MyDSASignature()
The key with that this algorithm has been initialised.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
decodeForXMLSignature(byte[] a_encodedSignature)
Tries to decode a signature in a way as it would meet the W3C standard for DSA XML
signature values.
|
(package private) static java.math.BigInteger[] |
derDecode(byte[] encoding,
int off,
int len) |
(package private) static byte[] |
derEncode(java.math.BigInteger r,
java.math.BigInteger s) |
byte[] |
encodeForXMLSignature(byte[] a_signature)
Encodes a signature in a way it meets the W3C standard for DSA XML signature values.
|
mybouncycastle.org.bouncycastle.asn1.x509.AlgorithmIdentifier |
getIdentifier()
Returns the algorithm identifier (DSA with SHA1).
|
java.lang.String |
getXMLSignatureAlgorithmReference()
Returns http://www.w3.org/2000/09/xmldsig#dsa-sha1.
|
void |
initSign(IMyPrivateKey k)
Initialises the algorithm for signing.
|
void |
initVerify(IMyPublicKey k)
Initialises the algorithm for verifying.
|
byte[] |
sign(byte[] bytesToSign)
Signs a message and returns the signature.
|
boolean |
verify(byte[] a_message,
byte[] a_signature)
Tests if the signature of a specified message is valid.
|
boolean |
verify(byte[] a_message,
int message_offset,
int message_len,
byte[] a_signature,
int signature_offset,
int signature_len)
Tests if the signature of a specified message is valid.
|
private static final mybouncycastle.org.bouncycastle.asn1.x509.AlgorithmIdentifier ms_identifier
private mybouncycastle.org.bouncycastle.crypto.signers.DSASigner m_SignatureAlgorithm
private mybouncycastle.org.bouncycastle.crypto.digests.SHA1Digest m_Digest
public MyDSASignature()
public void initVerify(IMyPublicKey k) throws java.security.InvalidKeyException
IMySignature
initVerify
in interface IMySignature
k
- a public keyjava.security.InvalidKeyException
- if the key is invalidpublic void initSign(IMyPrivateKey k) throws java.security.InvalidKeyException
IMySignature
initSign
in interface IMySignature
k
- a private keyjava.security.InvalidKeyException
- if the key is invalidpublic boolean verify(byte[] a_message, int message_offset, int message_len, byte[] a_signature, int signature_offset, int signature_len)
ISignatureVerificationAlgorithm
verify
in interface ISignatureVerificationAlgorithm
a_message
- a messagemessage_offset
- start of messagemessage_len
- length of messagea_signature
- a signaturesignature_offset
- start of signaturesignature_len
- length of signaturepublic boolean verify(byte[] a_message, byte[] a_signature)
IMySignature
verify
in interface IMySignature
verify
in interface ISignatureVerificationAlgorithm
a_message
- a messagea_signature
- a signaturepublic byte[] sign(byte[] bytesToSign)
IMySignature
sign
in interface IMySignature
sign
in interface ISignatureCreationAlgorithm
bytesToSign
- a messagepublic mybouncycastle.org.bouncycastle.asn1.x509.AlgorithmIdentifier getIdentifier()
getIdentifier
in interface ISignatureCreationAlgorithm
getIdentifier
in interface ISignatureVerificationAlgorithm
public byte[] encodeForXMLSignature(byte[] a_signature)
encodeForXMLSignature
in interface IMySignature
encodeForXMLSignature
in interface ISignatureCreationAlgorithm
a_signature
- an non-encoded signature in DER formathttp://www.w3.org/TR/xmldsig-core/#sec-DSA
public byte[] decodeForXMLSignature(byte[] a_encodedSignature)
decodeForXMLSignature
in interface IMySignature
decodeForXMLSignature
in interface ISignatureVerificationAlgorithm
a_encodedSignature
- an encoded signature in R-S formathttp://www.w3.org/TR/xmldsig-core/#sec-DSA
public java.lang.String getXMLSignatureAlgorithmReference()
getXMLSignatureAlgorithmReference
in interface IMySignature
getXMLSignatureAlgorithmReference
in interface ISignatureCreationAlgorithm
getXMLSignatureAlgorithmReference
in interface ISignatureVerificationAlgorithm
http://www.w3.org/TR/xmldsig-core/#sec-AlgID
static byte[] derEncode(java.math.BigInteger r, java.math.BigInteger s) throws java.io.IOException
java.io.IOException
static java.math.BigInteger[] derDecode(byte[] encoding, int off, int len) throws java.io.IOException
java.io.IOException
Copyright © 2023. All rights reserved.