Ejemplo n.º 1
0
            public static NodeDssMessage DecryptMessage(string cipherText, string hmac, byte[] Key, byte[] IV)
            {
                byte[] cipherBytes   = System.Convert.FromBase64String(cipherText);
                byte[] hmacBytes     = System.Convert.FromBase64String(hmac);
                var    jsonPlainText = AES.DecryptStringFromBytes_Aes(cipherBytes, Key, IV);

                if (HMAC.Verify(Key, jsonPlainText, hmacBytes))
                {
                    NodeDssMessage nodeMessage = JsonUtility.FromJson <NodeDssMessage>(jsonPlainText);
                    return(nodeMessage);
                }
                else
                {
                    throw new InvalidOperationException("Cannot verify the sender of the SDP message; invalid HMAC");
                }
            }