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 binary polynomial 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 * Sheueling Chang-Shantz <sheueling.chang@sun.com>, 1674N/A * Stephen Fung <fungstep@hotmail.com>, and 1674N/A * Douglas Stebila <douglas@stebila.ca>, Sun Microsystems Laboratories. 1674N/A *********************************************************************** */ 1674N/A/* Compute the x-coordinate x/z for the point 2*(x/z) in Montgomery 1674N/A * projective coordinates. Uses algorithm Mdouble in appendix of Lopez, J. 1674N/A * and Dahab, R. "Fast multiplication on elliptic curves over GF(2^m) 1674N/A * without precomputation". modified to not require precomputation of 1674N/A * Montgomery projective coordinates. Uses algorithm Madd in appendix of 1674N/A * Lopex, J. and Dahab, R. "Fast multiplication on elliptic curves over 1674N/A * GF(2^m) without precomputation". */ 1674N/A/* Compute the x, y affine coordinates from the point (x1, z1) (x2, z2) 1674N/A * using Montgomery point multiplication algorithm Mxy() in appendix of 1674N/A * Lopex, J. and Dahab, R. "Fast multiplication on elliptic curves over 1674N/A * GF(2^m) without precomputation". Returns: 0 on error 1 if return value 1674N/A * should be the point at infinity 2 otherwise */ 1674N/A/* Computes R = nP based on algorithm 2P of Lopex, J. and Dahab, R. "Fast 1674N/A * multiplication on elliptic curves over GF(2^m) without 1674N/A * precomputation". Elliptic curve points P and R can be identical. Uses 1674N/A * Montgomery projective coordinates. */ 1674N/A /* if result should be point at infinity */ 1674N/A /* find top-most bit and go one past it */ 1674N/A /* if top most bit was at word break, go to next word */ 1674N/A /* convert out of "projective" coordinates */