コード例 #1
0
  @Test
  public void encryptDecodeBadRecipients() throws CoseException {
    CBORObject obj = CBORObject.NewArray();
    obj.Add(CBORObject.FromObject(CBORObject.NewArray()).EncodeToBytes());
    obj.Add(CBORObject.NewMap());
    obj.Add(new byte[0]);
    obj.Add(CBORObject.False);

    thrown.expect(CoseException.class);
    thrown.expectMessage("Invalid Encrypt structure");

    byte[] rgb = obj.EncodeToBytes();
    Message msg = Message.DecodeFromBytes(rgb, MessageTag.Encrypt);
  }
コード例 #2
0
ファイル: MACMessage.java プロジェクト: joakimb/COSE-JAVA
  protected CBORObject EncodeCBORObject() throws CoseException {
    if (rgbTag == null) throw new CoseException("Compute function not called");

    CBORObject obj = CBORObject.NewArray();
    if (objProtected.size() > 0) obj.Add(objProtected.EncodeToBytes());
    else obj.Add(CBORObject.FromObject(new byte[0]));

    obj.Add(objUnprotected);
    obj.Add(rgbContent);
    obj.Add(rgbTag);

    return obj;
  }