OpenVAS Libraries  8.0.3
smb_crypt.h
Go to the documentation of this file.
1 /*
2  Unix SMB/Netbios implementation.
3  Version 1.9.
4 
5  a partial implementation of DES designed for use in the
6  SMB authentication protocol
7 
8  Copyright (C) Andrew Tridgell 1998-2000
9 
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program; if not, write to the Free Software Foundation,
22  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 */
24 
25 #ifndef NASL_SMB_CRYPT_H
26 #define NASL_SMB_CRYPT_H
27 #include "md5.h"
28 #include "md4.h"
29 #include "hmacmd5.h"
30 #include "charset.h"
31 #include "byteorder.h"
32 
33 #ifndef uchar
34 #define uchar unsigned char
35 #endif
36 
37 #ifndef uint8
38 #define uint8 uint8_t
39 #endif
40 
41 typedef unsigned int bool;
42 #define False 0
43 #define True 1
44 
45 void E_P24(const uchar *p21, const uchar *c8, uchar *p24);
46 void E_P16(uchar *p14,uchar *p16);
47 
48 int strupper_w(smb_ucs2_t *s);/*implemented in smb_crypt2.c*/
49 
50 void SMBsesskeygen_lm_sess_key_ntlmssp(const uchar lm_hash[16], const uchar lm_resp[24], uint8 sess_key[16]);
51 
52 void SMBsesskeygen_ntv1_ntlmssp(const uchar kr[16], const uchar * nt_resp, uint8 sess_key[16]);
53 
54 void SMBOWFencrypt_ntlmssp(const uchar passwd[16], const uchar *c8, uchar p24[24]);
55 
56 void SMBencrypt_hash_ntlmssp(const uchar lm_hash[16], const uchar *c8, uchar p24[24]);
57 
58 void SMBNTencrypt_hash_ntlmssp(const uchar nt_hash[16], uchar *c8, uchar *p24);
59 
60 bool E_deshash_ntlmssp(const char *passwd, uchar p16[16]);
61 
62 void SamOEMhash( uchar *data, const uchar *key, int val);
63 
64 /* Does the md5 encryption from the Key Response for NTLMv2. */
65 void SMBOWFencrypt_ntv2_ntlmssp(const uchar kr[16],
66  const uint8_t *srv_chal,
67  int srv_chal_len,
68  const uint8_t *cli_chal,
69  int cli_chal_len,
70  uchar resp_buf[16]);
71 
72 void SMBsesskeygen_ntv2_ntlmssp(const uchar kr[16],
73  const uchar * nt_resp, uint8 sess_key[16]);
74 
75 uint8_t * NTLMv2_generate_client_data_ntlmssp(const char *addr_list, int address_list_len);
76 
77 void NTLMv2_generate_response_ntlmssp(const uchar ntlm_v2_hash[16],
78  const char *server_chal,
79  const char *address_list, int address_list_len, uint8_t *nt_response);
80 
81 void LMv2_generate_response_ntlmssp(const uchar ntlm_v2_hash[16],
82  const char *server_chal, uint8_t *lm_response);
83 
84 void SMBNTLMv2encrypt_hash_ntlmssp(const char *user, const char *domain, uchar ntlm_v2_hash[16],
85  const char *server_chal,
86  const char *address_list, int address_list_len,
87  unsigned char *lm_response, unsigned char *nt_response,
88  unsigned char *user_session_key);
89 
90 #endif
#define uchar
Definition: hmacmd5.h:28
void SamOEMhash(uchar *data, const uchar *key, int val)
Definition: smb_crypt.c:337
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:512
int strupper_w(smb_ucs2_t *s)
Definition: smb_crypt2.c:42
void SMBsesskeygen_ntv1_ntlmssp(const uchar kr[16], const uchar *nt_resp, uint8 sess_key[16])
Definition: smb_crypt.c:386
void E_P16(uchar *p14, uchar *p16)
Definition: smb_crypt.c:323
void SMBencrypt_hash_ntlmssp(const uchar lm_hash[16], const uchar *c8, uchar p24[24])
Definition: smb_crypt.c:406
void LMv2_generate_response_ntlmssp(const uchar ntlm_v2_hash[16], const char *server_chal, uint8_t *lm_response)
Definition: smb_crypt.c:532
void SMBOWFencrypt_ntlmssp(const uchar passwd[16], const uchar *c8, uchar p24[24])
Definition: smb_crypt.c:397
void SMBsesskeygen_ntv2_ntlmssp(const uchar kr[16], const uchar *nt_resp, uint8 sess_key[16])
Definition: smb_crypt.c:471
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])
bool E_deshash_ntlmssp(const char *passwd, uchar p16[16])
Definition: smb_crypt.c:451
#define uint8
Definition: smb_crypt.h:38
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:513
uint16 smb_ucs2_t
Definition: hmacmd5.h:68
void SMBNTencrypt_hash_ntlmssp(const uchar nt_hash[16], uchar *c8, uchar *p24)
Definition: smb_crypt.c:417
void E_P24(const uchar *p21, const uchar *c8, uchar *p24)
Definition: smb_crypt.c:330
void SMBsesskeygen_lm_sess_key_ntlmssp(const uchar lm_hash[16], const uchar lm_resp[24], uint8 sess_key[16])
Definition: smb_crypt.c:426
uint8_t * NTLMv2_generate_client_data_ntlmssp(const char *addr_list, int address_list_len)
Definition: smb_crypt.c:484
unsigned int bool
Definition: smb_crypt.h:41