Exemple #1
0
        static public ECParams GenerateParameters(string curveName)
        {
            ECParams ecParams = new ECParams();

            CurveNames curveEnum = GetCurveName(curveName);

            ecParams.Oid        = ECRecommendedParameters.OID[(int)curveEnum];
            ecParams.parameters = NistNamedCurves.GetByName(curveName);
            FpCurve curve = ecParams.parameters.Curve as FpCurve;

            ecParams.q = ecParams.parameters.N;
            ecParams.g = ecParams.parameters.G as FpPoint;
            string pointGenerationHashInput = UProveHashInput + curveName;

            // g_1 ... g_n
            ecParams.g_i     = new FpPoint[NumberOfPregeneratedGenerators];
            ecParams.counter = new int[NumberOfPregeneratedGenerators];
            for (int i = 1; i <= NumberOfPregeneratedGenerators; i++)
            {
                ecParams.g_i[i - 1] = GetRandomPoint(pointGenerationHashInput, curve, i, null, out ecParams.counter[i - 1]);
                CheckIsOnCurve(curve, ecParams.g_i[i - 1]);
            }

            // g_t
            ecParams.g_t = GetRandomPoint(pointGenerationHashInput, curve, 255, null, out ecParams.counter_t);
            CheckIsOnCurve(curve, ecParams.g_t);

            // g_d
            ecParams.g_d = GetRandomPoint(pointGenerationHashInput, curve, 254, null, out ecParams.counter_d);
            CheckIsOnCurve(curve, ecParams.g_d);

            return(ecParams);
        }
Exemple #2
0
        static public void Print(Formatter formatter, string curveName)
        {
            CurveNames curveEnum = GetCurveName(curveName);
            ECParams   ecp       = ECRecommendedParameters.ecParams[(int)curveEnum];

            ecp.Oid = ECRecommendedParameters.OID[(int)curveEnum];
            formatter.PrintText("OID", ecp.Oid);
            formatter.PrintBigInteger("p", "UCHAR", null, (ecp.parameters.Curve as FpCurve).Q);
            formatter.PrintBigInteger("a", "UCHAR", null, ecp.parameters.Curve.A.ToBigInteger());
            formatter.PrintBigInteger("b", "UCHAR", null, ecp.parameters.Curve.B.ToBigInteger());
            formatter.PrintBigInteger("n", "UCHAR", null, ecp.parameters.N);
            formatter.PrintBigInteger("h", "UCHAR", null, ecp.parameters.H);
            formatter.PrintPoint("g", "UCHAR", null, ecp.parameters.G as FpPoint);

            // g_1 ... g_n
            for (int i = 1; i <= NumberOfPregeneratedGenerators; i++)
            {
                formatter.PrintPoint("g" + i, "UCHAR", null, ecp.g_i[i - 1], ecp.counter[i - 1]);
            }

            // g_t
            formatter.PrintPoint("gt", "UCHAR", null, ecp.g_t, ecp.counter_t);

            // g_d
            formatter.PrintPoint("gd", "UCHAR", null, ecp.g_d, ecp.counter_d);
        }
Exemple #3
0
 void DataGrid_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
 {
     if (e.ColumnIndex == CurveName.Index)
     {
         if (CurveNames.Any(name => name == (string)e.FormattedValue))
         {
             DataGrid.CancelEdit();
         }
     }
 }
Exemple #4
0
        /// <summary>
        /// Validates the proposed Curve property value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        private static bool validateCurve(object value)
        {
            CurveNames cName = (CurveNames)value;

            foreach (CurveNames item in Enum.GetValues(typeof(CurveNames)))
            {
                if (item == cName)
                {
                    return(true);
                }
            }
            return(false);
        }