Package org.webpki.cbor
Class CBORSigner<T extends CBORSigner<?>>
java.lang.Object
org.webpki.cbor.CBORSigner<T>
- 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) Set clone mode.setIntercepter
(CBORCryptoUtils.Intercepter intercepter) Set optional Intercepter.setKeyId
(CBORObject keyId) Set signaturekeyId
.setProvider
(String provider) Set cryptographic provider.sign
(CBORObject key, CBORMap mapToSign) Sign CBOR object.
-
Method Details
-
setIntercepter
Set optional Intercepter.- Parameters:
intercepter
- An instance of Intercepter- Returns:
this
of subclass
-
setKeyId
Set 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
of subclass
-
setProvider
Set cryptographic provider.- Parameters:
provider
- Name of provider like "BC"- Returns:
this
of subclass
-
setCloneMode
Set clone mode.By default the
sign(CBORObject, CBORMap)
method overwrites the inputmap
object.- Parameters:
flag
- Iftrue
input data will be cloned- Returns:
this
of subclass
-
sign
Sign 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
-