windows-nt/Source/XPSP1/NT/net/sfm/uam/uam5src/uamsrc/crypto.h
2020-09-26 16:20:57 +08:00

1 line
9.4 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*++ BUILD Version: 0001 // Increment this if a change has global effects
Copyright (c) 1989 Microsoft Corporation
Module Name:
crypto.h
Abstract:
This module contains the public data structures and API definitions
needed to utilize the encryption library
Author:
David Chalmers (Davidc) 21-October-1991
Revision History:
--*/
#ifndef _NTCRYPT_
#define _NTCRYPT_
//#include "UAMUtils.h"
/////////////////////////////////////////////////////////////////////////
// //
// Core encryption types //
// //
/////////////////////////////////////////////////////////////////////////
#define CLEAR_BLOCK_LENGTH 8
typedef struct _CLEAR_BLOCK {
char data[CLEAR_BLOCK_LENGTH];
} CLEAR_BLOCK;
typedef CLEAR_BLOCK * PCLEAR_BLOCK;
#define CYPHER_BLOCK_LENGTH 8
typedef struct _CYPHER_BLOCK {
char data[CYPHER_BLOCK_LENGTH];
} CYPHER_BLOCK;
typedef CYPHER_BLOCK * PCYPHER_BLOCK;
#define BLOCK_KEY_LENGTH 7
typedef struct _BLOCK_KEY {
char data[BLOCK_KEY_LENGTH];
} BLOCK_KEY;
typedef BLOCK_KEY * PBLOCK_KEY;
/////////////////////////////////////////////////////////////////////////
// //
// Arbitrary length data encryption types //
// //
/////////////////////////////////////////////////////////////////////////
typedef struct _CRYPT_BUFFER {
DWORD Length; // Number of valid bytes in buffer
DWORD MaximumLength; // Number of bytes pointed to by Buffer
PVOID Buffer;
} CRYPT_BUFFER;
typedef CRYPT_BUFFER * PCRYPT_BUFFER;
typedef CRYPT_BUFFER CLEAR_DATA;
typedef CLEAR_DATA * PCLEAR_DATA;
typedef CRYPT_BUFFER DATA_KEY;
typedef DATA_KEY * PDATA_KEY;
typedef CRYPT_BUFFER CYPHER_DATA;
typedef CYPHER_DATA * PCYPHER_DATA;
/////////////////////////////////////////////////////////////////////////
// //
// Lan Manager data types //
// //
/////////////////////////////////////////////////////////////////////////
//
// Define a LanManager compatible password
//
// A LanManager password is a null-terminated ansi string consisting of a
// maximum of 14 characters (not including terminator)
//
typedef char * PLM_PASSWORD;
//
// Define the result of the 'One Way Function' (OWF) on a LM password
//
#define LM_OWF_PASSWORD_LENGTH (CYPHER_BLOCK_LENGTH * 2)
typedef struct _LM_OWF_PASSWORD {
CYPHER_BLOCK data[2];
} LM_OWF_PASSWORD;
typedef LM_OWF_PASSWORD * PLM_OWF_PASSWORD;
//
// Define the challenge sent by the Lanman server during logon
//
#define LM_CHALLENGE_LENGTH CLEAR_BLOCK_LENGTH
typedef CLEAR_BLOCK LM_CHALLENGE;
typedef LM_CHALLENGE * PLM_CHALLENGE;
//
// Define the response sent by redirector in response to challenge from server
//
#define LM_RESPONSE_LENGTH (CYPHER_BLOCK_LENGTH * 3)
typedef struct _LM_RESPONSE {
CYPHER_BLOCK data[3];
} LM_RESPONSE;
typedef LM_RESPONSE * PLM_RESPONSE;
//
// Define the result of the reversible encryption of an OWF'ed password.
//
#define ENCRYPTED_LM_OWF_PASSWORD_LENGTH (CYPHER_BLOCK_LENGTH * 2)
typedef struct _ENCRYPTED_LM_OWF_PASSWORD {
CYPHER_BLOCK data[2];
} ENCRYPTED_LM_OWF_PASSWORD;
typedef ENCRYPTED_LM_OWF_PASSWORD * PENCRYPTED_LM_OWF_PASSWORD;
//
// Define the session key maintained by the redirector and server
//
#define LM_SESSION_KEY_LENGTH LM_CHALLENGE_LENGTH
typedef LM_CHALLENGE LM_SESSION_KEY;
typedef LM_SESSION_KEY * PLM_SESSION_KEY;
//
// Define the index type used to encrypt OWF Passwords
//
typedef DWORD CRYPT_INDEX;
typedef CRYPT_INDEX * PCRYPT_INDEX;
/////////////////////////////////////////////////////////////////////////
// //
// 'NT' encryption types that are used to duplicate existing LM //
// functionality with improved algorithms. //
// //
/////////////////////////////////////////////////////////////////////////
#define NT_OWF_PASSWORD_LENGTH LM_OWF_PASSWORD_LENGTH
typedef LM_OWF_PASSWORD NT_OWF_PASSWORD;
typedef NT_OWF_PASSWORD * PNT_OWF_PASSWORD;
#define NT_CHALLENGE_LENGTH LM_CHALLENGE_LENGTH
typedef LM_CHALLENGE NT_CHALLENGE;
typedef NT_CHALLENGE * PNT_CHALLENGE;
#define NT_RESPONSE_LENGTH LM_RESPONSE_LENGTH
typedef LM_RESPONSE NT_RESPONSE;
typedef NT_RESPONSE * PNT_RESPONSE;
#define ENCRYPTED_NT_OWF_PASSWORD_LENGTH ENCRYPTED_LM_OWF_PASSWORD_LENGTH
typedef ENCRYPTED_LM_OWF_PASSWORD ENCRYPTED_NT_OWF_PASSWORD;
typedef ENCRYPTED_NT_OWF_PASSWORD * PENCRYPTED_NT_OWF_PASSWORD;
#define NT_SESSION_KEY_LENGTH LM_SESSION_KEY_LENGTH
typedef LM_SESSION_KEY NT_SESSION_KEY;
typedef NT_SESSION_KEY * PNT_SESSION_KEY;
/////////////////////////////////////////////////////////////////////////
// //
// 'NT' encryption types for new functionality not present in LM //
// //
/////////////////////////////////////////////////////////////////////////
//
// The user session key is similar to the LM and NT session key except it
// is different for each user on the system. This allows it to be used
// for secure user communication with a server.
//
#define USER_SESSION_KEY_LENGTH (CYPHER_BLOCK_LENGTH * 2)
typedef struct _USER_SESSION_KEY {
CYPHER_BLOCK data[2];
} USER_SESSION_KEY;
typedef USER_SESSION_KEY * PUSER_SESSION_KEY;
////////////////////////////////////////////////////////////////////////////
// //
// Encryption library API macros //
// //
// To conceal the purpose of these functions to someone dumping out the //
// encryption dll they have been purposefully given unhelpful names. //
// Each has an associated macro that should be used by system components //
// to access these routines in a readable way. //
// //
////////////////////////////////////////////////////////////////////////////
#define RtlEncryptBlock SystemFunction001
#define RtlDecryptBlock SystemFunction002
#define RtlEncryptStdBlock SystemFunction003
#define RtlEncryptData SystemFunction004
#define RtlDecryptData SystemFunction005
#define RtlCalculateLmOwfPassword SystemFunction006
#define RtlCalculateNtOwfPassword SystemFunction007
#define RtlCalculateLmResponse SystemFunction008
#define RtlCalculateNtResponse SystemFunction009
#define RtlCalculateUserSessionKeyLm SystemFunction010
#define RtlCalculateUserSessionKeyNt SystemFunction011
#define RtlEncryptLmOwfPwdWithLmOwfPwd SystemFunction012
#define RtlDecryptLmOwfPwdWithLmOwfPwd SystemFunction013
#define RtlEncryptNtOwfPwdWithNtOwfPwd SystemFunction014
#define RtlDecryptNtOwfPwdWithNtOwfPwd SystemFunction015
#define RtlEncryptLmOwfPwdWithLmSesKey SystemFunction016
#define RtlDecryptLmOwfPwdWithLmSesKey SystemFunction017
#define RtlEncryptNtOwfPwdWithNtSesKey SystemFunction018
#define RtlDecryptNtOwfPwdWithNtSesKey SystemFunction019
#define RtlEncryptLmOwfPwdWithUserKey SystemFunction020
#define RtlDecryptLmOwfPwdWithUserKey SystemFunction021
#define RtlEncryptNtOwfPwdWithUserKey SystemFunction022
#define RtlDecryptNtOwfPwdWithUserKey SystemFunction023
#define RtlEncryptLmOwfPwdWithIndex SystemFunction024
#define RtlDecryptLmOwfPwdWithIndex SystemFunction025
#define RtlEncryptNtOwfPwdWithIndex SystemFunction026
#define RtlDecryptNtOwfPwdWithIndex SystemFunction027
#define RtlGetUserSessionKeyClient SystemFunction028
#define RtlGetUserSessionKeyServer SystemFunction029
#define RtlEqualLmOwfPassword SystemFunction030
#define RtlEqualNtOwfPassword SystemFunction031
#define RtlEncryptData2 SystemFunction032
#define RtlDecryptData2 SystemFunction033
////////////////////////////////////////////////////////////////////////////
// //
// Encryption library API function prototypes //
// //
////////////////////////////////////////////////////////////////////////////
#endif // _NTCRYPT_