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