Package COSE

Class Encrypt0Message


  • public class Encrypt0Message
    extends EncryptCommon
    The Encrypt0Message object corresponds to the Encrypt COSE message structure. This message structure provides protected and unprotected attributes. The structure only allows for the use of a pre-distributed shared secret to be used to encrypt and decrypt the message.
    • Constructor Detail

      • Encrypt0Message

        public Encrypt0Message()
        Create a Encrypt0Message object. This object corresponds to the encrypt message format in COSE. The leading CBOR tag will be emitted. The message content will be emitted.
      • Encrypt0Message

        public Encrypt0Message​(boolean emitTag,
                               boolean emitContent)
        Create a Encrypt0Message object. This object corresponds to the encrypt message format in COSE.
        Parameters:
        emitTag - is the leading CBOR tag emitted
        emitContent - is the content emitted
    • Method Detail

      • DecodeFromCBORObject

        public void DecodeFromCBORObject​(com.upokecenter.cbor.CBORObject obj)
                                  throws CoseException
        Description copied from class: Message
        Given a CBOR tree, parse the message. This is an abstract function that is implemented for each different supported COSE message.
        Specified by:
        DecodeFromCBORObject in class Message
        Parameters:
        obj - CBORObject to be converted to a message.
        Throws:
        CoseException - Internal COSE Exception
      • EncodeCBORObject

        protected com.upokecenter.cbor.CBORObject EncodeCBORObject()
                                                            throws CoseException
        Internal function used to construct the CBORObject
        Specified by:
        EncodeCBORObject in class Message
        Returns:
        the constructed CBORObject
        Throws:
        CoseException - if the content has not yet been encrypted
      • decrypt

        public byte[] decrypt​(byte[] rgbKey)
                       throws CoseException
        Decrypt the message using the passed in key.
        Parameters:
        rgbKey - key for decryption
        Returns:
        the decrypted content
        Throws:
        CoseException - - Error during decryption