summaryrefslogtreecommitdiff
path: root/lib/gnutls_mpi.h
blob: 31342432522f5a9b39c7e125c22719d6881c0027 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * Copyright (C) 2000-2012 Free Software Foundation, Inc.
 *
 * Author: Nikos Mavrogiannopoulos
 *
 * This file is part of GnuTLS.
 *
 * The GnuTLS is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */

#ifndef GNUTLS_MPI_H
#define GNUTLS_MPI_H

#include <gnutls_int.h>

#include <crypto-backend.h>

extern int crypto_bigint_prio;
extern gnutls_crypto_bigint_st _gnutls_mpi_ops;

bigint_t _gnutls_mpi_randomize(bigint_t, unsigned int bits,
			       gnutls_rnd_level_t level);

#define _gnutls_mpi_new _gnutls_mpi_ops.bigint_new
#define _gnutls_mpi_clear _gnutls_mpi_ops.bigint_clear
#define _gnutls_mpi_cmp _gnutls_mpi_ops.bigint_cmp
#define _gnutls_mpi_cmp_ui _gnutls_mpi_ops.bigint_cmp_ui
#define _gnutls_mpi_mod _gnutls_mpi_ops.bigint_mod
#define _gnutls_mpi_set _gnutls_mpi_ops.bigint_set
#define _gnutls_mpi_set_ui _gnutls_mpi_ops.bigint_set_ui
#define _gnutls_mpi_get_nbits _gnutls_mpi_ops.bigint_get_nbits
#define _gnutls_mpi_alloc_like(x) _gnutls_mpi_new(_gnutls_mpi_get_nbits(x))
#define _gnutls_mpi_powm _gnutls_mpi_ops.bigint_powm
#define _gnutls_mpi_addm _gnutls_mpi_ops.bigint_addm
#define _gnutls_mpi_subm _gnutls_mpi_ops.bigint_subm
#define _gnutls_mpi_mulm _gnutls_mpi_ops.bigint_mulm
#define _gnutls_mpi_add _gnutls_mpi_ops.bigint_add
#define _gnutls_mpi_sub _gnutls_mpi_ops.bigint_sub
#define _gnutls_mpi_mul _gnutls_mpi_ops.bigint_mul
#define _gnutls_mpi_div _gnutls_mpi_ops.bigint_div
#define _gnutls_mpi_add_ui _gnutls_mpi_ops.bigint_add_ui
#define _gnutls_mpi_sub_ui _gnutls_mpi_ops.bigint_sub_ui
#define _gnutls_mpi_mul_ui _gnutls_mpi_ops.bigint_mul_ui
#define _gnutls_prime_check _gnutls_mpi_ops.bigint_prime_check
#define _gnutls_mpi_print(x,y,z) _gnutls_mpi_ops.bigint_print(x,y,z,GNUTLS_MPI_FORMAT_USG)
#define _gnutls_mpi_print_lz(x,y,z) _gnutls_mpi_ops.bigint_print(x,y,z,GNUTLS_MPI_FORMAT_STD)
#define _gnutls_mpi_print_pgp(x,y,z) _gnutls_mpi_ops.bigint_print(x,y,z,GNUTLS_MPI_FORMAT_PGP)
#define _gnutls_mpi_copy( a) _gnutls_mpi_set( NULL, a)

void _gnutls_mpi_release(bigint_t * x);

int _gnutls_mpi_scan(bigint_t * ret_mpi, const void *buffer,
		     size_t nbytes);
int _gnutls_mpi_scan_nz(bigint_t * ret_mpi, const void *buffer,
			size_t nbytes);
int _gnutls_mpi_scan_pgp(bigint_t * ret_mpi, const void *buffer,
			 size_t nbytes);

int _gnutls_mpi_dprint_lz(const bigint_t a, gnutls_datum_t * dest);
int _gnutls_mpi_dprint(const bigint_t a, gnutls_datum_t * dest);
int _gnutls_mpi_dprint_size(const bigint_t a, gnutls_datum_t * dest,
			    size_t size);

#define _gnutls_mpi_generate_group( gg, bits) _gnutls_mpi_ops.bigint_generate_group( gg, bits)

#endif