public NetMQMessage DecryptApplicationMessage([NotNull] NetMQMessage cipherMessage)
{
if (!SecureChannelReady)
{
throw new NetMQSecurityException(NetMQSecurityErrorCode.SecureChannelNotReady, "Cannot decrypt messages until the secure channel is ready");
}
if (cipherMessage == null)
{
throw new ArgumentNullException("cipherMessage");
}
if (cipherMessage.FrameCount < 2)
{
throw new NetMQSecurityException(NetMQSecurityErrorCode.InvalidFramesCount, "cipher message should have at least 2 frames");
}
NetMQFrame protocolVersionFrame = cipherMessage.Pop();
NetMQFrame contentTypeFrame = cipherMessage.Pop();
if (!protocolVersionFrame.ToByteArray().SequenceEqual(m_protocolVersion))
{
throw new NetMQSecurityException(NetMQSecurityErrorCode.InvalidProtocolVersion, "Wrong protocol version");
}
ContentType contentType = (ContentType)contentTypeFrame.Buffer[0];
if (contentType != ContentType.ApplicationData)
{
throw new NetMQSecurityException(NetMQSecurityErrorCode.InvalidContentType, "Not an application data message");
}
return m_recordLayer.DecryptMessage(ContentType.ApplicationData, cipherMessage);
}