Ejemplo n.º 1
0
        private void ProcessBlock(int bytes)
        {
            // set the key to the current state
            m_blockCipher.SetKey(m_digestState);
            // update tweak
            m_ubiParameters.BitsProcessed += (long)bytes;
            m_blockCipher.SetTweak(m_ubiParameters.Tweak);
            // encrypt block
            m_blockCipher.Encrypt(m_cipherInput, m_digestState);

            // feed-forward input with state
            for (int i = 0; i < m_cipherInput.Length; i++)
            {
                m_digestState[i] ^= m_cipherInput[i];
            }
        }
Ejemplo n.º 2
0
        public void GenerateConfiguration(ulong[] InitialState)
        {
            Threefish512 cipher = new Threefish512();
            UbiTweak     tweak  = new UbiTweak();

            // initialize the tweak value
            tweak.StartNewBlockType(UbiType.Config);
            tweak.IsFinalBlock  = true;
            tweak.BitsProcessed = 32;

            cipher.SetKey(InitialState);
            cipher.SetTweak(tweak.Tweak);
            cipher.Encrypt(m_configString, m_configValue);

            m_configValue[0] ^= m_configString[0];
            m_configValue[1] ^= m_configString[1];
            m_configValue[2] ^= m_configString[2];
        }
Ejemplo n.º 3
0
        public void GenerateConfiguration(UInt64[] InitialState)
        {
            var cipher = new Threefish512();
            var tweak = new UbiTweak();

            // Initialize the tweak value
            tweak.StartNewBlockType(UbiType.Config);
            tweak.IsFinalBlock = true;
            tweak.BitsProcessed = 32;

            cipher.SetKey(InitialState);
            cipher.SetTweak(tweak.Tweak);
            cipher.Encrypt(ConfigString, ConfigValue);

            ConfigValue[0] ^= ConfigString[0];
            ConfigValue[1] ^= ConfigString[1];
            ConfigValue[2] ^= ConfigString[2];
        }