raw
ch1_mpi                 1 /* mpi.h  -  Multi Precision Integers
ch1_mpi 2 * Modified by No Such Labs. (C) 2015. See README.
ch1_mpi 3 *
ch1_mpi 4 * This file was originally part of Gnu Privacy Guard (GPG), ver. 1.4.10,
ch1_mpi 5 * SHA256(gnupg-1.4.10.tar.gz):
ch1_mpi 6 * 0bfd74660a2f6cedcf7d8256db4a63c996ffebbcdc2cf54397bfb72878c5a85a
ch1_mpi 7 * (C) 1994-2005 Free Software Foundation, Inc.
ch1_mpi 8 *
ch1_mpi 9 * This program is free software: you can redistribute it and/or modify
ch1_mpi 10 * it under the terms of the GNU General Public License as published by
ch1_mpi 11 * the Free Software Foundation, either version 3 of the License, or
ch1_mpi 12 * (at your option) any later version.
ch1_mpi 13 *
ch1_mpi 14 * This program is distributed in the hope that it will be useful,
ch1_mpi 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ch1_mpi 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ch1_mpi 17 * GNU General Public License for more details.
ch1_mpi 18 *
ch1_mpi 19 * You should have received a copy of the GNU General Public License
ch1_mpi 20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
ch1_mpi 21 */
ch1_mpi 22
ch1_mpi 23 #ifndef G10_MPI_H
ch1_mpi 24 #define G10_MPI_H
ch1_mpi 25
ch1_mpi 26 #include <stdio.h>
ch1_mpi 27 #include "knobs.h"
ch1_mpi 28 #include "types.h"
ch1_mpi 29 #include "memory.h"
ch1_mpi 30
ch1_mpi 31 #ifndef EXTERN_UNLESS_MAIN_MODULE
ch1_mpi 32 #define EXTERN_UNLESS_MAIN_MODULE
ch1_mpi 33 #endif
ch1_mpi 34
ch1_mpi 35 #define DBG_MPI mpi_debug_mode
ch1_mpi 36 EXTERN_UNLESS_MAIN_MODULE int mpi_debug_mode;
ch1_mpi 37
ch1_mpi 38
ch1_mpi 39 struct gcry_mpi;
ch1_mpi 40 typedef struct gcry_mpi *MPI;
ch1_mpi 41
ch1_mpi 42
ch1_mpi 43 /*-- mpiutil.c --*/
ch1_mpi 44
ch1_mpi 45 #ifdef M_DEBUG
ch1_mpi 46 #define mpi_alloc(n) mpi_debug_alloc((n), M_DBGINFO( __LINE__ ) )
ch1_mpi 47 #define mpi_alloc_secure(n) mpi_debug_alloc_secure((n), M_DBGINFO( __LINE__ ) )
ch1_mpi 48 #define mpi_alloc_like(n) mpi_debug_alloc_like((n), M_DBGINFO( __LINE__ ) )
ch1_mpi 49 #define mpi_free(a) mpi_debug_free((a), M_DBGINFO(__LINE__) )
ch1_mpi 50 #define mpi_resize(a,b) mpi_debug_resize((a),(b), M_DBGINFO(__LINE__) )
ch1_mpi 51 #define mpi_copy(a) mpi_debug_copy((a), M_DBGINFO(__LINE__) )
ch1_mpi 52 MPI mpi_debug_alloc( unsigned nlimbs, const char *info );
ch1_mpi 53 MPI mpi_debug_alloc_secure( unsigned nlimbs, const char *info );
ch1_mpi 54 MPI mpi_debug_alloc_like( MPI a, const char *info );
ch1_mpi 55 void mpi_debug_free( MPI a, const char *info );
ch1_mpi 56 void mpi_debug_resize( MPI a, unsigned nlimbs, const char *info );
ch1_mpi 57 MPI mpi_debug_copy( MPI a, const char *info );
ch1_mpi 58 #else
ch1_mpi 59 MPI mpi_alloc( unsigned nlimbs );
ch1_mpi 60 MPI mpi_alloc_secure( unsigned nlimbs );
ch1_mpi 61 MPI mpi_alloc_like( MPI a );
ch1_mpi 62 void mpi_free( MPI a );
ch1_mpi 63 void mpi_resize( MPI a, unsigned nlimbs );
ch1_mpi 64 MPI mpi_copy( MPI a );
ch1_mpi 65 #endif
ch1_mpi 66 #define mpi_is_opaque(a) ((a) && (mpi_get_flags (a)&4))
ch1_mpi 67 MPI mpi_set_opaque( MPI a, void *p, unsigned int len );
ch1_mpi 68 void *mpi_get_opaque( MPI a, unsigned int *len );
ch1_mpi 69 #define mpi_is_secure(a) ((a) && (mpi_get_flags (a)&1))
ch1_mpi 70 void mpi_set_secure( MPI a );
ch1_mpi 71 void mpi_clear( MPI a );
ch1_mpi 72 void mpi_set( MPI w, MPI u);
ch1_mpi 73 void mpi_set_ui( MPI w, ulong u);
ch1_mpi 74 MPI mpi_alloc_set_ui( unsigned long u);
ch1_mpi 75 void mpi_m_check( MPI a );
ch1_mpi 76 void mpi_swap( MPI a, MPI b);
ch1_mpi 77 int mpi_get_nlimbs (MPI a);
ch1_mpi 78 int mpi_is_neg (MPI a);
ch1_mpi 79 unsigned int mpi_nlimb_hint_from_nbytes (unsigned int nbytes);
ch1_mpi 80 unsigned int mpi_nlimb_hint_from_nbits (unsigned int nbits);
ch1_mpi 81 unsigned int mpi_get_flags (MPI a);
ch1_mpi 82
ch1_mpi 83 /*-- mpicoder.c --*/
ch1_mpi 84 MPI mpi_read_from_buffer(byte *buffer, unsigned *ret_nread, int secure);
ch1_mpi 85 int mpi_fromstr(MPI val, const char *str);
ch1_mpi 86 int mpi_print( FILE *fp, MPI a, int mode );
ch1_mpi 87 //void g10_log_mpidump( const char *text, MPI a );
ch1_mpi 88 byte *mpi_get_buffer( MPI a, unsigned *nbytes, int *sign );
ch1_mpi 89 byte *mpi_get_secure_buffer( MPI a, unsigned *nbytes, int *sign );
ch1_mpi 90 void mpi_set_buffer( MPI a, const byte *buffer, unsigned nbytes, int sign );
ch1_mpi 91
ch1_mpi 92 #define log_mpidump g10_log_mpidump
ch1_mpi 93
ch1_mpi 94 /*-- mpi-add.c --*/
ch1_mpi 95 void mpi_add_ui(MPI w, MPI u, ulong v );
ch1_mpi 96 void mpi_add(MPI w, MPI u, MPI v);
ch1_mpi 97 void mpi_addm(MPI w, MPI u, MPI v, MPI m);
ch1_mpi 98 void mpi_sub_ui(MPI w, MPI u, ulong v );
ch1_mpi 99 void mpi_sub( MPI w, MPI u, MPI v);
ch1_mpi 100 void mpi_subm( MPI w, MPI u, MPI v, MPI m);
ch1_mpi 101
ch1_mpi 102 /*-- mpi-mul.c --*/
ch1_mpi 103 void mpi_mul_ui(MPI w, MPI u, ulong v );
ch1_mpi 104 void mpi_mul_2exp( MPI w, MPI u, ulong cnt);
ch1_mpi 105 void mpi_mul( MPI w, MPI u, MPI v);
ch1_mpi 106 void mpi_mulm( MPI w, MPI u, MPI v, MPI m);
ch1_mpi 107
ch1_mpi 108 /*-- mpi-div.c --*/
ch1_mpi 109 ulong mpi_fdiv_r_ui( MPI rem, MPI dividend, ulong divisor );
ch1_mpi 110 void mpi_fdiv_r( MPI rem, MPI dividend, MPI divisor );
ch1_mpi 111 void mpi_fdiv_q( MPI quot, MPI dividend, MPI divisor );
ch1_mpi 112 void mpi_fdiv_qr( MPI quot, MPI rem, MPI dividend, MPI divisor );
ch1_mpi 113 void mpi_tdiv_r( MPI rem, MPI num, MPI den);
ch1_mpi 114 void mpi_tdiv_qr( MPI quot, MPI rem, MPI num, MPI den);
ch1_mpi 115 void mpi_tdiv_q_2exp( MPI w, MPI u, unsigned count );
ch1_mpi 116 int mpi_divisible_ui(MPI dividend, ulong divisor );
ch1_mpi 117
ch1_mpi 118 /*-- mpi-gcd.c --*/
ch1_mpi 119 int mpi_gcd( MPI g, MPI a, MPI b );
ch1_mpi 120
ch1_mpi 121 /*-- mpi-pow.c --*/
ch1_mpi 122 void mpi_pow( MPI w, MPI u, MPI v);
ch1_mpi 123 void mpi_powm( MPI res, MPI base, MPI exponent, MPI mod);
ch1_mpi 124
ch1_mpi 125 /*-- mpi-mpow.c --*/
ch1_mpi 126 void mpi_mulpowm( MPI res, MPI *basearray, MPI *exparray, MPI mod);
ch1_mpi 127
ch1_mpi 128 /*-- mpi-cmp.c --*/
ch1_mpi 129 int mpi_cmp_ui( MPI u, ulong v );
ch1_mpi 130 int mpi_cmp( MPI u, MPI v );
ch1_mpi 131
ch1_mpi 132 /*-- mpi-scan.c --*/
ch1_mpi 133 int mpi_getbyte( MPI a, unsigned idx );
ch1_mpi 134 void mpi_putbyte( MPI a, unsigned idx, int value );
ch1_mpi 135 unsigned mpi_trailing_zeros( MPI a );
ch1_mpi 136
ch1_mpi 137 /*-- mpi-bit.c --*/
ch1_mpi 138 void mpi_normalize( MPI a );
ch1_mpi 139 unsigned mpi_get_nbits( MPI a );
ch1_mpi 140 int mpi_test_bit( MPI a, unsigned n );
ch1_mpi 141 void mpi_set_bit( MPI a, unsigned n );
ch1_mpi 142 void mpi_set_highbit( MPI a, unsigned n );
ch1_mpi 143 void mpi_clear_highbit( MPI a, unsigned n );
ch1_mpi 144 void mpi_clear_bit( MPI a, unsigned n );
ch1_mpi 145 void mpi_rshift( MPI x, MPI a, unsigned n );
ch1_mpi 146
ch1_mpi 147 /*-- mpi-inv.c --*/
ch1_mpi 148 void mpi_invm( MPI x, MPI u, MPI v );
ch1_mpi 149
ch1_mpi 150 #endif /*G10_MPI_H*/