Пример #1
0
        public static ECIESProcessResult processMessage(string key, 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[] encryptedMessage = aes.Encrypt(message, Kenc);
            byte[] signedMessage    = MAC.GetTag(encryptedMessage, Kmac);

            return(new()
            {
                Tag = Encoding.ASCII.GetString(signedMessage),
                EncryptedMessage = Encoding.ASCII.GetString(encryptedMessage)
            });
        }