Tagged and Custom Container Data
The CBOR library contains support for wrapping CSF and CEF containers in aCBORTag as well as
including a customData element.
In both cases the added information becomes a part of the authenticated (signed) data.
Note that these options represent extensions that in order to be
accepted during validation respectively decryption, must
be preceded by setting a for the application suitable policy
(CBORCryptoUtils.POLICY).
Creating Tagged Containers
Creating a tagged CSF only requires wrapping the map to be signed in a suitableCBORTag object.
CEF containers can be tagged by wrapping an empty CBORMap in
a suitable CBORTag object, and use that as an additional
argument during encryption: CBOREncrypter.encrypt(byte[], CBORTag).
Decoding Tagged Containers
Decoding the tag of a tagged CSF or CEF container is performed by callingCBORValidator.setTagPolicy(CBORCryptoUtils.POLICY,CBORCryptoUtils.Collector) and
CBORDecrypter.setTagPolicy(CBORCryptoUtils.POLICY,CBORCryptoUtils.Collector) respectively,
where CBORCryptoUtils.Collector.foundData(CBORObject) returns
the actual tag object or null if the container is not tagged.
Creating Custom Data
Adding custom data to CSF or CEF containers is performed by callingCBORSigner.setIntercepter(CBORCryptoUtils.Intercepter) and
CBOREncrypter.setIntercepter(CBORCryptoUtils.Intercepter) respectively,
where CBORCryptoUtils.Intercepter.getCustomData() is supposed
to provide the actual data.
Decoding Custom Data
Decoding custom data in a CSF or CEF container is performed by callingCBORValidator.setCustomDataPolicy(CBORCryptoUtils.POLICY,CBORCryptoUtils.Collector) and
CBORDecrypter.setCustomDataPolicy(CBORCryptoUtils.POLICY,CBORCryptoUtils.Collector) respectively,
where CBORCryptoUtils.Collector.foundData(CBORObject) returns
the actual data or null if the container does not contain such data.