Mercurial > dropbear
view libtomcrypt/src/math/gmp_desc.c @ 1786:a3b39df57c8b
fuzz: add an always-failing dropbear_listen() replacement
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 06 Dec 2020 21:54:01 +0800 |
parents | 6dba84798cd5 |
children |
line wrap: on
line source
/* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. */ #define DESC_DEF_ONLY #include "tomcrypt.h" #ifdef GMP_DESC #include <stdio.h> #include <gmp.h> static int init(void **a) { LTC_ARGCHK(a != NULL); *a = XCALLOC(1, sizeof(__mpz_struct)); if (*a == NULL) { return CRYPT_MEM; } mpz_init(((__mpz_struct *)*a)); return CRYPT_OK; } static void deinit(void *a) { LTC_ARGCHKVD(a != NULL); mpz_clear(a); XFREE(a); } static int neg(void *a, void *b) { LTC_ARGCHK(a != NULL); LTC_ARGCHK(b != NULL); mpz_neg(b, a); return CRYPT_OK; } static int copy(void *a, void *b) { LTC_ARGCHK(a != NULL); LTC_ARGCHK(b != NULL); mpz_set(b, a); return CRYPT_OK; } static int init_copy(void **a, void *b) { if (init(a) != CRYPT_OK) { return CRYPT_MEM; } return copy(b, *a); } /* ---- trivial ---- */ static int set_int(void *a, ltc_mp_digit b) { LTC_ARGCHK(a != NULL); mpz_set_ui(((__mpz_struct *)a), b); return CRYPT_OK; } static unsigned long get_int(void *a) { LTC_ARGCHK(a != NULL); return mpz_get_ui(a); } static ltc_mp_digit get_digit(void *a, int n) { LTC_ARGCHK(a != NULL); return mpz_getlimbn(a, n); } static int get_digit_count(void *a) { LTC_ARGCHK(a != NULL); return mpz_size(a); } static int compare(void *a, void *b)