Package COSE
Class Encrypt0Message
- java.lang.Object
-
- COSE.Attribute
-
- COSE.Message
-
- COSE.EncryptCommon
-
- COSE.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.
-
-
Field Summary
-
Fields inherited from class COSE.EncryptCommon
context, rgbEncrypt
-
Fields inherited from class COSE.Message
emitContent, emitTag, messageTag, rgbContent
-
Fields inherited from class COSE.Attribute
DO_NOT_SEND, DontSendAttributes, externalData, objDontSend, objProtected, objUnprotected, PROTECTED, ProtectedAttributes, rgbProtected, UNPROTECTED, UnprotectedAttributes
-
-
Constructor Summary
Constructors Constructor Description Encrypt0Message()Create a Encrypt0Message object.Encrypt0Message(boolean emitTag, boolean emitContent)Create a Encrypt0Message object.
-
Method Summary
Modifier and Type Method Description voidDecodeFromCBORObject(com.upokecenter.cbor.CBORObject obj)Given a CBOR tree, parse the message.byte[]decrypt(byte[] rgbKey)Decrypt the message using the passed in key.protected com.upokecenter.cbor.CBORObjectEncodeCBORObject()Internal function used to construct the CBORObjectvoidencrypt(byte[] rgbKey)Encrypt the message using the passed in key.-
Methods inherited from class COSE.EncryptCommon
decryptWithKey, getEncryptedContent, ProcessCounterSignatures, setEncryptedContent, validate, validate
-
Methods inherited from class COSE.Message
addCountersignature, DecodeFromBytes, DecodeFromBytes, EncodeToBytes, EncodeToCBORObject, GetContent, getCountersign1, getCountersignerList, HasContent, SetContent, SetContent, setCountersign1
-
Methods inherited from class COSE.Attribute
addAttribute, addAttribute, addAttribute, AddProtected, AddProtected, AddProtected, AddUnprotected, AddUnprotected, AddUnprotected, findAttribute, findAttribute, findAttribute, findAttribute, getDoNotSendAttributes, getExternal, getProtectedAttributes, getUnprotectedAttributes, removeAttribute, removeAttribute, setExternal
-
-
-
-
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 emittedemitContent- is the content emitted
-
-
Method Detail
-
DecodeFromCBORObject
public void DecodeFromCBORObject(com.upokecenter.cbor.CBORObject obj) throws CoseExceptionDescription copied from class:MessageGiven a CBOR tree, parse the message. This is an abstract function that is implemented for each different supported COSE message.- Specified by:
DecodeFromCBORObjectin classMessage- Parameters:
obj- CBORObject to be converted to a message.- Throws:
CoseException- Internal COSE Exception
-
EncodeCBORObject
protected com.upokecenter.cbor.CBORObject EncodeCBORObject() throws CoseExceptionInternal function used to construct the CBORObject- Specified by:
EncodeCBORObjectin classMessage- Returns:
- the constructed CBORObject
- Throws:
CoseException- if the content has not yet been encrypted
-
decrypt
public byte[] decrypt(byte[] rgbKey) throws CoseExceptionDecrypt the message using the passed in key.- Parameters:
rgbKey- key for decryption- Returns:
- the decrypted content
- Throws:
CoseException- - Error during decryption
-
encrypt
public void encrypt(byte[] rgbKey) throws CoseException, IllegalStateExceptionEncrypt the message using the passed in key.- Parameters:
rgbKey- key used for encryption- Throws:
CoseException- - Error during decryptionIllegalStateException- - Error during decryption
-
-