private void Dispose(bool Disposing) { if (!m_isDisposed && Disposing) { try { if (m_blockCipher != null) { m_blockCipher.Clear(); m_blockCipher = null; } if (m_cipherInput != null) { Array.Clear(m_cipherInput, 0, m_cipherInput.Length); m_cipherInput = null; } if (m_digestState != null) { Array.Clear(m_digestState, 0, m_digestState.Length); m_digestState = null; } } finally { m_isDisposed = true; } } }
/// <remarks> /// Default generation function /// </remarks> private void GenerateConfiguration() { Threefish512 cipher = new Threefish512(); UbiTweak tweak = new UbiTweak(); // initialize the tweak value tweak.StartNewBlockType(UbiType.Config); tweak.IsFinalBlock = true; tweak.BitsProcessed = 32; 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]; }
/// <summary> /// Initializes the Skein hash instance /// </summary> /// /// <param name="InitializationType">Digest initialization type <see cref="SkeinInitializationType"/></param> public Skein512(SkeinInitializationType InitializationType = SkeinInitializationType.Normal) { m_initializationType = InitializationType; m_blockCipher = new Threefish512(); // allocate buffers m_inputBuffer = new byte[STATE_BYTES]; m_cipherInput = new ulong[STATE_WORDS]; m_digestState = new ulong[STATE_WORDS]; // allocate tweak m_ubiParameters = new UbiTweak(); // allocate config value m_configValue = new ulong[STATE_BYTES]; // initialize and enerate the configuration string m_configString = new ulong[STATE_BYTES]; m_configString[1] = (ulong)DigestSize * 8; SetSchema(83, 72, 65, 51); // "SHA3" SetVersion(1); GenerateConfiguration(); Initialize(InitializationType); }
/// <remarks> /// Default generation function /// </remarks> private void GenerateConfiguration() { var cipher = new Threefish512(); var tweak = new UbiTweak(); // Initialize the tweak value tweak.StartNewBlockType(UbiType.Config); tweak.IsFinalBlock = true; tweak.BitsProcessed = 32; cipher.SetTweak(tweak.Tweak); cipher.Encrypt(ConfigString, ConfigValue); ConfigValue[0] ^= ConfigString[0]; ConfigValue[1] ^= ConfigString[1]; ConfigValue[2] ^= ConfigString[2]; }
private void Dispose(bool Disposing) { if (!_isDisposed && Disposing) { try { if (_blockCipher != null) { _blockCipher.Clear(); _blockCipher = null; } if (_cipherInput != null) { Array.Clear(_cipherInput, 0, _cipherInput.Length); _cipherInput = null; } if (_digestState != null) { Array.Clear(_digestState, 0, _digestState.Length); _digestState = null; } } finally { _isDisposed = true; } } }
/// <summary> /// Initializes the Skein hash instance /// </summary> /// /// <param name="InitializationType">Digest initialization type <see cref="SkeinInitializationType"/></param> public Skein512(SkeinInitializationType InitializationType = SkeinInitializationType.Normal) { this.InitializationType = InitializationType; _cipherStateBits = STATE_SIZE; _cipherStateBytes = STATE_SIZE / 8; _cipherStateWords = STATE_SIZE / 64; _outputBytes = (STATE_SIZE + 7) / 8; _blockCipher = new Threefish512(); // Allocate buffers _inputBuffer = new byte[_cipherStateBytes]; _cipherInput = new UInt64[_cipherStateWords]; _digestState = new UInt64[_cipherStateWords]; // Allocate tweak UbiParameters = new UbiTweak(); // initialize and enerate the configuration string SkeinConfig(); SetSchema(83, 72, 65, 51); // "SHA3" SetVersion(1); GenerateConfiguration(); Initialize(InitializationType); }