OpenVAS Libraries  6.0+beta5
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_ntlmssp(const char *passwd, const uchar *c8, uchar p24[24]);
58 
59 void SMBencrypt_hash_ntlmssp(const uchar lm_hash[16], const uchar *c8, uchar p24[24]);
60 
61 void SMBNTencrypt_hash_ntlmssp(const uchar nt_hash[16], uchar *c8, uchar *p24);
62 
63 void E_md5hash_ntlmssp(const uchar salt[16], const uchar nthash[16], uchar hash_out[16]);
64 
65 bool E_deshash_ntlmssp(const char *passwd, uchar p16[16]);
66 
67 void SamOEMhash( uchar *data, const uchar *key, int val);
68 
69 /* Does the md5 encryption from the Key Response for NTLMv2. */
70 void SMBOWFencrypt_ntv2_ntlmssp(const uchar kr[16],
71  const uint8_t *srv_chal,
72  int srv_chal_len,
73  const uint8_t *cli_chal,
74  int cli_chal_len,
75  uchar resp_buf[16]);
76 
77 void SMBsesskeygen_ntv2_ntlmssp(const uchar kr[16],
78  const uchar * nt_resp, uint8 sess_key[16]);
79 
80 uint8_t * NTLMv2_generate_client_data_ntlmssp(const char *addr_list, int address_list_len);
81 
82 void NTLMv2_generate_response_ntlmssp(const uchar ntlm_v2_hash[16],
83  const char *server_chal,
84  const char *address_list, int address_list_len, uint8_t *nt_response);
85 
86 void LMv2_generate_response_ntlmssp(const uchar ntlm_v2_hash[16],
87  const char *server_chal, uint8_t *lm_response);
88 
89 void SMBNTLMv2encrypt_hash_ntlmssp(const char *user, const char *domain, uchar ntlm_v2_hash[16],
90  const char *server_chal,
91  const char *address_list, int address_list_len,
92  unsigned char *lm_response, unsigned char *nt_response,
93  unsigned char *user_session_key);
94 
95 #endif