OpenVAS Scanner  6.0.1
hmacmd5.h
Go to the documentation of this file.
1 /* Copyright (C) Luke Kenneth Casson Leighton 1996-1999
2  * Copyright (C) Andrew Tridgell 1992-1999
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
29 #ifndef _HMAC_MD5_H
30 #define _HMAC_MD5_H
31 
32 #include "md5.h"
33 
34 #ifndef uchar
35 #define uchar unsigned char
36 #endif
37 
38 /* zero a structure */
39 #define ZERO_STRUCT(x) memset ((char *) &(x), 0, sizeof (x))
40 
41 typedef struct
42 {
43  struct MD5Context ctx;
44  uchar k_ipad[65];
45  uchar k_opad[65];
46 
48 
49 #ifndef SAFE_FREE
50 
56 #define SAFE_FREE(x) \
57  do \
58  { \
59  if ((x) != NULL) \
60  { \
61  free (x); \
62  x = NULL; \
63  } \
64  } \
65  while (0)
66 #endif
67 
68 /*
69  * Note we duplicate the size tests in the unsigned
70  * case as int16 may be a typedef from rpc/rpc.h
71  */
72 
73 #if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H)
74 #if (SIZEOF_SHORT == 4)
75 #define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
76 #else /* SIZEOF_SHORT != 4 */
77 #define uint16 unsigned short
78 #endif /* SIZEOF_SHORT != 4 */
79 #endif
80 
81 /*
82  * SMB UCS2 (16-bit unicode) internal type.
83  */
85 
86 #ifdef WORDS_BIGENDIAN
87 #define UCS2_SHIFT 8
88 #else
89 #define UCS2_SHIFT 0
90 #endif
91 
92 /* turn a 7 bit character into a ucs2 character */
93 #define UCS2_CHAR(c) ((c) << UCS2_SHIFT)
94 void
95 hmac_md5_init_limK_to_64 (const uchar *key, int key_len, HMACMD5Context *ctx);
96 
97 void
98 hmac_md5_update (const uchar *text, int text_len, HMACMD5Context *ctx);
99 void
100 hmac_md5_final (uchar *digest, HMACMD5Context *ctx);
101 
102 void
103 hmac_md5 (uchar key[16], uchar *data, int data_len, uchar *digest);
104 
105 #endif /* _HMAC_MD5_H */
#define uchar
Definition: hmacmd5.h:35
void hmac_md5_final(uchar *digest, HMACMD5Context *ctx)
Finish off hmac_md5 "inner" buffer and generate outer one.
Definition: hmacmd5.c:77
void hmac_md5(uchar key[16], uchar *data, int data_len, uchar *digest)
Function to calculate an HMAC MD5 digest from data. Use the microsoft hmacmd5 init method because the...
Definition: hmacmd5.c:95
void hmac_md5_init_limK_to_64(const uchar *key, int key_len, HMACMD5Context *ctx)
The microsoft version of hmac_md5 initialisation.
Definition: hmacmd5.c:37
#define uint16
Definition: hmacmd5.h:77
uint16 smb_ucs2_t
Definition: hmacmd5.h:84
Definition: md5.h:46
void hmac_md5_update(const uchar *text, int text_len, HMACMD5Context *ctx)
Update hmac_md5 "inner" buffer.
Definition: hmacmd5.c:68
Definition: hmacmd5.h:41