Class CBOREncrypter

java.lang.Object
org.webpki.cbor.CBOREncrypter
Direct Known Subclasses:
CBORAsymKeyEncrypter, CBORSymKeyEncrypter, CBORX509Encrypter

public abstract class CBOREncrypter extends Object
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 Details

    • setIntercepter

      public CBOREncrypter setIntercepter(CBORCryptoUtils.Intercepter intercepter)
      Sets optional Intercepter.
      Parameters:
      intercepter - An instance of Intercepter
      Returns:
      this
    • setKeyId

      public CBOREncrypter setKeyId(CBORObject keyId)
      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 of null is equivalent to the default (= no keyId).

      Parameters:
      keyId - Key Id or null
      Returns:
      this
    • setKeyId

      public CBOREncrypter setKeyId(int keyId)
      Sets optional key Id. The keyId will be represented as a CBOR integer.
      Parameters:
      keyId - Key Id
      Returns:
      this
    • setKeyId

      public CBOREncrypter setKeyId(String keyId)
      Sets optional key Id. The keyId will be represented as a CBOR text string.
      Parameters:
      keyId - Key Id
      Returns:
      this
    • encrypt

      public CBORObject encrypt(byte[] dataToEncrypt)
      Encrypts data.
      Parameters:
      dataToEncrypt - The data to encrypt
      Returns:
      CBOR encryption object