Beispiel #1
0
        /// <summary>
        /// Sets the encryption and authentication keys and the security mode.
        /// </summary>
        /// <param name="encryptionKey">The key used for encryption.</param>
        /// <param name="authenticationKey">The key used to ensure data integrity.</param>
        /// <param name="mode">The enum used to easily control salt iterations to derive the keys. Default is 6000 iterations (Balanced Mode).</param>
        public CryptionSlater(byte[] encryptionKey, byte[] authenticationKey, CryptionSlaterMode mode)
        {
            this.EncryptionKey     = encryptionKey;
            this.AuthenticationKey = authenticationKey;

            EncryptionKeyStretchTargetMS     = 200;
            AuthenticationKeyStretchTargetMS = 200;

            hmacBitSize = new THmac().HashSize;
            ivByteSize  = new TSymmetricAlgorithm().IV.Length;

            BlockBitSize = GetLargestValidBlockSize();
            KeyBitSize   = GetLargestValidKeySize();
            SaltBitSize  = (Int16)KeyBitSize;

            EncryptionKeyStretchIterations     = (Int32)mode;
            AuthenticationKeyStretchIterations = (Int32)mode;

            if (mode == CryptionSlaterMode.AutoAdjust)
            {
                AutoAdjustEncryptionKeyStretching = true;
            }
            if (mode == CryptionSlaterMode.AutoAdjust)
            {
                AutoAdjustAuthenticationKeyStretching = true;
            }
        }
Beispiel #2
0
 /// <summary>
 /// Sets the encryption and authentication keys and sets the security mode.
 /// </summary>
 /// <param name="encryptionKey">The key used for encryption.</param>
 /// <param name="authenticationKey">The key used to ensure data integrity.</param>
 /// <param name="mode">The enum used to easily control salt iterations to derive the keys. Default is 6000 iterations (Balanced).</param>
 public CryptionSlater(string encryptionKey, string authenticationKey, CryptionSlaterMode mode)
     : this(Encoding.UTF8.GetBytes(encryptionKey), Encoding.UTF8.GetBytes(authenticationKey), mode)
 {
 }