in java/cose/CoseRecipient.java [63:82]
public static CoseRecipient decode(DataItem data) throws CborException {
Array recipientArray = CborUtil.asArray(data);
List<DataItem> dataItems = recipientArray.getDataItems();
if (dataItems.size() != COSE_RECIPIENT_LENGTH) {
throw new CborException(
String.format(
"Recipient has the wrong length \nExpected: %s\nActual: %s",
COSE_RECIPIENT_LENGTH, dataItems.size()));
}
byte[] protectedHeaders =
CborUtil.asByteString(dataItems.get(COSE_RECIPIENT_PROTECTED_HEADERS_INDEX)).getBytes();
Map unprotectedHeaders =
CborUtil.asMap(dataItems.get(COSE_RECIPIENT_UNPROTECTED_HEADERS_INDEX));
byte[] ciphertext =
CborUtil.asByteString(dataItems.get(COSE_RECIPIENT_CIPHERTEXT_INDEX)).getBytes();
return new CoseRecipient(protectedHeaders, unprotectedHeaders, ciphertext);
}