4272N/A * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. 4272N/A * Use is subject to license terms. 4272N/A * This library is free software; you can redistribute it and/or 4272N/A * modify it under the terms of the GNU Lesser General Public 4272N/A * License as published by the Free Software Foundation; either 4272N/A * version 2.1 of the License, or (at your option) any later version. 4272N/A * This library is distributed in the hope that it will be useful, 4272N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of 4272N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 4272N/A * Lesser General Public License for more details. 4272N/A * You should have received a copy of the GNU Lesser General Public License 4272N/A * along with this library; if not, write to the Free Software Foundation, 4272N/A * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 4272N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 4272N/A/* ********************************************************************* 1674N/A * The Original Code is the elliptic curve math library for prime field curves. 1674N/A * The Initial Developer of the Original Code is 1674N/A * Portions created by the Initial Developer are Copyright (C) 2003 1674N/A * the Initial Developer. All Rights Reserved. 1674N/A * Douglas Stebila <douglas@stebila.ca> 1674N/A *********************************************************************** */ 1674N/A/* Fast modular reduction for p521 = 2^521 - 1. a can be r. Uses 1674N/A * algorithm 2.31 from Hankerson, Menezes, Vanstone. Guide to 1674N/A * Elliptic Curve Cryptography. */ 1674N/A /* m1, m2 are statically-allocated mp_int of exactly the size we need */ 1674N/A /* for polynomials larger than twice the field size or polynomials 1674N/A * not using all words, use regular reduction */ 1674N/A/* Compute the square of polynomial a, reduce modulo p521. Store the 1674N/A * result in r. r could be a. Uses optimized modular reduction for p521. 1674N/A/* Compute the product of two polynomials a and b, reduce modulo p521. 1674N/A * Store the result in r. r could be a or b; a could be b. Uses 1674N/A * optimized modular reduction for p521. */ 1674N/A/* Divides two field elements. If a is NULL, then returns the inverse of 1674N/A /* If a is NULL, then return the inverse of b, otherwise return a/b. */ 1674N/A /* MPI doesn't support divmod, so we implement it using invmod and 1674N/A/* Wire in fast field arithmetic and precomputation of base point for