Package org.webpki.cbor
Class CBORSigner
java.lang.Object
org.webpki.cbor.CBORSigner
- Direct Known Subclasses:
CBORAsymKeySigner
,CBORHmacSigner
,CBORX509Signer
Base class for signing data.
This implementation supports signatures using CSF (CBOR Signature Format) packaging, while algorithms are derived from COSE.
Note that signer objects may be used any number of times (assuming that the same parameters are valid). They are also thread-safe.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionsetCloneMode
(boolean flag) Sets clone mode.setIntercepter
(CBORCryptoUtils.Intercepter intercepter) Sets optional Intercepter.setKeyId
(CBORObject keyId) Sets signaturekeyId
.setProvider
(String provider) Sets cryptographic provider.sign
(CBORObject key, CBORMap mapToSign) Signs CBOR object.
-
Method Details
-
setIntercepter
Sets optional Intercepter.- Parameters:
intercepter
- An instance of Intercepter- Returns:
this
-
setKeyId
Sets signaturekeyId
. In the case the public key is not provided in the signature object, the signature key may be tied to an identifier known by the relying party. How such an identifier is used to retrieve the proper public key is up to a convention between the parties using a specific message scheme. AkeyId
may be a database index, a hash of the public key, a text string, or a URL pointing to a public key in PEM format.For HMAC-signatures, a
keyId
or implicit key are the only ways to retrieve the proper secret key.Note that a
keyId
argument ofnull
is equivalent to the default (= nokeyId
).- Parameters:
keyId
- Key Id ornull
- Returns:
this
-
setProvider
Sets cryptographic provider.- Parameters:
provider
- Name of provider like "BC"- Returns:
- CBORSigner
-
setCloneMode
Sets clone mode.By default the
sign(CBORObject, CBORMap)
method overwrites the inputmap
object.- Parameters:
flag
- Iftrue
input data will be cloned- Returns:
- CBORSigner
-
sign
Signs CBOR object.Adds an enveloped CSF object (signature) to a CBOR map.
Also see
setCloneMode(boolean)
.- Parameters:
key
- Key holding the signature in the CBOR map to signmapToSign
- CBOR map to be signed- Returns:
- Signed object
-