| 308 |
return FALSE; |
return FALSE; |
| 309 |
} |
} |
| 310 |
|
|
| 311 |
static void no_encrypt(PTInstVar pvar, unsigned char *buf, int bytes) |
static void no_encrypt(PTInstVar pvar, unsigned char *buf, unsigned int bytes) |
| 312 |
{ |
{ |
| 313 |
} |
} |
| 314 |
|
|
| 315 |
static void crypt_SSH2_encrypt(PTInstVar pvar, unsigned char *buf, int bytes) |
static void crypt_SSH2_encrypt(PTInstVar pvar, unsigned char *buf, unsigned int bytes) |
| 316 |
{ |
{ |
| 317 |
unsigned char *newbuff; |
unsigned char *newbuff; |
| 318 |
int block_size = pvar->ssh2_keys[MODE_OUT].enc.block_size; |
int block_size = pvar->ssh2_keys[MODE_OUT].enc.block_size; |
| 348 |
} |
} |
| 349 |
} |
} |
| 350 |
|
|
| 351 |
static void crypt_SSH2_decrypt(PTInstVar pvar, unsigned char *buf, int bytes) |
static void crypt_SSH2_decrypt(PTInstVar pvar, unsigned char *buf, unsigned int bytes) |
| 352 |
{ |
{ |
| 353 |
unsigned char *newbuff; |
unsigned char *newbuff; |
| 354 |
int block_size = pvar->ssh2_keys[MODE_IN].enc.block_size; |
int block_size = pvar->ssh2_keys[MODE_IN].enc.block_size; |
| 384 |
} |
} |
| 385 |
} |
} |
| 386 |
|
|
| 387 |
static void c3DES_encrypt(PTInstVar pvar, unsigned char *buf, int bytes) |
static void c3DES_encrypt(PTInstVar pvar, unsigned char *buf, unsigned int bytes) |
| 388 |
{ |
{ |
| 389 |
Cipher3DESState *encryptstate = &pvar->crypt_state.enc.c3DES; |
Cipher3DESState *encryptstate = &pvar->crypt_state.enc.c3DES; |
| 390 |
|
|
| 396 |
&encryptstate->k3, &encryptstate->ivec3, DES_ENCRYPT); |
&encryptstate->k3, &encryptstate->ivec3, DES_ENCRYPT); |
| 397 |
} |
} |
| 398 |
|
|
| 399 |
static void c3DES_decrypt(PTInstVar pvar, unsigned char *buf, int bytes) |
static void c3DES_decrypt(PTInstVar pvar, unsigned char *buf, unsigned int bytes) |
| 400 |
{ |
{ |
| 401 |
Cipher3DESState *decryptstate = &pvar->crypt_state.dec.c3DES; |
Cipher3DESState *decryptstate = &pvar->crypt_state.dec.c3DES; |
| 402 |
|
|
| 408 |
&decryptstate->k1, &decryptstate->ivec1, DES_DECRYPT); |
&decryptstate->k1, &decryptstate->ivec1, DES_DECRYPT); |
| 409 |
} |
} |
| 410 |
|
|
| 411 |
static void cDES_encrypt(PTInstVar pvar, unsigned char *buf, int bytes) |
static void cDES_encrypt(PTInstVar pvar, unsigned char *buf, unsigned int bytes) |
| 412 |
{ |
{ |
| 413 |
CipherDESState *encryptstate = &pvar->crypt_state.enc.cDES; |
CipherDESState *encryptstate = &pvar->crypt_state.enc.cDES; |
| 414 |
|
|
| 416 |
&encryptstate->k, &encryptstate->ivec, DES_ENCRYPT); |
&encryptstate->k, &encryptstate->ivec, DES_ENCRYPT); |
| 417 |
} |
} |
| 418 |
|
|
| 419 |
static void cDES_decrypt(PTInstVar pvar, unsigned char *buf, int bytes) |
static void cDES_decrypt(PTInstVar pvar, unsigned char *buf, unsigned int bytes) |
| 420 |
{ |
{ |
| 421 |
CipherDESState *decryptstate = &pvar->crypt_state.dec.cDES; |
CipherDESState *decryptstate = &pvar->crypt_state.dec.cDES; |
| 422 |
|
|
| 424 |
&decryptstate->k, &decryptstate->ivec, DES_DECRYPT); |
&decryptstate->k, &decryptstate->ivec, DES_DECRYPT); |
| 425 |
} |
} |
| 426 |
|
|
| 427 |
static void flip_endianness(unsigned char *cbuf, int bytes) |
static void flip_endianness(unsigned char *cbuf, unsigned int bytes) |
| 428 |
{ |
{ |
| 429 |
uint32 *buf = (uint32 *) cbuf; |
uint32 *buf = (uint32 *) cbuf; |
| 430 |
int count = bytes / 4; |
int count = bytes / 4; |
| 439 |
} |
} |
| 440 |
} |
} |
| 441 |
|
|
| 442 |
static void cBlowfish_encrypt(PTInstVar pvar, unsigned char *buf, int bytes) |
static void cBlowfish_encrypt(PTInstVar pvar, unsigned char *buf, unsigned int bytes) |
| 443 |
{ |
{ |
| 444 |
CipherBlowfishState *encryptstate = |
CipherBlowfishState *encryptstate = |
| 445 |
&pvar->crypt_state.enc.cBlowfish; |
&pvar->crypt_state.enc.cBlowfish; |
| 450 |
flip_endianness(buf, bytes); |
flip_endianness(buf, bytes); |
| 451 |
} |
} |
| 452 |
|
|
| 453 |
static void cBlowfish_decrypt(PTInstVar pvar, unsigned char *buf, int bytes) |
static void cBlowfish_decrypt(PTInstVar pvar, unsigned char *buf, unsigned int bytes) |
| 454 |
{ |
{ |
| 455 |
CipherBlowfishState *decryptstate = |
CipherBlowfishState *decryptstate = |
| 456 |
&pvar->crypt_state.dec.cBlowfish; |
&pvar->crypt_state.dec.cBlowfish; |
| 461 |
flip_endianness(buf, bytes); |
flip_endianness(buf, bytes); |
| 462 |
} |
} |
| 463 |
|
|
| 464 |
void CRYPT_set_random_data(PTInstVar pvar, unsigned char *buf, int bytes) |
void CRYPT_set_random_data(PTInstVar pvar, unsigned char *buf, unsigned int bytes) |
| 465 |
{ |
{ |
| 466 |
RAND_bytes(buf, bytes); |
RAND_bytes(buf, bytes); |
| 467 |
} |
} |