Beispiel #1
0
        /// <summary>
        /// MAC generator.
        /// </summary>
        /// <param name="key">Key</param>
        /// <param name="message">Message</param>
        /// <returns>Generated message</returns>
        public static byte[] Generate(byte[] key, byte[] message)
        {
            CheckData(key, message);

            using var gost = new GostManager(key, null, message);
            return(gost.Generate());
        }
Beispiel #2
0
        /// <summary>
        /// CFB decode.
        /// </summary>
        /// <param name="key">Key</param>
        /// <param name="iv">Init vector</param>
        /// <param name="message">Message</param>
        /// <param name="sBlockType">SBlock type</param>
        /// <returns>Decoded</returns>
        public static byte[] Decode(byte[] key, byte[] iv, byte[] message, SBlockTypes sBlockType)
        {
            CheckData(key, iv, message);

            using var gost = new GostManager(key, iv, message, CipherTypes.Cfb, sBlockType);
            return(gost.Decode());
        }
Beispiel #3
0
        /// <summary>
        /// Substitution decode.
        /// </summary>
        /// <param name="key">Key</param>
        /// <param name="message">Message</param>
        /// <param name="sBlockType">SBlock type</param>
        /// <returns>Decoded</returns>
        public static byte[] Decode(byte[] key, byte[] message, SBlockTypes sBlockType)
        {
            CheckData(key, message);

            if (message.Length % 8 != 0)
            {
                throw new ArgumentException("Block must have 64 bit length");
            }

            using var gost = new GostManager(key, null, message, CipherTypes.Substitution, sBlockType);
            return(gost.Decode());
        }