ec2_test.c revision 2
1N/A * ***** BEGIN LICENSE BLOCK ***** 1N/A * Version: MPL 1.1/GPL 2.0/LGPL 2.1 1N/A * The contents of this file are subject to the Mozilla Public License Version 1N/A * 1.1 (the "License"); you may not use this file except in compliance with 1N/A * the License. You may obtain a copy of the License at 1N/A * Software distributed under the License is distributed on an "AS IS" basis, 1N/A * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 1N/A * for the specific language governing rights and limitations under the 1N/A * The Original Code is the elliptic curve math library for binary polynomial field curves. 1N/A * The Initial Developer of the Original Code is 1N/A * Sun Microsystems, Inc. 1N/A * Portions created by the Initial Developer are Copyright (C) 2003 1N/A * the Initial Developer. All Rights Reserved. 1N/A * Douglas Stebila <douglas@stebila.ca>, Sun Microsystems Laboratories 1N/A * Alternatively, the contents of this file may be used under the terms of 1N/A * either the GNU General Public License Version 2 or later (the "GPL"), or 1N/A * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 1N/A * in which case the provisions of the GPL or the LGPL are applicable instead 1N/A * of those above. If you wish to allow use of your version of this file only 1N/A * under the terms of either the GPL or the LGPL, and not to allow others to 1N/A * use your version of this file under the terms of the MPL, indicate your 1N/A * decision by deleting the provisions above and replace them with the notice 1N/A * and other provisions required by the GPL or the LGPL. If you do not delete 1N/A * the provisions above, a recipient may use your version of this file under 1N/A * the terms of any one of the MPL, the GPL or the LGPL. 1N/A * ***** END LICENSE BLOCK ***** */ 2N/A * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. 1N/A * Sun elects to use this software under the MPL license. 1N/A/* Time k repetitions of operation op. */ 1N/A for (i = 0; i < k; i++) { \
1N/A/* Test curve using generic field arithmetic. */ 1N/A printf(
" Error: could not construct params.\n"); \
1N/A printf(
" Error: could not construct group.\n"); \
1N/A/* Test curve using specific field arithmetic. */ 1N/A printf(
" Warning: could not construct group.\n"); \
1N/A printf(
"... failed; continuing with remaining tests.\n"); \
1N/A/* Performs basic tests of elliptic curve cryptography over binary 1N/A * polynomial fields. If tests fail, then it prints an error message, 1N/A * aborts, and returns an error code. Otherwise, returns 0. */ 1N/A /* initialize values */ 1N/A /* encode base point */ 1N/A /* output base point */ 1N/A /* multiply base point by order - 1 and check for negative of base 1N/A printf(
" Error: invalid result (expected (- base point)).\n");
1N/A /* multiply base point by order - 1 and check for negative of base 1N/A printf(
" Error: invalid result (expected (- base point)).\n");
1N/A /* multiply base point by order - 1 and check for negative of base 1N/A printf(
" Error: invalid result (expected (- base point)).\n");
1N/A /* multiply base point by order - 1 and check for negative of base 1N/A printf(
" Error: invalid result (expected (- base point)).\n");
1N/A /* multiply base point by order - 1 and check for negative of base 1N/A printf(
" Error: invalid result (expected (- base point)).\n");
1N/A /* multiply base point by order and check for point at infinity */ 1N/A printf(
" Error: invalid result (expected point at infinity).\n");
1N/A /* multiply base point by order and check for point at infinity */ 1N/A printf(
" Error: invalid result (expected point at infinity).\n");
1N/A /* multiply base point by order and check for point at infinity */ 1N/A printf(
" Error: invalid result (expected point at infinity).\n");
1N/A /* multiply base point by order and check for point at infinity */ 1N/A printf(
" Error: invalid result (expected point at infinity).\n");
1N/A /* multiply base point by order and check for point at infinity */ 1N/A printf(
" Error: invalid result (expected point at infinity).\n");
1N/A /* check that (order-1)P + (order-1)P + P == (order-1)P */ 1N/A (
" (order-1)*P + (order-1)*P + P == (order-1)*P (ECPoints_mul):\n");
1N/A printf(
" Error: invalid result (expected (- base point)).\n");
1N/A /* test validate_point function */ 1N/A printf(
" Error: validate point on base point failed.\n");
1N/A printf(
" Error: validate point on invalid point passed.\n");
1N/A /* compute random scalar */ 1N/A/* Performs tests of elliptic curve cryptography over binary polynomial 1N/A * fields. If tests fail, then it prints an error message, aborts, and 1N/A * returns an error code. Otherwise, returns 0. */ 1N/A /* generic arithmetic tests */ 1N/A /* specific arithmetic tests */