Class COSESigner
java.lang.Object
com.authlete.cose.COSESigner
-
Constructor Summary
ConstructorsConstructorDescriptionCOSESigner
(KeyGetter keyGetter) A constructor with a key getter that is called later when signing is performed.COSESigner
(Key key) A constructor with a private key for signing. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
sign
(SigStructure structure, int algorithm) Generate a signature for the Sig Structure with the specified algorithm.byte[]
sign
(SigStructure structure, int algorithm, byte[] keyID) Generate a signature for the Sig Structure with the specified algorithm.static byte[]
Generate a signature for the data with the key and the algorithm.
-
Constructor Details
-
COSESigner
A constructor with a private key for signing.- Parameters:
key
- A private key for signing. Must not be null.
-
COSESigner
A constructor with a key getter that is called later when signing is performed.When signing is performed, the
get
method of the key getter is called with the first argumentCOSEKeyOperations.SIGN
.- Parameters:
keyGetter
- A key getter that returns a private key for signing. Must not be null.
-
-
Method Details
-
sign
Generate a signature for the Sig Structure with the specified algorithm.- Specified by:
sign
in interfaceSigStructureSigner
- Parameters:
structure
- A Sig Structure for which a signature is generated.algorithm
- The integer identifier of an algorithm such as -7 (which meansES256
). Identifiers are listed in IANA: COSE Algorithms.- Returns:
- A generated signature.
- Throws:
COSEException
-
sign
Generate a signature for the Sig Structure with the specified algorithm.- Parameters:
structure
- A Sig Structure for which a signature is generated.algorithm
- The integer identifier of an algorithm such as -7 (which meansES256
). Identifiers are listed in IANA: COSE Algorithms.keyID
- The key ID of the private key to use. This argument has a meaning only when thisCOSESigner
instance has been created with a key getter. The key ID is passed to theget
method of the key getter.- Returns:
- A generated signature.
- Throws:
COSEException
-
sign
Generate a 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
Sig_structure
.- Parameters:
key
- A private key for signing.alg
- The integer identifier of an algorithm such as -7 (which meansES256
). Identifiers are listed in IANA: COSE Algorithms.data
- Data for which a signature is generated.- Returns:
- A generated signature.
- Throws:
COSEException
-