libssh  0.5.4
libcrypto.h
1 /*
2  * This file is part of the SSH Library
3  *
4  * Copyright (c) 2009 by Aris Adamantiadis
5  *
6  * The SSH Library is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or (at your
9  * option) any later version.
10  *
11  * The SSH Library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with the SSH Library; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19  * MA 02111-1307, USA.
20  */
21 
22 #ifndef LIBCRYPTO_H_
23 #define LIBCRYPTO_H_
24 
25 #include "config.h"
26 
27 #ifdef HAVE_LIBCRYPTO
28 
29 #include <openssl/dsa.h>
30 #include <openssl/rsa.h>
31 #include <openssl/sha.h>
32 #include <openssl/md5.h>
33 #include <openssl/hmac.h>
34 typedef SHA_CTX* SHACTX;
35 typedef MD5_CTX* MD5CTX;
36 typedef HMAC_CTX* HMACCTX;
37 
38 #define SHA_DIGEST_LEN SHA_DIGEST_LENGTH
39 #ifdef MD5_DIGEST_LEN
40  #undef MD5_DIGEST_LEN
41 #endif
42 #define MD5_DIGEST_LEN MD5_DIGEST_LENGTH
43 
44 #include <openssl/bn.h>
45 #include <openssl/opensslv.h>
46 #define OPENSSL_0_9_7b 0x0090702fL
47 #if (OPENSSL_VERSION_NUMBER <= OPENSSL_0_9_7b)
48 #define BROKEN_AES_CTR
49 #endif
50 typedef BIGNUM* bignum;
51 typedef BN_CTX* bignum_CTX;
52 
53 #define bignum_new() BN_new()
54 #define bignum_free(num) BN_clear_free(num)
55 #define bignum_set_word(bn,n) BN_set_word(bn,n)
56 #define bignum_bin2bn(bn,datalen,data) BN_bin2bn(bn,datalen,data)
57 #define bignum_bn2dec(num) BN_bn2dec(num)
58 #define bignum_dec2bn(bn,data) BN_dec2bn(data,bn)
59 #define bignum_bn2hex(num) BN_bn2hex(num)
60 #define bignum_rand(rnd, bits, top, bottom) BN_rand(rnd,bits,top,bottom)
61 #define bignum_ctx_new() BN_CTX_new()
62 #define bignum_ctx_free(num) BN_CTX_free(num)
63 #define bignum_mod_exp(dest,generator,exp,modulo,ctx) BN_mod_exp(dest,generator,exp,modulo,ctx)
64 #define bignum_num_bytes(num) BN_num_bytes(num)
65 #define bignum_num_bits(num) BN_num_bits(num)
66 #define bignum_is_bit_set(num,bit) BN_is_bit_set(num,bit)
67 #define bignum_bn2bin(num,ptr) BN_bn2bin(num,ptr)
68 #define bignum_cmp(num1,num2) BN_cmp(num1,num2)
69 
70 struct crypto_struct *ssh_get_ciphertab(void);
71 
72 #endif /* HAVE_LIBCRYPTO */
73 
74 #endif /* LIBCRYPTO_H_ */