1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
//************************************************************************
// Microsoft Corporation
// Copyright(c) Microsoft Corp., 1994
//
//
// Revision history:
// 5/5/94 Created gurdeep
//
// This file uses 4 space tabs
//************************************************************************
#ifdef COMP_12K
#define HISTORY_SIZE 16000
#else
#define HISTORY_SIZE (8192U) // Maximum back-pointer value, also used
#endif
#define HISTORY_MAX (HISTORY_SIZE -1) // Maximum back-pointer value, also used
#define HASH_TABLE_SIZE 4096
#define MAX_BACK_PTR 8511
#define MAX_COMPRESSFRAME_SIZE 1600
struct SendContext {
UCHAR History [HISTORY_SIZE+1] ;
int CurrentIndex ; // how far into the history buffer we are
PUCHAR ValidHistory ; // how much of history is valid
UCHAR CompressBuffer[MAX_COMPRESSFRAME_SIZE] ;
USHORT HashTable[HASH_TABLE_SIZE];
} ;
typedef struct SendContext SendContext ;
struct RecvContext {
UCHAR History [HISTORY_SIZE+1] ;
#if DBG
#define DEBUG_FENCE_VALUE 0xABABABAB
ULONG DebugFence;
#endif
UCHAR *CurrentPtr ; // how far into the history buffer we are
} ;
typedef struct RecvContext RecvContext ;
// Prototypes
//
UCHAR
compress (
UCHAR *CurrentBuffer,
UCHAR *CompOutBuffer,
ULONG *CurrentLength,
SendContext *context);
//UCHAR
//compress (
// UCHAR *CurrentBuffer,
// ULONG *CurrentLength,
// SendContext *context);
int
decompress (
UCHAR *inbuf,
int inlen,
int start,
UCHAR **output,
int *outlen,
RecvContext *context) ;
void getcontextsizes (long *, long *) ;
void initsendcontext (SendContext *) ;
void initrecvcontext (RecvContext *) ;
NDIS_STATUS
InitSHAContext(
PENCRYPTION_INFO EncryptInfo
);
VOID
GetStartKeyFromSHA(
PENCRYPTION_INFO EncryptInfo,
PUCHAR Challenge
);
VOID
GetNewKeyFromSHA(
PENCRYPTION_INFO EncryptInfo
);
//
// Other defines
//
#define COMPRESSION_PADDING 4
#define PACKET_FLUSHED 0x80
#define PACKET_AT_FRONT 0x40
#define PACKET_COMPRESSED 0x20
#define PACKET_ENCRYPTED 0x10
/* Copyright (C) RSA Data Security, Inc. created 1993. This is an
unpublished work protected as such under copyright law. This work
contains proprietary, confidential, and trade secret information of
RSA Data Security, Inc. Use, disclosure or reproduction without the
express written authorization of RSA Data Security, Inc. is
prohibited.
*/
#define A_SHA_DIGEST_LEN 20
typedef struct {
ULONG state[5]; /* state (ABCDE) */
ULONG count[2]; /* number of UCHARs, msb first */
unsigned char buffer[64]; /* input buffer */
} A_SHA_COMM_CTX;
typedef void (A_SHA_TRANSFORM) (ULONG [5], unsigned char [64]);
void A_SHAInitCommon (A_SHA_COMM_CTX *);
void A_SHAUpdateCommon(A_SHA_COMM_CTX *, UCHAR *, ULONG, A_SHA_TRANSFORM *);
void A_SHAFinalCommon(A_SHA_COMM_CTX *, UCHAR[A_SHA_DIGEST_LEN],
A_SHA_TRANSFORM *);
VOID ByteReverse(ULONG* Out, ULONG* In, ULONG Count);
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
ULONG FinishFlag;
UCHAR HashVal[A_SHA_DIGEST_LEN];
A_SHA_COMM_CTX commonContext;
} A_SHA_CTX;
void A_SHAInit(A_SHA_CTX *);
void A_SHAUpdate(A_SHA_CTX *, unsigned char *, unsigned int);
void A_SHAFinal(A_SHA_CTX *, unsigned char [A_SHA_DIGEST_LEN]);
#ifdef __cplusplus
}
#endif
/* F, G, H and I are basic SHA functions.
*/
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) ((x) ^ (y) ^ (z))
#define H(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
#define I(x, y, z) ((x) ^ (y) ^ (z))
/* ROTATE_LEFT rotates x left n bits.
*/
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
*/
#define ROUND(a, b, c, d, e, x, F, k) { \
(e) += ROTATE_LEFT ((a), 5) + F ((b), (c), (d)) + (x) + k; \
(b) = ROTATE_LEFT ((b), 30); \
}
#define FF(a, b, c, d, e, x) ROUND (a, b, c, d, e, x, F, 0x5a827999);
#define GG(a, b, c, d, e, x) ROUND (a, b, c, d, e, x, G, 0x6ed9eba1);
#define HH(a, b, c, d, e, x) ROUND (a, b, c, d, e, x, H, 0x8f1bbcdc);
#define II(a, b, c, d, e, x) ROUND (a, b, c, d, e, x, I, 0xca62c1d6);
void SHATransform(ULONG [5], unsigned char [64]);
void SHAExpand(ULONG [80]);
|