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. 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>, Sun Microsystems Laboratories 1674N/A *********************************************************************** */ 1674N/A/* Construct a generic GFMethod for arithmetic over prime fields with 1674N/A/* Wrapper functions for generic prime field arithmetic. */ 1674N/A/* Field multiplication using Montgomery reduction. */ 1674N/A /* if MP_MONT_USE_MP_MUL is defined, then the function s_mp_mul_mont 1674N/A * is not implemented and we have to use mp_mul and s_mp_redc directly 1674N/A /* s_mp_mul_mont doesn't allow source and destination to be the same */ 1674N/A if ((a == r) || (b == r)) {
1674N/A/* Field squaring using Montgomery reduction. */ 1674N/A/* Field division using Montgomery reduction. */ 1674N/A /* if A=aZ represents a encoded in montgomery coordinates with Z and # 1674N/A * and \ respectively represent multiplication and division in 1674N/A * montgomery coordinates, then A\B = (a/b)Z = (A/B)Z and Binv = 1674N/A * (1/b)Z = (1/B)(Z^2) where B # Binv = Z */ 1674N/A/* Encode a field element in Montgomery form. See s_mp_to_mont in 1674N/A/* Decode a field element from Montgomery form. */ 1674N/A/* Free the memory allocated to the extra fields of Montgomery GFMethod