Package org.webpki.cbor
Class CBOREncrypter
java.lang.Object
org.webpki.cbor.CBOREncrypter
- Direct Known Subclasses:
CBORAsymKeyEncrypter
,CBORSymKeyEncrypter
,CBORX509Encrypter
Base class for encrypting data.
This implementation supports encryptions using CEF (CBOR Encryption Format) packaging, while algorithms are derived from COSE.
Note that encrypter 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 TypeMethodDescriptionencrypt
(byte[] dataToEncrypt) Encrypts data.setIntercepter
(CBORCryptoUtils.Intercepter intercepter) Sets optional Intercepter.setKeyId
(int keyId) Sets optional key Id.Sets optional key Id.setKeyId
(CBORObject keyId) Sets optional key Id.
-
Method Details
-
setIntercepter
Sets optional Intercepter.- Parameters:
intercepter
- An instance of Intercepter- Returns:
this
-
setKeyId
Sets optional key Id. In the case the public key is not provided in the object, the encryption key may be tied to an identifier known by the recipient. How such an identifier is used to retrieve the proper private key is up to a convention between the parties using a specific message scheme. A keyId may be a database index, a hash of the public key, or a text string.For symmetric key-algorithms, 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
-
setKeyId
Sets optional key Id. ThekeyId
will be represented as a CBORinteger
.- Parameters:
keyId
- Key Id- Returns:
this
-
setKeyId
Sets optional key Id. ThekeyId
will be represented as a CBORtext string
.- Parameters:
keyId
- Key Id- Returns:
this
-
encrypt
Encrypts data.- Parameters:
dataToEncrypt
- The data to encrypt- Returns:
- CBOR encryption object
-