Ejemplo n.º 1
0
        /// <summary>
        /// Reset the SP20Prng instance
        /// </summary>
        public void Reset()
        {
            if (m_seedGenerator != null)
            {
                m_seedGenerator.Dispose();
                m_seedGenerator = null;
            }
            if (m_rngGenerator != null)
            {
                m_rngGenerator.Dispose();
                m_rngGenerator = null;
            }

            m_seedGenerator = GetSeedGenerator(m_seedType);
            m_rngGenerator  = new SBG(m_rndCount);

            if (m_seedGenerator != null)
            {
                m_rngGenerator.Initialize(m_seedGenerator.GetBytes(m_keySize));
            }
            else
            {
                m_rngGenerator.Initialize(m_stateSeed);
            }

            m_rngGenerator.Generate(m_byteBuffer);
            m_bufferIndex = 0;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reinitialize the internal state
        /// </summary>
        public void Reset()
        {
            if (m_rndGenerator != null)
            {
                m_rndGenerator.Dispose();
                m_rndGenerator = null;
            }

            m_rndGenerator = new SBG(20);
            m_rndGenerator.Initialize(m_stateSeed);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Outputs expected values for the SP20Drbg
        /// </summary>
        public string GetSP20Vector(int KeySize)
        {
            SBG spd = new SBG();

            byte[] key    = new byte[KeySize];
            byte[] output = new byte[1024];
            for (int i = 0; i < KeySize; i++)
            {
                key[i] = (byte)i;
            }

            spd.Initialize(key);
            spd.Generate(output);

            while (output.Length > 32)
            {
                output = Reduce(output);
            }

            return(HexConverter.ToString(output));
        }