java/remoteprovisioning/CborUtil.java
/*
   * Builds the COSE Enc_structure which becomes the AAD for encryption/decryption operations.
   * In this case, the context indicates this is for a COSE_Encrypt message only, but it could
   * be trivially modified to accept an enum for context selection in the future if the need
   * arises.
   *
   * Enc_structure = [
   *     context : "Encrypt" / "Encrypt0" / "Enc_Recipient" /
   *         "Mac_Recipient" / "Rec_Recipient",
   *     protected : empty_or_serialized_map,
   *     external_aad : bstr
   * ]
   */
Builds the COSE Enc_structure which becomes the AAD for encryption/decryption operations.
In this case, the context indicates this is for a COSE_Encrypt message only, but it could
be trivially modified to accept an enum for context selection in the future if the need
arises.


Builds the COSE Enc_structure which becomes the AAD for encryption / decryption operations . In this case the context indicates this is for a COSE_Encrypt message only but it could be trivially modified to accept an enum for context selection in the future if the need arises .
private static byte[] buildEncStructure(byte[] emptyOrSerializedMap, byte[] externalAad) {
    CBORObject encStructure = CBORObject.NewArray();
    encStructure.Add("Encrypt");
    encStructure.Add(emptyOrSerializedMap);
    if (externalAad == null) {
      externalAad = new byte[0];
    }
    encStructure.Add(externalAad);
    return encStructure.EncodeToBytes();
  }
private static byte [ ] buildEncStructure ( byte [ ] emptyOrSerializedMap , byte [ ] externalAad ) { CBORObject encStructure = CBORObject . NewArray ( ) ; encStructure . Add ( "Encrypt" ) ; encStructure . Add ( emptyOrSerializedMap ) ; if ( externalAad == null ) { externalAad = new byte [ 0 ] ; } encStructure . Add ( externalAad ) ; return encStructure . EncodeToBytes ( ) ; }
Builds the COSE Enc_structure which becomes the AAD for encryption/decryption operations.
Builds the COSE Enc_structure which becomes the AAD for encryption / decryption operations .
// Absent external_aad should be represented as a bstr of length 0, not nil.