34static const unsigned char permute[256] = {
35 217,120,249,196, 25,221,181,237, 40,233,253,121, 74,160,216,157,
36 198,126, 55,131, 43,118, 83,142, 98, 76,100,136, 68,139,251,162,
37 23,154, 89,245,135,179, 79, 19, 97, 69,109,141, 9,129,125, 50,
38 189,143, 64,235,134,183,123, 11,240,149, 33, 34, 92,107, 78,130,
39 84,214,101,147,206, 96,178, 28,115, 86,192, 20,167,140,241,220,
40 18,117,202, 31, 59,190,228,209, 66, 61,212, 48,163, 60,182, 38,
41 111,191, 14,218, 70,105, 7, 87, 39,242, 29,155,188,148, 67, 3,
42 248, 17,199,246,144,239, 62,231, 6,195,213, 47,200,102, 30,215,
43 8,232,234,222,128, 82,238,247,132,170,114,172, 53, 77,106, 42,
44 150, 26,210,113, 90, 21, 73,116, 75,159,208, 94, 4, 24,164,236,
45 194,224, 65,110, 15, 81,203,204, 36,145,175, 80,161,244,112, 57,
46 153,124, 58,133, 35,184,180,122,252, 2, 54, 91, 37, 85,151, 49,
47 45, 93,250,152,227,138,146,174, 5,223, 41, 16,103,108,186,201,
48 211, 0,230,207,225,158,168, 44, 99, 22, 1, 63, 88,226,137,169,
49 13, 56, 52, 27,171, 51,255,176,187, 72, 12, 95,185,177,205, 46,
50 197,243,219, 71,229,165,156,119, 10,166, 32,104,254,127,193,173
55 unsigned *xkey =
rc2->xkey;
56 unsigned char tmp[128];
60 if (keylen < 5 || keylen > 128) {
64 if (rounds != 0 && rounds != 16) {
80 for (
i = 0;
i < keylen;
i++) {
81 tmp[
i] =
key[
i] & 255;
86 for (
i = keylen;
i < 128;
i++) {
87 tmp[
i] =
permute[(tmp[
i - 1] + tmp[
i - keylen]) & 255];
95 tmp[128 - T8] =
permute[tmp[128 - T8] & TM];
96 for (
i = 127 - T8;
i >= 0;
i--) {
101 for (
i = 0;
i < 64;
i++) {
102 xkey[
i] = (
unsigned)tmp[2*
i] + ((
unsigned)tmp[2*
i+1] << 8);
116 unsigned x76, x54, x32, x10,
i;
125 for (
i = 0;
i < 16;
i++) {
126 x10 = (x10 + (x32 & ~x76) + (x54 & x76) + xkey[4*
i+0]) & 0xFFFF;
127 x10 = ((x10 << 1) | (x10 >> 15));
129 x32 = (x32 + (x54 & ~x10) + (x76 & x10) + xkey[4*
i+1]) & 0xFFFF;
130 x32 = ((x32 << 2) | (x32 >> 14));
132 x54 = (x54 + (x76 & ~x32) + (x10 & x32) + xkey[4*
i+2]) & 0xFFFF;
133 x54 = ((x54 << 3) | (x54 >> 13));
135 x76 = (x76 + (x10 & ~x54) + (x32 & x54) + xkey[4*
i+3]) & 0xFFFF;
136 x76 = ((x76 << 5) | (x76 >> 11));
138 if (
i == 4 ||
i == 10) {
139 x10 = (x10 + xkey[x76 & 63]) & 0xFFFF;
140 x32 = (x32 + xkey[x10 & 63]) & 0xFFFF;
141 x54 = (x54 + xkey[x32 & 63]) & 0xFFFF;
142 x76 = (x76 + xkey[x54 & 63]) & 0xFFFF;
160 unsigned char *plain,
163 unsigned x76, x54, x32, x10;
174 for (
i = 15;
i >= 0;
i--) {
175 if (
i == 4 ||
i == 10) {
176 x76 = (x76 - xkey[x54 & 63]) & 0xFFFF;
177 x54 = (x54 - xkey[x32 & 63]) & 0xFFFF;
178 x32 = (x32 - xkey[x10 & 63]) & 0xFFFF;
179 x10 = (x10 - xkey[x76 & 63]) & 0xFFFF;
182 x76 = ((x76 << 11) | (x76 >> 5));
183 x76 = (x76 - ((x10 & ~x54) + (x32 & x54) + xkey[4*
i+3])) & 0xFFFF;
185 x54 = ((x54 << 13) | (x54 >> 3));
186 x54 = (x54 - ((x76 & ~x32) + (x10 & x32) + xkey[4*
i+2])) & 0xFFFF;
188 x32 = ((x32 << 14) | (x32 >> 2));
189 x32 = (x32 - ((x54 & ~x10) + (x76 & x10) + xkey[4*
i+1])) & 0xFFFF;
191 x10 = ((x10 << 15) | (x10 >> 1));
192 x10 = (x10 - ((x32 & ~x76) + (x54 & x76) + xkey[4*
i+0])) & 0xFFFF;
195 plain[0] = (
unsigned char)x10;
196 plain[1] = (
unsigned char)(x10 >> 8);
197 plain[2] = (
unsigned char)x32;
198 plain[3] = (
unsigned char)(x32 >> 8);
199 plain[4] = (
unsigned char)x54;
200 plain[5] = (
unsigned char)(x54 >> 8);
201 plain[6] = (
unsigned char)x76;
202 plain[7] = (
unsigned char)(x76 >> 8);
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
static unsigned(__cdecl *hash_bstr)(bstr_t s)
void rc2_ecb_encrypt(const unsigned char *plain, unsigned char *cipher, rc2_key *rc2)
static const unsigned char permute[256]
int rc2_setup(const unsigned char *key, int keylen, int bits, int rounds, rc2_key *rc2)
void rc2_ecb_decrypt(const unsigned char *cipher, unsigned char *plain, rc2_key *rc2)