⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tini400_ntlm.h

📁 TINI的pop3的c代码
💻 H
字号:
/* --------------------------------------------------------------------------------------
 *  Copyright (C) 2003 Dallas Semiconductor Corporation, All Rights Reserved.
 * 
 *  Permission is hereby granted, free of charge, to any person obtaining a
 *  copy of this software and associated documentation files (the "Software"),
 *  to deal in the Software without restriction, including without limitation
 *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
 *  and/or sell copies of the Software, and to permit persons to whom the
 *  Software is furnished to do so, subject to the following conditions:
 * 
 *  The above copyright notice and this permission notice shall be included
 *  in all copies or substantial portions of the Software.
 * 
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *  MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 *  IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
 *  OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 *  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 *  OTHER DEALINGS IN THE SOFTWARE.
 * 
 *  Except as contained in this notice, the name of Dallas Semiconductor
 *  shall not be used except as stated in the Dallas Semiconductor
 *  Branding Policy.
 * --------------------------------------------------------------------------------------
 */

/****************************************************************************************
 *		Module Name : NTLM authentication module
 *		Description : NTLM authentication module function and datastructure declarations
 *	   	   Filename : ntlm.h
 *		   Compiler : keil C51 Compiler V7.06
 *			Version : Version 1.0
 *	  Modifications :
 *			  Notes :
 ****************************************************************************************/

/** \file tini400_ntlm.h
 *  \brief NTLM Library functions for DS80C400 processor
 *
 *  This library contains functions for managing NeTwork Lan Manager(NTLM) authentication protocol
 *  
 *  For detailed information on the DS80C400 please see the
 *  <a href="http://pdfserv.maxim-ic.com/arpdf/Design/DS80C400UG.pdf">
 *  High-Speed Microcontroller User's Guide: DS80C400 Supplement</a>.
 *
 *  \warning  The functions in this library are <b>NOT</b> multi-process 
 *            safe--that is, if you call the same method from two different 
 *            processes at the same time, the parameters to the function
 *            may be destroyed, yielding unpredictable results.
 */

#ifndef __rom400_ntlm_
#define __rom400_ntlm_

/** 
 * Structure for security buffer header
 */
typedef struct _sbufhdr
{
   unsigned int  len;        ///< length of the data
   unsigned int  buflen;     ///< length of the security buffer 
   unsigned long start_loc;  ///< starting address of the data
}sbufhdr;

/** 
 * Structure for type1 message header
 */
typedef struct _type1msghdr
{
	char          		signature[8];   ///< char array to store NTLM signature
    unsigned long       msgtype;        ///< NTLM Message Type
	unsigned long       flags;          ///< The NTLM flags  
	sbufhdr			    usr;            ///< user name security buffer header  
	sbufhdr			    domain;         ///< domain name security buffer header
}type1msghdr;

/** 
 * Structure for type1 message
 */
typedef struct _type1msg
{
	type1msghdr		  t1hdr;           ///< type 1 message header
	unsigned char     buf[1024];       ///< security buffer
	unsigned int	  buf_index;       ///< security buffer length
}type1msg;

/** 
 * Structure for type2 message header
 */
typedef struct _type2msghdr
{
	char          signature[8];      ///< char array to store NTLM signature
	unsigned long msgtype;           ///< The NTLM message type
	sbufhdr    	  domain;            ///< domain name security buffer header
	unsigned long flags;             ///< The NTLM flags
	unsigned char challenge[8];      ///< the 8 byte server challenge
	unsigned char context[8];        ///< reserved for future use
	sbufhdr		  targetinfo;        ///< target information.
}type2msghdr;

/** 
 * Structure for type2 message
 */
typedef struct _type2msg
{
	type2msghdr  t2hdr;             ///< char array to store NTLM signature
	unsigned char buf[1024];        ///< security buffer
	unsigned int  buf_index;        ///< security buffer length
}type2msg;

/** 
 * Structure for type3 message header
 */
typedef struct _type3msghdr
{
	char          signature[8];     ///< char array to store NTLM signature 
	unsigned long msgtype;          ///< The NTLM message type 
	sbufhdr 	  lmresponse;       ///< lan manager response
 	sbufhdr		  ntlmresponse;     ///< network lan manager response
	sbufhdr 	  domain;           ///< domain name buffer header
	sbufhdr		  usr;              ///< user name buffer header
	sbufhdr 	  workstation;      ///< workstation name buffer header
	sbufhdr		  session;          ///< session buffer header.  
	unsigned long flags;            ///< The NTLM flags
}type3msghdr;

/** 
 * Structure for type3 message
 */
typedef struct _type3msg
{
	type3msghdr  t3hdr;            ///< char array to store NTLM signature
	unsigned char buf[1024];       ///< security buffer
	unsigned int  buf_index;       ///< security buffer length
}type3msg;

/** definition for maximum ntlm security buffer length.
 * \sa #generate_type1_msg, #generate_type3_msg*/
#define MAX_NTLM_BUF 1024

/** definition for NTLM signature
 * \sa #generate_type1_msg, #generate_type3_msg*/
#define NTLM_SIGN "NTLMSSP\0"

/** definition for type 1 NTLM Message
 * \sa #generate_type1_msg*/
#define NTLM_TYPE1_MSG 1

/** definition for type 3 NTLM Message
 * \sa #generate_type3_msg*/
#define NTLM_TYPE3_MSG 3

/** definition for NTLM flags
 * \sa #generate_type1_msg, #generate_type3_msg*/
#define NTLM_FLAGS 0x0000b207L

//function prototypes
/**
 * \brief      Generates type1 NTLM message
 *
 *  	This function generates Type1 NTLM message that is sent to server to get type2 message.
 *	For more information, See NTLM authentication protocol specification.
 *
 * \param     t1_msg   the NTLM type 1 message 
 * \param     user     the user name 
 *
 * \sa        #generate_type3_msg
 */
void generate_type1_msg(type1msg *t1_msg, char *user);

/**
 * \brief      Generates type3 NTLM message
 *
 *  	This function generates Type3 NTLM message that contains both LAN Manager and NT LAN manager 
 *		responses for server challenge.For more information, See NTLM authentication protocol specification.
 *
 * \param     t2_msg   the type 2 NTLM message
 * \param	  t3_msg   the type 3 NTLM message
 * \param     user     user name 
 * \param	  pass	   password	
 *
 * \sa        #generate_type1_msg
 */
void generate_type3_msg(type2msg *t2_msg, type3msg *t3_msg, char *user, char *pass);

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -