4 * @brief Class with helper functions for gmp operations
9 * Copyright (C) 1997 Angelos D. Keromytis.
10 * Copyright (C) 2005 Jan Hutter, Martin Willi
11 * Hochschule fuer Technik Rapperswil
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
34 * Class with helper functions to manipulate gmp values
37 typedef struct gmp_helper_s gmp_helper_t
;
42 * @brief initialize an mpz_t to a random prime of specified size
45 * @param this calling object
46 * @param[out] var mpz_t variable to initialize
47 * @param[in] bytes length of given prime in bytes
53 status_t (*init_prime
) (gmp_helper_t
*this, mpz_t
*var
, int bytes
);
55 /* Convert network form (binary bytes, big-endian) to mpz_t of gmp library.
57 * mpz_t gets initialized in this function.
59 * @param this calling private_gmp_helper_t object
60 * @param mpz_value pointer to a mpz_t value
61 * @param data chunk_t containing the network form of data
63 void (*chunk_to_mpz
) (gmp_helper_t
*this,mpz_t
*mpz_value
, chunk_t data
);
65 /* Convert mpz_t to network form (binary bytes, big-endian).
67 * @param this calling private_gmp_helper_t object
68 * @param mpz_value mpz_value to convert
69 * @param data chunk_t where the data are written to
70 * @param bytes number of bytes to copy
75 * - FAILED if mpz_t value was longer then given bytes count
77 status_t (*mpz_to_chunk
) (gmp_helper_t
*this,mpz_t
*mpz_value
, chunk_t
*data
,size_t bytes
);
80 * @brief Destroys an gmp_helper_t object.
82 * @param this gmp_helper_t object to destroy
86 status_t (*destroy
) (gmp_helper_t
*this);
90 * Creates a new gmp_helper_t object
93 * - gmp_helper_t if successfully
94 * - NULL if out of ressources
96 gmp_helper_t
*gmp_helper_create();
99 #endif /*GMP_HELPER_H_*/