|
libssh
0.7.2
|
00001 /* 00002 * This file is part of the SSH Library 00003 * 00004 * Copyright (c) 2009 by Aris Adamantiadis 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 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 SHA512_CTX* SHA384CTX; 00040 typedef SHA512_CTX* SHA512CTX; 00041 typedef MD5_CTX* MD5CTX; 00042 typedef HMAC_CTX* HMACCTX; 00043 #ifdef HAVE_ECC 00044 typedef EVP_MD_CTX *EVPCTX; 00045 #else 00046 typedef void *EVPCTX; 00047 #endif 00048 00049 #define SHA_DIGEST_LEN SHA_DIGEST_LENGTH 00050 #define SHA256_DIGEST_LEN SHA256_DIGEST_LENGTH 00051 #define SHA384_DIGEST_LEN SHA384_DIGEST_LENGTH 00052 #define SHA512_DIGEST_LEN SHA512_DIGEST_LENGTH 00053 #ifdef MD5_DIGEST_LEN 00054 #undef MD5_DIGEST_LEN 00055 #endif 00056 #define MD5_DIGEST_LEN MD5_DIGEST_LENGTH 00057 00058 #ifdef HAVE_OPENSSL_ECC 00059 #define EVP_DIGEST_LEN EVP_MAX_MD_SIZE 00060 #endif 00061 00062 #include <openssl/bn.h> 00063 #include <openssl/opensslv.h> 00064 #define OPENSSL_0_9_7b 0x0090702fL 00065 #if (OPENSSL_VERSION_NUMBER <= OPENSSL_0_9_7b) 00066 #define BROKEN_AES_CTR 00067 #endif 00068 typedef BIGNUM* bignum; 00069 typedef BN_CTX* bignum_CTX; 00070 00071 #define bignum_new() BN_new() 00072 #define bignum_free(num) BN_clear_free(num) 00073 #define bignum_set_word(bn,n) BN_set_word(bn,n) 00074 #define bignum_bin2bn(bn,datalen,data) BN_bin2bn(bn,datalen,data) 00075 #define bignum_bn2dec(num) BN_bn2dec(num) 00076 #define bignum_dec2bn(bn,data) BN_dec2bn(data,bn) 00077 #define bignum_bn2hex(num) BN_bn2hex(num) 00078 #define bignum_rand(rnd, bits, top, bottom) BN_rand(rnd,bits,top,bottom) 00079 #define bignum_ctx_new() BN_CTX_new() 00080 #define bignum_ctx_free(num) BN_CTX_free(num) 00081 #define bignum_mod_exp(dest,generator,exp,modulo,ctx) BN_mod_exp(dest,generator,exp,modulo,ctx) 00082 #define bignum_num_bytes(num) BN_num_bytes(num) 00083 #define bignum_num_bits(num) BN_num_bits(num) 00084 #define bignum_is_bit_set(num,bit) BN_is_bit_set(num,bit) 00085 #define bignum_bn2bin(num,ptr) BN_bn2bin(num,ptr) 00086 #define bignum_cmp(num1,num2) BN_cmp(num1,num2) 00087 00088 SHA256CTX sha256_init(void); 00089 void sha256_update(SHA256CTX c, const void *data, unsigned long len); 00090 void sha256_final(unsigned char *md, SHA256CTX c); 00091 00092 SHA384CTX sha384_init(void); 00093 void sha384_update(SHA384CTX c, const void *data, unsigned long len); 00094 void sha384_final(unsigned char *md, SHA384CTX c); 00095 00096 SHA512CTX sha512_init(void); 00097 void sha512_update(SHA512CTX c, const void *data, unsigned long len); 00098 void sha512_final(unsigned char *md, SHA512CTX c); 00099 00100 struct ssh_cipher_struct *ssh_get_ciphertab(void); 00101 00102 #endif /* HAVE_LIBCRYPTO */ 00103 00104 #endif /* LIBCRYPTO_H_ */
1.7.5.1