Exemplo n.º 1
0
        /// <summary>
        /// Benchmark key transformation.
        /// </summary>
        /// <param name="pBuf256">Source and destination buffer.</param>
        /// <param name="pKey256">Key to use in the transformation.</param>
        /// <param name="puRounds">Number of transformations done.</param>
        /// <param name="uSeconds">Number of seconds to perform the benchmark.</param>
        /// <returns>Returns <c>true</c>, if the benchmark was successful.</returns>
        public static bool TransformKey256Timed(byte[] pBuf256, byte[] pKey256, ref UInt64 puRounds, uint uSeconds)
        {
            if (m_bAllowNative == false)
            {
                return(false);
            }

            KeyValuePair <IntPtr, IntPtr> kvp = NativeLib.PrepareArrays(pBuf256, pKey256);
            bool bResult = false;

            try
            {
                bResult = NativeLib.TransformKeyTimed(kvp.Key, kvp.Value, ref puRounds, uSeconds);
            }
            catch (Exception) { Debug.Assert(false); bResult = false; }

            Debug.Assert(bResult);
            if (bResult)
            {
                NativeLib.GetBuffers256(kvp, pBuf256, pKey256);
            }

            NativeLib.FreeArrays(kvp);
            return(bResult);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Transform a key.
        /// </summary>
        /// <param name="pBuf256">Source and destination buffer.</param>
        /// <param name="pKey256">Key to use in the transformation.</param>
        /// <param name="uRounds">Number of transformation rounds.</param>
        /// <returns>Returns <c>true</c>, if the key was transformed successfully.</returns>
        public static bool TransformKey256(byte[] pBuf256, byte[] pKey256, UInt64 uRounds)
        {
            if (m_bAllowNative == false)
            {
                return(false);
            }

            KeyValuePair <IntPtr, IntPtr> kvp = NativeLib.PrepareArrays(pBuf256, pKey256);
            bool bResult = false;

            try
            {
                bResult = NativeLib.TransformKey(kvp.Key, kvp.Value, uRounds);
            }
            catch (Exception) { bResult = false; }

            if (bResult)
            {
                NativeLib.GetBuffers256(kvp, pBuf256, pKey256);
            }

            NativeLib.FreeArrays(kvp);
            return(bResult);
        }