public void roundTripDetached() { EncryptMessage msg = new EncryptMessage(true, false); msg.AddAttribute(HeaderKeys.Algorithm, AlgorithmValues.AES_GCM_128, true); msg.AddAttribute(HeaderKeys.IV, CBORObject.FromObject(rgbIV96), false); msg.SetContent(strContent); msg.Encrypt(rgbKey128); byte[] content = msg.GetEncryptedContent(); byte[] rgb = msg.EncodeToBytes(); msg = (EncryptMessage)Message.DecodeFromBytes(rgb); msg.SetEncryptedContent(content); msg.Decrypt(rgbKey128); }
public void roundTripDetached() { EncryptMessage msg = new EncryptMessage(true, false); msg.AddAttribute(HeaderKeys.Algorithm, AlgorithmValues.AES_GCM_128, Attributes.PROTECTED); msg.AddAttribute(HeaderKeys.IV, CBORObject.FromObject(rgbIV96), Attributes.UNPROTECTED); msg.SetContent(strContent); Recipient r = new Recipient(key128, AlgorithmValues.Direct); msg.AddRecipient(r); msg.Encrypt(); byte[] content = msg.GetEncryptedContent(); byte[] rgb = msg.EncodeToBytes(); msg = (EncryptMessage)Message.DecodeFromBytes(rgb); msg.SetEncryptedContent(content); r = msg.RecipientList[0]; r.SetKey(key128); msg.Decrypt(r); }