private byte[] GenerateThenSignAndCipherXmlDocument(Dictionary <string, string> xmlElementsDictionary, string key, string iv) { XmlDocument document = XmlUtils.FormXmlDocument(xmlElementsDictionary); if (State.Equals(ProtocolState.WaitingSession)) { return(ConvertUtils.XmlDocumentToByteArray(document)); } document = XmlUtils.SignXmlWithSymmetricKey(document, key); return(AESUtils.CipherXmlDocument(document, key, iv)); }