Package org.webpki.crypto
Class SignatureWrapper
java.lang.Object
org.webpki.crypto.SignatureWrapper
Wrapper over
Signature
.-
Constructor Summary
ConstructorDescriptionSignatureWrapper
(AsymSignatureAlgorithms algorithm, PrivateKey privateKey) Initiates a signer.SignatureWrapper
(AsymSignatureAlgorithms algorithm, PrivateKey privateKey, String provider) Initites a signer.SignatureWrapper
(AsymSignatureAlgorithms algorithm, PublicKey publicKey) Initiates a verifier.SignatureWrapper
(AsymSignatureAlgorithms algorithm, PublicKey publicKey, String provider) Initiates a verifier. -
Method Summary
Modifier and TypeMethodDescriptionecdsaAsn1SignatureEncoding
(boolean flag) Sets ASN.1 encoding mode for ECDSA.byte[]
sign()
SeeSignature
.static byte[]
sign
(PrivateKey privateKey, AsymSignatureAlgorithms algorithm, byte[] data, String provider) Signature creation conveniance method.update
(byte data) SeeSignature
.update
(byte[] data) SeeSignature
.static void
validate
(PublicKey publicKey, AsymSignatureAlgorithms algorithm, byte[] data, byte[] signature, String provider) Signature validation conveniance method.boolean
verify
(byte[] signature) SeeSignature
.
-
Constructor Details
-
SignatureWrapper
public SignatureWrapper(AsymSignatureAlgorithms algorithm, PublicKey publicKey, String provider) throws GeneralSecurityException Initiates a verifier.- Parameters:
algorithm
-publicKey
-provider
-- Throws:
GeneralSecurityException
-
SignatureWrapper
public SignatureWrapper(AsymSignatureAlgorithms algorithm, PublicKey publicKey) throws GeneralSecurityException Initiates a verifier.- Parameters:
algorithm
-publicKey
-- Throws:
GeneralSecurityException
-
SignatureWrapper
public SignatureWrapper(AsymSignatureAlgorithms algorithm, PrivateKey privateKey, String provider) throws GeneralSecurityException Initites a signer.- Parameters:
algorithm
-privateKey
-provider
-- Throws:
GeneralSecurityException
-
SignatureWrapper
public SignatureWrapper(AsymSignatureAlgorithms algorithm, PrivateKey privateKey) throws GeneralSecurityException Initiates a signer.- Parameters:
algorithm
-privateKey
-- Throws:
GeneralSecurityException
-
-
Method Details
-
ecdsaAsn1SignatureEncoding
Sets ASN.1 encoding mode for ECDSA.Default is
false
.- Parameters:
flag
-- Returns:
-
update
SeeSignature
.- Parameters:
data
-- Returns:
- Throws:
GeneralSecurityException
-
update
SeeSignature
.- Parameters:
data
-- Returns:
- Throws:
GeneralSecurityException
-
getProvider
-
verify
SeeSignature
.- Parameters:
signature
-- Returns:
- Throws:
GeneralSecurityException
-
sign
SeeSignature
.- Returns:
- Throws:
GeneralSecurityException
-
sign
public static byte[] sign(PrivateKey privateKey, AsymSignatureAlgorithms algorithm, byte[] data, String provider) Signature creation conveniance method.This method generates JOSE/COSE compatible signatures.
For security related errors,
CryptoException
is thrown.- Parameters:
privateKey
- Signature keyalgorithm
- Signature algorithmdata
- Data to signprovider
- Optional provider ornull
- Returns:
- Signature
-
validate
public static void validate(PublicKey publicKey, AsymSignatureAlgorithms algorithm, byte[] data, byte[] signature, String provider) Signature validation conveniance method.This method validates JOSE/COSE compatible signatures.
For security related errors including invalid signatures,
CryptoException
is thrown.- Parameters:
publicKey
- Validtion keyalgorithm
- Signature algorithmdata
- The data what was signedsignature
- The signature to be validatedprovider
- Optional provider ornull
-