OpenVAS Scanner  7.0.1~git
smb_crypt.h
Go to the documentation of this file.
1 /* Copyright (C) Andrew Tridgell 1998-2000
2  *
3  * SPDX-License-Identifier: GPL-2.0-or-later
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
28 #ifndef NASL_SMB_CRYPT_H
29 #define NASL_SMB_CRYPT_H
30 #include "byteorder.h"
31 #include "charset.h"
32 #include "hmacmd5.h"
33 #include "md4.h"
34 #include "md5.h"
35 
36 #ifndef uchar
37 #define uchar unsigned char
38 #endif
39 
40 #ifndef uint8
41 #define uint8 uint8_t
42 #endif
43 
44 typedef unsigned int bool;
45 #define False 0
46 #define True 1
47 
48 void
49 E_P24 (const uchar *p21, const uchar *c8, uchar *p24);
50 void
51 E_P16 (uchar *p14, uchar *p16);
52 
53 int
54 strupper_w (smb_ucs2_t *s); /*implemented in smb_crypt2.c*/
55 
56 void
57 SMBsesskeygen_lm_sess_key_ntlmssp (const uchar lm_hash[16],
58  const uchar lm_resp[24], uint8 sess_key[16]);
59 
60 void
61 SMBsesskeygen_ntv1_ntlmssp (const uchar kr[16], const uchar *nt_resp,
62  uint8 sess_key[16]);
63 
64 void
65 SMBOWFencrypt_ntlmssp (const uchar passwd[16], const uchar *c8, uchar p24[24]);
66 
67 void
68 SMBencrypt_hash_ntlmssp (const uchar lm_hash[16], const uchar *c8,
69  uchar p24[24]);
70 
71 void
72 SMBNTencrypt_hash_ntlmssp (const uchar nt_hash[16], uchar *c8, uchar *p24);
73 
74 bool
75 E_deshash_ntlmssp (const char *passwd, uint8_t pass_len, uchar p16[16]);
76 
77 void
78 SamOEMhash (uchar *data, const uchar *key, int val);
79 
80 /* Does the md5 encryption from the Key Response for NTLMv2. */
81 void
82 SMBOWFencrypt_ntv2_ntlmssp (const uchar kr[16], const uint8_t *srv_chal,
83  int srv_chal_len, const uint8_t *cli_chal,
84  int cli_chal_len, uchar resp_buf[16]);
85 
86 void
87 SMBsesskeygen_ntv2_ntlmssp (const uchar kr[16], const uchar *nt_resp,
88  uint8 sess_key[16]);
89 
90 uint8_t *
91 NTLMv2_generate_client_data_ntlmssp (const char *addr_list,
92  int address_list_len);
93 
94 void
95 NTLMv2_generate_response_ntlmssp (const uchar ntlm_v2_hash[16],
96  const char *server_chal,
97  const char *address_list,
98  int address_list_len, uint8_t *nt_response);
99 
100 void
101 LMv2_generate_response_ntlmssp (const uchar ntlm_v2_hash[16],
102  const char *server_chal, uint8_t *lm_response);
103 
104 void
105 SMBNTLMv2encrypt_hash_ntlmssp (const char *user, const char *domain,
106  uchar ntlm_v2_hash[16], const char *server_chal,
107  const char *address_list, int address_list_len,
108  unsigned char *lm_response,
109  unsigned char *nt_response,
110  unsigned char *user_session_key);
111 
112 #endif
#define uchar
Definition: hmacmd5.h:35
void SamOEMhash(uchar *data, const uchar *key, int val)
Definition: smb_crypt.c:331
void SMBNTLMv2encrypt_hash_ntlmssp(const char *user, const char *domain, uchar ntlm_v2_hash[16], const char *server_chal, const char *address_list, int address_list_len, unsigned char *lm_response, unsigned char *nt_response, unsigned char *user_session_key)
const char * val
Definition: nasl_init.c:378
int strupper_w(smb_ucs2_t *s)
Definition: smb_crypt2.c:48
void SMBsesskeygen_ntv1_ntlmssp(const uchar kr[16], const uchar *nt_resp, uint8 sess_key[16])
Definition: smb_crypt.c:386
Unix SMB/CIFS implementation. charset defines.
void E_P16(uchar *p14, uchar *p16)
Definition: smb_crypt.c:315
void SMBencrypt_hash_ntlmssp(const uchar lm_hash[16], const uchar *c8, uchar p24[24])
Definition: smb_crypt.c:407
void LMv2_generate_response_ntlmssp(const uchar ntlm_v2_hash[16], const char *server_chal, uint8_t *lm_response)
Definition: smb_crypt.c:545
void SMBOWFencrypt_ntlmssp(const uchar passwd[16], const uchar *c8, uchar p24[24])
Definition: smb_crypt.c:397
bool E_deshash_ntlmssp(const char *passwd, uint8_t pass_len, uchar p16[16])
Definition: smb_crypt.c:450
void SMBsesskeygen_ntv2_ntlmssp(const uchar kr[16], const uchar *nt_resp, uint8 sess_key[16])
Definition: smb_crypt.c:476
void SMBOWFencrypt_ntv2_ntlmssp(const uchar kr[16], const uint8_t *srv_chal, int srv_chal_len, const uint8_t *cli_chal, int cli_chal_len, uchar resp_buf[16])
Unix SMB/CIFS implementation. HMAC MD5 code for use in NTLMv2.
#define uint8
Definition: smb_crypt.h:41
void NTLMv2_generate_response_ntlmssp(const uchar ntlm_v2_hash[16], const char *server_chal, const char *address_list, int address_list_len, uint8_t *nt_response)
Definition: smb_crypt.c:520
Unix SMB/CIFS implementation. SMB Byte handling.
uint16 smb_ucs2_t
Definition: hmacmd5.h:65
void SMBNTencrypt_hash_ntlmssp(const uchar nt_hash[16], uchar *c8, uchar *p24)
Definition: smb_crypt.c:419
void E_P24(const uchar *p21, const uchar *c8, uchar *p24)
Definition: smb_crypt.c:323
void SMBsesskeygen_lm_sess_key_ntlmssp(const uchar lm_hash[16], const uchar lm_resp[24], uint8 sess_key[16])
Definition: smb_crypt.c:429
Unix SMB/CIFS implementation.
uint8_t * NTLMv2_generate_client_data_ntlmssp(const char *addr_list, int address_list_len)
Definition: smb_crypt.c:489
unsigned int bool
Definition: smb_crypt.h:44