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 prime 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> 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 ***** */ 1N/A * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 1N/A * Sun elects to use this software under the MPL license. 1N/A/* Fast modular reduction for p521 = 2^521 - 1. a can be r. Uses 1N/A * algorithm 2.31 from Hankerson, Menezes, Vanstone. Guide to 1N/A * Elliptic Curve Cryptography. */ 1N/A /* m1, m2 are statically-allocated mp_int of exactly the size we need */ 1N/A /* for polynomials larger than twice the field size or polynomials 1N/A * not using all words, use regular reduction */ 1N/A/* Compute the square of polynomial a, reduce modulo p521. Store the 1N/A * result in r. r could be a. Uses optimized modular reduction for p521. 1N/A/* Compute the product of two polynomials a and b, reduce modulo p521. 1N/A * Store the result in r. r could be a or b; a could be b. Uses 1N/A * optimized modular reduction for p521. */ 1N/A/* Divides two field elements. If a is NULL, then returns the inverse of 1N/A /* If a is NULL, then return the inverse of b, otherwise return a/b. */ 1N/A /* MPI doesn't support divmod, so we implement it using invmod and 1N/A/* Wire in fast field arithmetic and precomputation of base point for