tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

mplogic.h (1815B)


      1 /*
      2 *  mplogic.h
      3 *
      4 *  Bitwise logical operations on MPI values
      5 *
      6 * This Source Code Form is subject to the terms of the Mozilla Public
      7 * License, v. 2.0. If a copy of the MPL was not distributed with this
      8 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      9 
     10 #ifndef _H_MPLOGIC_
     11 #define _H_MPLOGIC_
     12 
     13 #include "mpi.h"
     14 SEC_BEGIN_PROTOS
     15 
     16 /*
     17  The logical operations treat an mp_int as if it were a bit vector,
     18  without regard to its sign (an mp_int is represented in a signed
     19  magnitude format).  Values are treated as if they had an infinite
     20  string of zeros left of the most-significant bit.
     21 */
     22 
     23 /* Parity results                    */
     24 
     25 #define MP_EVEN MP_YES
     26 #define MP_ODD MP_NO
     27 
     28 /* Bitwise functions                 */
     29 
     30 mp_err mpl_not(mp_int *a, mp_int *b);            /* one's complement  */
     31 mp_err mpl_and(mp_int *a, mp_int *b, mp_int *c); /* bitwise AND       */
     32 mp_err mpl_or(mp_int *a, mp_int *b, mp_int *c);  /* bitwise OR        */
     33 mp_err mpl_xor(mp_int *a, mp_int *b, mp_int *c); /* bitwise XOR       */
     34 
     35 /* Shift functions                   */
     36 
     37 mp_err mpl_rsh(const mp_int *a, mp_int *b, mp_digit d); /* right shift    */
     38 mp_err mpl_lsh(const mp_int *a, mp_int *b, mp_digit d); /* left shift     */
     39 
     40 /* Bit count and parity              */
     41 
     42 mp_err mpl_num_set(mp_int *a, unsigned int *num);   /* count set bits    */
     43 mp_err mpl_num_clear(mp_int *a, unsigned int *num); /* count clear bits  */
     44 mp_err mpl_parity(mp_int *a);                       /* determine parity  */
     45 
     46 /* Get & Set the value of a bit */
     47 
     48 mp_err mpl_set_bit(mp_int *a, mp_size bitNum, mp_size value);
     49 mp_err mpl_get_bit(const mp_int *a, mp_size bitNum);
     50 mp_err mpl_get_bits(const mp_int *a, mp_size lsbNum, mp_size numBits);
     51 mp_size mpl_significant_bits(const mp_int *a);
     52 
     53 SEC_END_PROTOS
     54 
     55 #endif /* end _H_MPLOGIC_ */