OpenVAS Libraries
4.0+rc3.SVN
|
00001 /* 00002 Unix SMB/CIFS implementation. 00003 Interface header: Scheduler service 00004 Copyright (C) Luke Kenneth Casson Leighton 1996-1999 00005 Copyright (C) Andrew Tridgell 1992-1999 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00020 */ 00021 00022 #ifndef _HMAC_MD5_H 00023 #define _HMAC_MD5_H 00024 00025 #include "md5.h" 00026 00027 #ifndef uchar 00028 #define uchar unsigned char 00029 #endif 00030 00031 /* zero a structure */ 00032 #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x)) 00033 00034 typedef struct 00035 { 00036 struct MD5Context ctx; 00037 uchar k_ipad[65]; 00038 uchar k_opad[65]; 00039 00040 } HMACMD5Context; 00041 00042 #ifndef SAFE_FREE 00043 00049 #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0) 00050 #endif 00051 00052 /* 00053 * Note we duplicate the size tests in the unsigned 00054 * case as int16 may be a typedef from rpc/rpc.h 00055 */ 00056 00057 #if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H) 00058 #if (SIZEOF_SHORT == 4) 00059 #define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16; 00060 #else /* SIZEOF_SHORT != 4 */ 00061 #define uint16 unsigned short 00062 #endif /* SIZEOF_SHORT != 4 */ 00063 #endif 00064 00065 /* 00066 * SMB UCS2 (16-bit unicode) internal type. 00067 */ 00068 typedef uint16 smb_ucs2_t; 00069 00070 #ifdef WORDS_BIGENDIAN 00071 #define UCS2_SHIFT 8 00072 #else 00073 #define UCS2_SHIFT 0 00074 #endif 00075 00076 /* turn a 7 bit character into a ucs2 character */ 00077 #define UCS2_CHAR(c) ((c) << UCS2_SHIFT) 00078 void hmac_md5_init_rfc2104(uchar* key, int key_len, HMACMD5Context *ctx); 00079 void hmac_md5_init_limK_to_64(const uchar* key, int key_len, HMACMD5Context *ctx); 00080 00081 void hmac_md5_update(const uchar* text, int text_len, HMACMD5Context *ctx); 00082 void hmac_md5_final(uchar *digest, HMACMD5Context *ctx); 00083 00084 void hmac_md5( uchar key[16], uchar* data, int data_len, uchar* digest); 00085 00086 #endif /* _HMAC_MD5_H */