security/nss/lib/freebl/mpi/mplogic.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/freebl/mpi/mplogic.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,52 @@
     1.4 +/*
     1.5 + *  mplogic.h
     1.6 + *
     1.7 + *  Bitwise logical operations on MPI values
     1.8 + *
     1.9 + * This Source Code Form is subject to the terms of the Mozilla Public
    1.10 + * License, v. 2.0. If a copy of the MPL was not distributed with this
    1.11 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    1.12 +
    1.13 +#ifndef _H_MPLOGIC_
    1.14 +#define _H_MPLOGIC_
    1.15 +
    1.16 +#include "mpi.h"
    1.17 +
    1.18 +/*
    1.19 +  The logical operations treat an mp_int as if it were a bit vector,
    1.20 +  without regard to its sign (an mp_int is represented in a signed
    1.21 +  magnitude format).  Values are treated as if they had an infinite
    1.22 +  string of zeros left of the most-significant bit.
    1.23 + */
    1.24 +
    1.25 +/* Parity results                    */
    1.26 +
    1.27 +#define MP_EVEN       MP_YES
    1.28 +#define MP_ODD        MP_NO
    1.29 +
    1.30 +/* Bitwise functions                 */
    1.31 +
    1.32 +mp_err mpl_not(mp_int *a, mp_int *b);            /* one's complement  */
    1.33 +mp_err mpl_and(mp_int *a, mp_int *b, mp_int *c); /* bitwise AND       */
    1.34 +mp_err mpl_or(mp_int *a, mp_int *b, mp_int *c);  /* bitwise OR        */
    1.35 +mp_err mpl_xor(mp_int *a, mp_int *b, mp_int *c); /* bitwise XOR       */
    1.36 +
    1.37 +/* Shift functions                   */
    1.38 +
    1.39 +mp_err mpl_rsh(const mp_int *a, mp_int *b, mp_digit d);   /* right shift    */
    1.40 +mp_err mpl_lsh(const mp_int *a, mp_int *b, mp_digit d);   /* left shift     */
    1.41 +
    1.42 +/* Bit count and parity              */
    1.43 +
    1.44 +mp_err mpl_num_set(mp_int *a, int *num);         /* count set bits    */
    1.45 +mp_err mpl_num_clear(mp_int *a, int *num);       /* count clear bits  */
    1.46 +mp_err mpl_parity(mp_int *a);                    /* determine parity  */
    1.47 +
    1.48 +/* Get & Set the value of a bit */
    1.49 +
    1.50 +mp_err mpl_set_bit(mp_int *a, mp_size bitNum, mp_size value);
    1.51 +mp_err mpl_get_bit(const mp_int *a, mp_size bitNum);
    1.52 +mp_err mpl_get_bits(const mp_int *a, mp_size lsbNum, mp_size numBits);
    1.53 +mp_err mpl_significant_bits(const mp_int *a);
    1.54 +
    1.55 +#endif /* end _H_MPLOGIC_ */

mercurial