Class COSEVerifier
java.lang.Object
com.authlete.cose.COSEVerifier
-
Constructor Summary
ConstructorsConstructorDescriptionCOSEVerifier
(KeyGetter keyGetter) A constructor with a key getter that is called later when verification is performed.COSEVerifier
(Key key) A constructor with a public key for verification. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Verify aCOSE_Sign
object.boolean
Verify aCOSE_Sign1
object.boolean
Verify aCOSE_Sign1
object.boolean
Verify aCOSE_Sign
object.boolean
verify
(COSESign sign, COSESignature signature) Verify a combination ofCOSE_Sign
andCOSE_Signature
.boolean
verify
(COSESign sign, COSESignature signature, byte[] externalData) Verify a combination ofCOSE_Sign
andCOSE_Signature
.static boolean
Verify the signature for the data with the key and the algorithm.
-
Constructor Details
-
COSEVerifier
A constructor with a public key for verification.- Parameters:
key
- A public key for verification. Must not be null.
-
COSEVerifier
A constructor with a key getter that is called later when verification is performed.When verification is performed, the
get
method of the key getter is called with the first argumentCOSEKeyOperations.VERIFY
.- Parameters:
keyGetter
- A key getter that returns a public key for verification. Must not be null.
-
-
Method Details
-
verify
Verify aCOSE_Sign
object.This method is an alias of
verify
(sign, (byte[])null)
.- Parameters:
sign
- ACOSE_Sign
object to verify.- Returns:
true
if any of signatures in theCOSE_Sign
object is valid.false
if none of signatures in theCOSE_Sign
object are valid.- Throws:
COSEException
-
verify
Verify aCOSE_Sign
object.- Parameters:
sign
- ACOSE_Sign
object to verify.externalData
- Optional external data.- Returns:
true
if any of signatures in theCOSE_Sign
object is valid.false
if none of signatures in theCOSE_Sign
object are valid.- Throws:
COSEException
-
verify
Verify a combination ofCOSE_Sign
andCOSE_Signature
.This method is an alias of
verify
(sign, signature, (byte[])null)
.- Parameters:
sign
- ACOSE_Sign
object to verify.signature
- ACOSE_Signature
object to verify.- Returns:
true
if the signature of theCOSE_Signature
object is valid.false
if the signature is invalid.- Throws:
COSEException
-
verify
public boolean verify(COSESign sign, COSESignature signature, byte[] externalData) throws COSEException Verify a combination ofCOSE_Sign
andCOSE_Signature
.This method is called repeatedly from within
verify(COSESign, byte[])
for eachCOSE_Signature
object in theCOSE_Sign
object.- Parameters:
sign
- ACOSE_Sign
object to verify.signature
- ACOSE_Signature
object to verify.externalData
- Optional external data.- Returns:
true
if the signature of theCOSE_Signature
object is valid.false
if the signature is invalid.- Throws:
COSEException
-
verify
Verify aCOSE_Sign1
object.This method is an alias of
verify
(sign1, (byte[])null)
.- Parameters:
sign1
- ACOSE_Sign1
object to verify.- Returns:
true
if the signature of theCOSE_Sign1
object is valid.false
if the signature is invalid.- Throws:
COSEException
-
verify
Verify aCOSE_Sign1
object.- Parameters:
sign1
- ACOSE_Sign1
object to verify.externalData
- Optional external data.- Returns:
true
if the signature of theCOSE_Sign1
object is valid.false
if the signature is invalid.- Throws:
COSEException
-
verify
Verify the signature for the data with the key and the algorithm.This method can be used for general purposes without depending on COSE data structures such as
COSE_Sign
andCOSE_Sign1
.- Parameters:
key
- A public key for verification.alg
- The integer identifier of an algorithm such as -7 (which meansES256
). Identifiers are listed in IANA: COSE Algorithms.data
- Data for which the signature was generated.signature
- A signature to verify.- Returns:
true
if the signature is valid.false
if the signature is invalid.- Throws:
COSEException
-