OpenVAS Libraries  7.0.7
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 "system.h"
28 #include "md5.h"
29 #include "md4.h"
30 #include "hmacmd5.h"
31 #include "charset.h"
32 #include "byteorder.h"
33 
34 #ifndef uchar
35 #define uchar unsigned char
36 #endif
37 
38 #ifndef uint8
39 #define uint8 uint8_t
40 #endif
41 
42 typedef unsigned int bool;
43 #define False 0
44 #define True 1
45 
46 void E_P24(const uchar *p21, const uchar *c8, uchar *p24);
47 void E_P16(uchar *p14,uchar *p16);
48 
49 int strupper_w(smb_ucs2_t *s);/*implemented in smb_crypt2.c*/
50 
51 void SMBsesskeygen_lm_sess_key_ntlmssp(const uchar lm_hash[16], const uchar lm_resp[24], uint8 sess_key[16]);
52 
53 void SMBsesskeygen_ntv1_ntlmssp(const uchar kr[16], const uchar * nt_resp, uint8 sess_key[16]);
54 
55 void SMBOWFencrypt_ntlmssp(const uchar passwd[16], const uchar *c8, uchar p24[24]);
56 
57 void SMBencrypt_hash_ntlmssp(const uchar lm_hash[16], const uchar *c8, uchar p24[24]);
58 
59 void SMBNTencrypt_hash_ntlmssp(const uchar nt_hash[16], uchar *c8, uchar *p24);
60 
61 bool E_deshash_ntlmssp(const char *passwd, uchar p16[16]);
62 
63 void SamOEMhash( uchar *data, const uchar *key, int val);
64 
65 /* Does the md5 encryption from the Key Response for NTLMv2. */
66 void SMBOWFencrypt_ntv2_ntlmssp(const uchar kr[16],
67  const uint8_t *srv_chal,
68  int srv_chal_len,
69  const uint8_t *cli_chal,
70  int cli_chal_len,
71  uchar resp_buf[16]);
72 
73 void SMBsesskeygen_ntv2_ntlmssp(const uchar kr[16],
74  const uchar * nt_resp, uint8 sess_key[16]);
75 
76 uint8_t * NTLMv2_generate_client_data_ntlmssp(const char *addr_list, int address_list_len);
77 
78 void NTLMv2_generate_response_ntlmssp(const uchar ntlm_v2_hash[16],
79  const char *server_chal,
80  const char *address_list, int address_list_len, uint8_t *nt_response);
81 
82 void LMv2_generate_response_ntlmssp(const uchar ntlm_v2_hash[16],
83  const char *server_chal, uint8_t *lm_response);
84 
85 void SMBNTLMv2encrypt_hash_ntlmssp(const char *user, const char *domain, uchar ntlm_v2_hash[16],
86  const char *server_chal,
87  const char *address_list, int address_list_len,
88  unsigned char *lm_response, unsigned char *nt_response,
89  unsigned char *user_session_key);
90 
91 #endif