@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); }
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; }