Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/security/ec/impl/mplogic.h
38918 views
/*1* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.2* Use is subject to license terms.3*4* This library is free software; you can redistribute it and/or5* modify it under the terms of the GNU Lesser General Public6* License as published by the Free Software Foundation; either7* version 2.1 of the License, or (at your option) any later version.8*9* This library is distributed in the hope that it will be useful,10* but WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU12* Lesser General Public License for more details.13*14* You should have received a copy of the GNU Lesser General Public License15* along with this library; if not, write to the Free Software Foundation,16* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/* *********************************************************************24*25* The Original Code is the MPI Arbitrary Precision Integer Arithmetic library.26*27* The Initial Developer of the Original Code is28* Michael J. Fromberger.29* Portions created by the Initial Developer are Copyright (C) 199830* the Initial Developer. All Rights Reserved.31*32* Contributor(s):33*34*********************************************************************** */3536/* Bitwise logical operations on MPI values */3738#ifndef _MPLOGIC_H39#define _MPLOGIC_H4041/* $Id: mplogic.h,v 1.7 2004/04/27 23:04:36 gerv%gerv.net Exp $ */4243#include "mpi.h"4445/*46The logical operations treat an mp_int as if it were a bit vector,47without regard to its sign (an mp_int is represented in a signed48magnitude format). Values are treated as if they had an infinite49string of zeros left of the most-significant bit.50*/5152/* Parity results */5354#define MP_EVEN MP_YES55#define MP_ODD MP_NO5657/* Bitwise functions */5859mp_err mpl_not(mp_int *a, mp_int *b); /* one's complement */60mp_err mpl_and(mp_int *a, mp_int *b, mp_int *c); /* bitwise AND */61mp_err mpl_or(mp_int *a, mp_int *b, mp_int *c); /* bitwise OR */62mp_err mpl_xor(mp_int *a, mp_int *b, mp_int *c); /* bitwise XOR */6364/* Shift functions */6566mp_err mpl_rsh(const mp_int *a, mp_int *b, mp_digit d); /* right shift */67mp_err mpl_lsh(const mp_int *a, mp_int *b, mp_digit d); /* left shift */6869/* Bit count and parity */7071mp_err mpl_num_set(mp_int *a, int *num); /* count set bits */72mp_err mpl_num_clear(mp_int *a, int *num); /* count clear bits */73mp_err mpl_parity(mp_int *a); /* determine parity */7475/* Get & Set the value of a bit */7677mp_err mpl_set_bit(mp_int *a, mp_size bitNum, mp_size value);78mp_err mpl_get_bit(const mp_int *a, mp_size bitNum);79mp_err mpl_get_bits(const mp_int *a, mp_size lsbNum, mp_size numBits);80mp_err mpl_significant_bits(const mp_int *a);8182#endif /* _MPLOGIC_H */838485