Пример #1
0
        public static ECIESUnprocessResult unprocessMessage(string key, string tag, string message)
        {
            byte[] sharedKey = Encoding.ASCII.GetBytes(key);
            byte[] Kenc      = KDF.DeriveKey(sharedKey, KDF.DefaultRoundsEnc);
            byte[] Kmac      = KDF.DeriveKey(sharedKey, KDF.DefaultRoundsMac);

            AesEncryptionProvider aes = new AesEncryptionProvider(Kenc);

            byte[] tagByte     = Encoding.ASCII.GetBytes(tag);
            byte[] messageByte = Encoding.ASCII.GetBytes(message);
            if (MAC.VerifyTag(tagByte, Kmac))
            {
                return new()
                       {
                           DeprocessedMessage = aes.Decrypt(messageByte, Kenc),
                           Status             = MyEnum.Successful
                       }
            }
            ;
            else
            {
                return new()
                       {
                           DeprocessedMessage = "",
                           Status             = MyEnum.Fail
                       }
            };
        }
    }