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