コード例 #1
0
ファイル: Skein.cs プロジェクト: neoeinstein/xpdm
        public Skein(int state_size, int output_size)
        {
            // Make sure the output bit size > 0
            if (output_size <= 0)
                throw new CryptographicException("Output bit size must be greater than zero.");

            m_CipherStateBits = state_size;
            m_CipherStateBytes = state_size / 8;
            m_CipherStateWords = state_size / 64;

            base.HashSizeValue = output_size;
            m_OutputBytes = (output_size + 7) / 8;

            // Figure out which cipher we need based on
            // the state size
            m_Cipher = ThreefishCipher.CreateCipher(state_size);
            if (m_Cipher == null) throw new CryptographicException("Unsupported state size.");

            // Allocate buffers
            m_InputBuffer = new byte[m_CipherStateBytes];
            m_CipherInput = new ulong[m_CipherStateWords];
            m_State = new ulong[m_CipherStateWords];

            // Allocate tweak
            m_Tweak = new UBITweak();

            // Set default payload type (regular straight hashing)
            m_PayloadType = UBIType.Message;

            // Generate the configuration string
            m_Configuration = new SkeinConfig(this);
            m_Configuration.SetSchema("SHA3");
            m_Configuration.SetVersion(1);
            m_Configuration.GenerateConfiguration();

            // Initialize hash
            Initialize();
        }
コード例 #2
0
ファイル: UBITweak.cs プロジェクト: neoeinstein/xpdm
 public void StartNewType(UBIType type)
 {
     m_Tweak[0] = 0;
     m_Tweak[1] = ((ulong)type << 56) | T1_FLAG_FIRST;
 }