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
|
/* crypto.h
*
* Prototypes and definitions for services in crypto.c
*
* ported to win nt from win 95 on 6/95
* Cory West
*/
#include <windef.h>
#define CIPHERBLOCKSIZE 8 // size of RC2 block
#define MAX_RSA_BITS 512 // actually 420
#define MAX_RSA_BYTES (MAX_RSA_BITS/8)
#define B_PSIZEBITS 210
#define B_PSIZEWORDS (1 + B_PSIZEBITS/32)
void __cdecl
GenRandomBytes(
BYTE *output,
int len
);
//
// Generate an 8 byte key from a seed of the given length.
//
void __cdecl
GenKey8(
BYTE *keyData,
int keyDataLen,
BYTE key8[8]
);
void __cdecl
MD2(
BYTE *input,
const int inlen,
BYTE *output
);
//
// RC2 encrypt and decrypt wrappers.
//
int __cdecl
CBCEncrypt(
BYTE *key, // secret key
BYTE const *ivec, // initialization vector, NULL implies zero vector
BYTE *const input, // plain text
int inlen, // size of plaintext
BYTE *const output, // encrypted text
int *outlen, // OUTPUT: size of encrypted text
const int checksumlen // size of checksum, if 0 no checksum is used
);
int __cdecl
CBCDecrypt(
BYTE *key, // secret key
BYTE *ivec, // initialization vector, null ptr implies zero vector
BYTE *input, // encrypted text
int inlen, // size of encrypted text
BYTE *output, // plain text
int *outlen, // OUTPUT: size of plaintext
int checksumlen // size of checksum; 0=> no checksum
);
//
// Wrappers to the RSA code.
//
int __cdecl
RSAGetInputBlockSize(
BYTE *keydata,
int keylen
);
BYTE * __cdecl
RSAGetModulus(
BYTE *keydata,
int keylen,
int *modSize
);
BYTE * _cdecl
RSAGetPublicExponent(
BYTE *keydata,
int keylen,
int *expSize
);
int __cdecl
RSAPack(
BYTE *input,
int inlen,
BYTE *output,
int blocksize
);
int __cdecl
RSAPublic(
BYTE *pukeydata, // BSAFE 1 itemized public key data
int pukeylen, // length of BSAFE1 keydata (including sign)
BYTE *input, // input block
int inlen, // size of input (< modulus)
BYTE *output // encrypted block (modulus sized)
);
int __cdecl
RSAPrivate(
BYTE *prkeydata,
int prkeylen,
BYTE *input,
int inlen,
BYTE *output
);
int __cdecl
RSAModMpy(
BYTE *pukeydata, // BSAFE 1 itemized public key data
int pukeylen, // length of BSAFE1 keydata (including sign)
BYTE *input1, // input block
int inlen1, // size of input (< modulus)
BYTE *input2, // multiplier
int inlen2, // size of multiplier
BYTE *output // encrypted block (modulus sized)
);
int __cdecl
RSAModExp(
BYTE *pukeydata, // BSAFE 1 itemized public key data
int pukeylen, // length of BSAFE1 keydata (including sign)
BYTE *input1, // input block
int inlen1, // size of input (< modulus)
BYTE *exponent,
int explen,
BYTE *output // encrypted block (modulus sized)
);
|