29 typedef gcry_md_hd_t SHACTX;
30 typedef gcry_md_hd_t SHA256CTX;
31 typedef gcry_md_hd_t SHA384CTX;
32 typedef gcry_md_hd_t SHA512CTX;
33 typedef gcry_md_hd_t MD5CTX;
34 typedef gcry_md_hd_t HMACCTX;
35 #define SHA_DIGEST_LENGTH 20 36 #define SHA_DIGEST_LEN SHA_DIGEST_LENGTH 37 #define MD5_DIGEST_LEN 16 38 #define SHA256_DIGEST_LENGTH 32 39 #define SHA256_DIGEST_LEN SHA256_DIGEST_LENGTH 40 #define SHA384_DIGEST_LENGTH 48 41 #define SHA384_DIGEST_LEN SHA384_DIGEST_LENGTH 42 #define SHA512_DIGEST_LENGTH 64 43 #define SHA512_DIGEST_LEN SHA512_DIGEST_LENGTH 45 #ifndef EVP_MAX_MD_SIZE 46 #define EVP_MAX_MD_SIZE 64 49 #define EVP_DIGEST_LEN EVP_MAX_MD_SIZE 51 typedef gcry_mpi_t bignum;
52 typedef const struct gcry_mpi *const_bignum;
53 typedef void* bignum_CTX;
56 #define NID_gcrypt_nistp256 0 57 #define NID_gcrypt_nistp384 1 58 #define NID_gcrypt_nistp521 2 61 int ssh_gcry_dec2bn(bignum *bn,
const char *data);
62 char *ssh_gcry_bn2dec(bignum bn);
63 int ssh_gcry_rand_range(bignum rnd, bignum max);
65 #define bignum_new() gcry_mpi_new(0) 66 #define bignum_safe_free(num) do { \ 67 if ((num) != NULL) { \ 68 gcry_mpi_release((num)); \ 72 #define bignum_free(num) gcry_mpi_release(num) 73 #define bignum_ctx_new() NULL 74 #define bignum_ctx_free(ctx) do {(ctx) = NULL;} while(0) 75 #define bignum_ctx_invalid(ctx) (ctx != NULL) 76 #define bignum_set_word(bn,n) (gcry_mpi_set_ui(bn,n)!=NULL ? 1 : 0) 77 #define bignum_bin2bn(data,datalen,dest) gcry_mpi_scan(dest,GCRYMPI_FMT_USG,data,datalen,NULL) 78 #define bignum_bn2dec(num) ssh_gcry_bn2dec(num) 79 #define bignum_dec2bn(num, data) ssh_gcry_dec2bn(data, num) 81 #define bignum_bn2hex(num, data) \ 82 gcry_mpi_aprint(GCRYMPI_FMT_HEX, data, NULL, (const gcry_mpi_t)num) 84 #define bignum_hex2bn(data, num) (gcry_mpi_scan(num,GCRYMPI_FMT_HEX,data,0,NULL)==0?1:0) 85 #define bignum_rand(num,bits) 1,gcry_mpi_randomize(num,bits,GCRY_STRONG_RANDOM),gcry_mpi_set_bit(num,bits-1),gcry_mpi_set_bit(num,0) 86 #define bignum_mod_exp(dest,generator,exp,modulo, ctx) 1,gcry_mpi_powm(dest,generator,exp,modulo) 87 #define bignum_num_bits(num) gcry_mpi_get_nbits(num) 88 #define bignum_num_bytes(num) ((gcry_mpi_get_nbits(num)+7)/8) 89 #define bignum_is_bit_set(num,bit) gcry_mpi_test_bit(num,bit) 90 #define bignum_bn2bin(num,datalen,data) gcry_mpi_print(GCRYMPI_FMT_USG,data,datalen,NULL,num) 91 #define bignum_cmp(num1,num2) gcry_mpi_cmp(num1,num2) 92 #define bignum_rshift1(dest, src) gcry_mpi_rshift (dest, src, 1) 93 #define bignum_add(dst, a, b) gcry_mpi_add(dst, a, b) 94 #define bignum_sub(dst, a, b) gcry_mpi_sub(dst, a, b) 95 #define bignum_mod(dst, a, b, ctx) 1,gcry_mpi_mod(dst, a, b) 96 #define bignum_rand_range(rnd, max) ssh_gcry_rand_range(rnd, max); 97 #define bignum_dup(orig, dest) do { \ 98 if (*(dest) == NULL) { \ 99 *(dest) = gcry_mpi_copy(orig); \ 101 gcry_mpi_set(*(dest), orig); \ 109 ssh_string ssh_sexp_extract_mpi(
const gcry_sexp_t sexp,
111 enum gcry_mpi_format informat,
112 enum gcry_mpi_format outformat);
114 #define ssh_fips_mode() false