annotate src/share/native/sun/security/ec/impl/mplogic.h @ 3909:272483f6650b

7033660: Update copyright year to 2011 on any files changed in 2011 Reviewed-by: dholmes
author ohair
date Wed, 06 Apr 2011 22:06:11 -0700
parents 1b5c838b8db8
children b49a0af85821
rev   line source
vinnie@1674 1 /* *********************************************************************
vinnie@1674 2 *
vinnie@1674 3 * Sun elects to have this file available under and governed by the
vinnie@1674 4 * Mozilla Public License Version 1.1 ("MPL") (see
vinnie@1674 5 * http://www.mozilla.org/MPL/ for full license text). For the avoidance
vinnie@1674 6 * of doubt and subject to the following, Sun also elects to allow
vinnie@1674 7 * licensees to use this file under the MPL, the GNU General Public
vinnie@1674 8 * License version 2 only or the Lesser General Public License version
vinnie@1674 9 * 2.1 only. Any references to the "GNU General Public License version 2
vinnie@1674 10 * or later" or "GPL" in the following shall be construed to mean the
vinnie@1674 11 * GNU General Public License version 2 only. Any references to the "GNU
vinnie@1674 12 * Lesser General Public License version 2.1 or later" or "LGPL" in the
vinnie@1674 13 * following shall be construed to mean the GNU Lesser General Public
vinnie@1674 14 * License version 2.1 only. However, the following notice accompanied
vinnie@1674 15 * the original version of this file:
vinnie@1674 16 *
vinnie@1674 17 *
vinnie@1674 18 * Bitwise logical operations on MPI values
vinnie@1674 19 *
vinnie@1674 20 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
vinnie@1674 21 *
vinnie@1674 22 * The contents of this file are subject to the Mozilla Public License Version
vinnie@1674 23 * 1.1 (the "License"); you may not use this file except in compliance with
vinnie@1674 24 * the License. You may obtain a copy of the License at
vinnie@1674 25 * http://www.mozilla.org/MPL/
vinnie@1674 26 *
vinnie@1674 27 * Software distributed under the License is distributed on an "AS IS" basis,
vinnie@1674 28 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
vinnie@1674 29 * for the specific language governing rights and limitations under the
vinnie@1674 30 * License.
vinnie@1674 31 *
vinnie@1674 32 * The Original Code is the MPI Arbitrary Precision Integer Arithmetic library.
vinnie@1674 33 *
vinnie@1674 34 * The Initial Developer of the Original Code is
vinnie@1674 35 * Michael J. Fromberger.
vinnie@1674 36 * Portions created by the Initial Developer are Copyright (C) 1998
vinnie@1674 37 * the Initial Developer. All Rights Reserved.
vinnie@1674 38 *
vinnie@1674 39 * Contributor(s):
vinnie@1674 40 *
vinnie@1674 41 * Alternatively, the contents of this file may be used under the terms of
vinnie@1674 42 * either the GNU General Public License Version 2 or later (the "GPL"), or
vinnie@1674 43 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
vinnie@1674 44 * in which case the provisions of the GPL or the LGPL are applicable instead
vinnie@1674 45 * of those above. If you wish to allow use of your version of this file only
vinnie@1674 46 * under the terms of either the GPL or the LGPL, and not to allow others to
vinnie@1674 47 * use your version of this file under the terms of the MPL, indicate your
vinnie@1674 48 * decision by deleting the provisions above and replace them with the notice
vinnie@1674 49 * and other provisions required by the GPL or the LGPL. If you do not delete
vinnie@1674 50 * the provisions above, a recipient may use your version of this file under
vinnie@1674 51 * the terms of any one of the MPL, the GPL or the LGPL.
vinnie@1674 52 *
vinnie@1674 53 *********************************************************************** */
vinnie@1674 54 /*
ohair@3909 55 * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
vinnie@1674 56 * Use is subject to license terms.
vinnie@1674 57 */
vinnie@1674 58
vinnie@1674 59 #ifndef _MPLOGIC_H
vinnie@1674 60 #define _MPLOGIC_H
vinnie@1674 61
vinnie@1674 62 /* $Id: mplogic.h,v 1.7 2004/04/27 23:04:36 gerv%gerv.net Exp $ */
vinnie@1674 63
vinnie@1674 64 #include "mpi.h"
vinnie@1674 65
vinnie@1674 66 /*
vinnie@1674 67 The logical operations treat an mp_int as if it were a bit vector,
vinnie@1674 68 without regard to its sign (an mp_int is represented in a signed
vinnie@1674 69 magnitude format). Values are treated as if they had an infinite
vinnie@1674 70 string of zeros left of the most-significant bit.
vinnie@1674 71 */
vinnie@1674 72
vinnie@1674 73 /* Parity results */
vinnie@1674 74
vinnie@1674 75 #define MP_EVEN MP_YES
vinnie@1674 76 #define MP_ODD MP_NO
vinnie@1674 77
vinnie@1674 78 /* Bitwise functions */
vinnie@1674 79
vinnie@1674 80 mp_err mpl_not(mp_int *a, mp_int *b); /* one's complement */
vinnie@1674 81 mp_err mpl_and(mp_int *a, mp_int *b, mp_int *c); /* bitwise AND */
vinnie@1674 82 mp_err mpl_or(mp_int *a, mp_int *b, mp_int *c); /* bitwise OR */
vinnie@1674 83 mp_err mpl_xor(mp_int *a, mp_int *b, mp_int *c); /* bitwise XOR */
vinnie@1674 84
vinnie@1674 85 /* Shift functions */
vinnie@1674 86
vinnie@1674 87 mp_err mpl_rsh(const mp_int *a, mp_int *b, mp_digit d); /* right shift */
vinnie@1674 88 mp_err mpl_lsh(const mp_int *a, mp_int *b, mp_digit d); /* left shift */
vinnie@1674 89
vinnie@1674 90 /* Bit count and parity */
vinnie@1674 91
vinnie@1674 92 mp_err mpl_num_set(mp_int *a, int *num); /* count set bits */
vinnie@1674 93 mp_err mpl_num_clear(mp_int *a, int *num); /* count clear bits */
vinnie@1674 94 mp_err mpl_parity(mp_int *a); /* determine parity */
vinnie@1674 95
vinnie@1674 96 /* Get & Set the value of a bit */
vinnie@1674 97
vinnie@1674 98 mp_err mpl_set_bit(mp_int *a, mp_size bitNum, mp_size value);
vinnie@1674 99 mp_err mpl_get_bit(const mp_int *a, mp_size bitNum);
vinnie@1674 100 mp_err mpl_get_bits(const mp_int *a, mp_size lsbNum, mp_size numBits);
vinnie@1674 101 mp_err mpl_significant_bits(const mp_int *a);
vinnie@1674 102
vinnie@1674 103 #endif /* _MPLOGIC_H */