OpenVAS Scanner  7.0.0~git
smb_signing.h File Reference

Unix SMB/CIFS implementation. SMB Signing Code. More...

#include "byteorder.h"
#include "md5.h"
#include "smb.h"
Include dependency graph for smb_signing.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define uchar   unsigned char
 
#define uint8   uint8_t
 

Functions

void simple_packet_signature_ntlmssp (uint8_t *mac_key, const uchar *buf, uint32 seq_number, unsigned char *calc_md5_mac)
 

Detailed Description

Unix SMB/CIFS implementation. SMB Signing Code.

Definition in file smb_signing.h.

Macro Definition Documentation

◆ uchar

#define uchar   unsigned char

Definition at line 41 of file smb_signing.h.

◆ uint8

#define uint8   uint8_t

Definition at line 45 of file smb_signing.h.

Function Documentation

◆ simple_packet_signature_ntlmssp()

void simple_packet_signature_ntlmssp ( uint8_t *  mac_key,
const uchar buf,
uint32  seq_number,
unsigned char *  calc_md5_mac 
)

Definition at line 36 of file smb_signing.c.

38 {
39  const size_t offset_end_of_sig = (smb_ss_field + 8);
40  unsigned char sequence_buf[8];
41  struct MD5Context md5_ctx;
42 
43  /*
44  * Firstly put the sequence number into the first 4 bytes.
45  * and zero out the next 4 bytes.
46  *
47  * We do this here, to avoid modifying the packet.
48  */
49 
50  SIVAL (sequence_buf, 0, seq_number);
51  SIVAL (sequence_buf, 4, 0);
52 
53  /* Calculate the 16 byte MAC - but don't alter the data in the
54  incoming packet.
55 
56  This makes for a bit of fussing about, but it's not too bad.
57  */
58  MD5Init (&md5_ctx);
59 
60  /* initialise with the key */
61  MD5Update (&md5_ctx, mac_key, 16);
62 
63  /* copy in the first bit of the SMB header */
64  MD5Update (&md5_ctx, buf + 4, smb_ss_field - 4);
65 
66  /* copy in the sequence number, instead of the signature */
67  MD5Update (&md5_ctx, sequence_buf, sizeof (sequence_buf));
68 
69  /* copy in the rest of the packet in, skipping the signature */
70  MD5Update (&md5_ctx, buf + offset_end_of_sig,
71  smb_len (buf) - (offset_end_of_sig - 4));
72 
73  /* calculate the MD5 sig */
74  MD5Final (calc_md5_mac, &md5_ctx);
75 }

References MD5Context::buf, MD5Final(), MD5Init(), MD5Update(), SIVAL, smb_len, and smb_ss_field.

Referenced by nasl_get_sign().

Here is the call graph for this function:
Here is the caller graph for this function:
MD5Context::buf
uint32 buf[4]
Definition: md5.h:48
SIVAL
#define SIVAL(buf, pos, val)
Definition: byteorder.h:130
MD5Update
void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
Definition: md5.c:66
smb_ss_field
#define smb_ss_field
Definition: smb.h:60
MD5Init
void MD5Init(struct MD5Context *ctx)
Definition: md5.c:50
smb_len
#define smb_len(buf)
Definition: smb.h:196
MD5Context
Definition: md5.h:46
MD5Final
void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
Definition: md5.c:118