Beispiel #1
0
        // Finalize message strucutre then write.
        public static void EncryptSendMessage(byte[] message, NetworkStream stream)
        {
            // Encrypt Message Data
            byte[] encrypt = Encryption.AESEncrypt(message, Encryption.AESKey, Encryption.AESIV);

            // Encrypt Key Data
            byte[] finalBytes = Encryption.AppendKeyToMessage(encrypt, Encryption.AESKey, Encryption.AESIV, Encryption.clientCopyOfServerPublicKey);

            StreamHandler.WriteToStream(stream, finalBytes);
        }
Beispiel #2
0
        public static byte[] EncryptMessage(byte[] data, byte[] modulus, byte[] exponent)
        {
            // Encrypt Message Data
            byte[] encrypt = Encryption.AESEncrypt(data, Encryption.AESKey, Encryption.AESIV);

            // Combine key values.
            RSAParameters publicKeyCombined = Encryption.RSAParamaterCombiner(modulus, exponent);

            // Encrypt Key Data
            byte[] finalBytes = Encryption.AppendKeyToMessage(encrypt, Encryption.AESKey, Encryption.AESIV, publicKeyCombined);

            return(finalBytes);
        }