00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef LIBCRYPTO_H_
00022 #define LIBCRYPTO_H_
00023
00024 #include "config.h"
00025
00026 #ifdef HAVE_LIBCRYPTO
00027
00028 #include <openssl/dsa.h>
00029 #include <openssl/rsa.h>
00030 #include <openssl/sha.h>
00031 #include <openssl/md5.h>
00032 #include <openssl/hmac.h>
00033 #ifdef HAVE_OPENSSL_ECC
00034 #include <openssl/evp.h>
00035 #endif
00036
00037 typedef SHA_CTX* SHACTX;
00038 typedef SHA256_CTX* SHA256CTX;
00039 typedef MD5_CTX* MD5CTX;
00040 typedef HMAC_CTX* HMACCTX;
00041 #ifdef HAVE_ECC
00042 typedef EVP_MD_CTX *EVPCTX;
00043 #else
00044 typedef void *EVPCTX;
00045 #endif
00046
00047 #define SHA_DIGEST_LEN SHA_DIGEST_LENGTH
00048 #ifdef MD5_DIGEST_LEN
00049 #undef MD5_DIGEST_LEN
00050 #endif
00051 #define MD5_DIGEST_LEN MD5_DIGEST_LENGTH
00052
00053 #ifdef HAVE_OPENSSL_ECC
00054 #define EVP_DIGEST_LEN EVP_MAX_MD_SIZE
00055 #endif
00056
00057 #include <openssl/bn.h>
00058 #include <openssl/opensslv.h>
00059 #define OPENSSL_0_9_7b 0x0090702fL
00060 #if (OPENSSL_VERSION_NUMBER <= OPENSSL_0_9_7b)
00061 #define BROKEN_AES_CTR
00062 #endif
00063 typedef BIGNUM* bignum;
00064 typedef BN_CTX* bignum_CTX;
00065
00066 #define bignum_new() BN_new()
00067 #define bignum_free(num) BN_clear_free(num)
00068 #define bignum_set_word(bn,n) BN_set_word(bn,n)
00069 #define bignum_bin2bn(bn,datalen,data) BN_bin2bn(bn,datalen,data)
00070 #define bignum_bn2dec(num) BN_bn2dec(num)
00071 #define bignum_dec2bn(bn,data) BN_dec2bn(data,bn)
00072 #define bignum_bn2hex(num) BN_bn2hex(num)
00073 #define bignum_rand(rnd, bits, top, bottom) BN_rand(rnd,bits,top,bottom)
00074 #define bignum_ctx_new() BN_CTX_new()
00075 #define bignum_ctx_free(num) BN_CTX_free(num)
00076 #define bignum_mod_exp(dest,generator,exp,modulo,ctx) BN_mod_exp(dest,generator,exp,modulo,ctx)
00077 #define bignum_num_bytes(num) BN_num_bytes(num)
00078 #define bignum_num_bits(num) BN_num_bits(num)
00079 #define bignum_is_bit_set(num,bit) BN_is_bit_set(num,bit)
00080 #define bignum_bn2bin(num,ptr) BN_bn2bin(num,ptr)
00081 #define bignum_cmp(num1,num2) BN_cmp(num1,num2)
00082
00083 SHA256CTX sha256_init(void);
00084 void sha256_update(SHA256CTX c, const void *data, unsigned long len);
00085 void sha256_final(unsigned char *md, SHA256CTX c);
00086
00087 struct ssh_cipher_struct *ssh_get_ciphertab(void);
00088
00089 #endif
00090
00091 #endif