OpenVAS Scanner  22.7.9
smb_crypt.h
Go to the documentation of this file.
1 /* SPDX-FileCopyrightText: 2023 Greenbone AG
2  * SPDX-FileCopyrightText: 1998-2000 Andrew Tridgell
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  */
6 
15 #ifndef NASL_SMB_CRYPT_H
16 #define NASL_SMB_CRYPT_H
17 #include "byteorder.h"
18 #include "charset.h"
19 #include "hmacmd5.h"
20 #include "md4.h"
21 #include "md5.h"
22 
23 #ifndef uchar
24 #define uchar unsigned char
25 #endif
26 
27 #ifndef uint8
28 #define uint8 uint8_t
29 #endif
30 
31 typedef unsigned int bool;
32 #define False 0
33 #define True 1
34 
35 void
36 E_P24 (const uchar *p21, const uchar *c8, uchar *p24);
37 void
38 E_P16 (uchar *p14, uchar *p16);
39 
40 int
41 strupper_w (smb_ucs2_t *s); /*implemented in smb_crypt2.c*/
42 
43 void
44 SMBsesskeygen_lm_sess_key_ntlmssp (const uchar lm_hash[16],
45  const uchar lm_resp[24], uint8 sess_key[16]);
46 
47 void
48 SMBsesskeygen_ntv1_ntlmssp (const uchar kr[16], const uchar *nt_resp,
49  uint8 sess_key[16]);
50 
51 void
52 SMBOWFencrypt_ntlmssp (const uchar passwd[16], const uchar *c8, uchar p24[24]);
53 
54 void
55 SMBencrypt_hash_ntlmssp (const uchar lm_hash[16], const uchar *c8,
56  uchar p24[24]);
57 
58 void
59 SMBNTencrypt_hash_ntlmssp (const uchar nt_hash[16], uchar *c8, uchar *p24);
60 
61 bool
62 E_deshash_ntlmssp (const char *passwd, uint8_t pass_len, uchar p16[16]);
63 
64 void
65 SamOEMhash (uchar *data, const uchar *key, int val);
66 
67 /* Does the md5 encryption from the Key Response for NTLMv2. */
68 void
69 SMBOWFencrypt_ntv2_ntlmssp (const uchar *kr, const uint8_t *srv_chal,
70  int srv_chal_len, const uint8_t *cli_chal,
71  int cli_chal_len, uchar resp_buf[16]);
72 
73 void
74 SMBsesskeygen_ntv2_ntlmssp (const uchar kr[16], const uchar *nt_resp,
75  uint8 sess_key[16]);
76 
77 uint8_t *
78 NTLMv2_generate_client_data_ntlmssp (const char *addr_list,
79  int address_list_len);
80 
81 void
82 NTLMv2_generate_response_ntlmssp (const uchar ntlm_v2_hash[16],
83  const char *server_chal,
84  const char *address_list,
85  int address_list_len, uint8_t *nt_response);
86 
87 void
88 LMv2_generate_response_ntlmssp (const uchar ntlm_v2_hash[16],
89  const char *server_chal, uint8_t *lm_response);
90 
91 void
92 SMBNTLMv2encrypt_hash_ntlmssp (const char *user, const char *domain,
93  uchar ntlm_v2_hash[16], const char *server_chal,
94  const char *address_list, int address_list_len,
95  unsigned char *lm_response,
96  unsigned char *nt_response,
97  unsigned char *user_session_key);
98 
99 #endif
NTLMv2_generate_response_ntlmssp
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:507
uint8
#define uint8
Definition: smb_crypt.h:28
uchar
#define uchar
Definition: hmacmd5.h:22
SMBsesskeygen_ntv1_ntlmssp
void SMBsesskeygen_ntv1_ntlmssp(const uchar kr[16], const uchar *nt_resp, uint8 sess_key[16])
Definition: smb_crypt.c:373
SMBNTLMv2encrypt_hash_ntlmssp
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)
byteorder.h
Unix SMB/CIFS implementation. SMB Byte handling.
SMBOWFencrypt_ntv2_ntlmssp
void SMBOWFencrypt_ntv2_ntlmssp(const uchar *kr, const uint8_t *srv_chal, int srv_chal_len, const uint8_t *cli_chal, int cli_chal_len, uchar resp_buf[16])
LMv2_generate_response_ntlmssp
void LMv2_generate_response_ntlmssp(const uchar ntlm_v2_hash[16], const char *server_chal, uint8_t *lm_response)
Definition: smb_crypt.c:534
SMBNTencrypt_hash_ntlmssp
void SMBNTencrypt_hash_ntlmssp(const uchar nt_hash[16], uchar *c8, uchar *p24)
Definition: smb_crypt.c:406
bool
unsigned int bool
Definition: smb_crypt.h:31
E_P16
void E_P16(uchar *p14, uchar *p16)
Definition: smb_crypt.c:302
SMBsesskeygen_lm_sess_key_ntlmssp
void SMBsesskeygen_lm_sess_key_ntlmssp(const uchar lm_hash[16], const uchar lm_resp[24], uint8 sess_key[16])
Definition: smb_crypt.c:416
SamOEMhash
void SamOEMhash(uchar *data, const uchar *key, int val)
Definition: smb_crypt.c:318
NTLMv2_generate_client_data_ntlmssp
uint8_t * NTLMv2_generate_client_data_ntlmssp(const char *addr_list, int address_list_len)
Definition: smb_crypt.c:476
strupper_w
int strupper_w(smb_ucs2_t *s)
Definition: smb_crypt2.c:35
SMBOWFencrypt_ntlmssp
void SMBOWFencrypt_ntlmssp(const uchar passwd[16], const uchar *c8, uchar p24[24])
Definition: smb_crypt.c:384
SMBsesskeygen_ntv2_ntlmssp
void SMBsesskeygen_ntv2_ntlmssp(const uchar kr[16], const uchar *nt_resp, uint8 sess_key[16])
Definition: smb_crypt.c:463
smb_ucs2_t
uint16 smb_ucs2_t
Definition: hmacmd5.h:52
charset.h
Unix SMB/CIFS implementation. charset defines.
hmacmd5.h
Unix SMB/CIFS implementation. HMAC MD5 code for use in NTLMv2.
md4.h
Unix SMB/CIFS implementation.
md5.h
val
const char * val
Definition: nasl_init.c:412
E_deshash_ntlmssp
bool E_deshash_ntlmssp(const char *passwd, uint8_t pass_len, uchar p16[16])
Definition: smb_crypt.c:437
E_P24
void E_P24(const uchar *p21, const uchar *c8, uchar *p24)
Definition: smb_crypt.c:310
SMBencrypt_hash_ntlmssp
void SMBencrypt_hash_ntlmssp(const uchar lm_hash[16], const uchar *c8, uchar p24[24])
Definition: smb_crypt.c:394