libcrypto: Fix build with DEBUG_CRYPTO turned on
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
родитель
21bf499bb4
Коммит
94d00009cc
@ -602,7 +602,10 @@ typedef uint8_t des_iv_t[8];
|
|||||||
|
|
||||||
struct ssh_3des_key_schedule {
|
struct ssh_3des_key_schedule {
|
||||||
DES_key_schedule keys[3];
|
DES_key_schedule keys[3];
|
||||||
des_iv_t ivs[3];
|
union {
|
||||||
|
des_iv_t v[3];
|
||||||
|
uint8_t *c;
|
||||||
|
} ivs;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* 3des cbc for SSH-1 has no suitable EVP construct and requires
|
/* 3des cbc for SSH-1 has no suitable EVP construct and requires
|
||||||
@ -622,35 +625,35 @@ static int des3_set_key(struct ssh_cipher_struct *cipher, void *key, void *IV){
|
|||||||
DES_set_key_unchecked(&keys[0], &cipher->des3_key->keys[0]);
|
DES_set_key_unchecked(&keys[0], &cipher->des3_key->keys[0]);
|
||||||
DES_set_key_unchecked(&keys[1], &cipher->des3_key->keys[1]);
|
DES_set_key_unchecked(&keys[1], &cipher->des3_key->keys[1]);
|
||||||
DES_set_key_unchecked(&keys[2], &cipher->des3_key->keys[2]);
|
DES_set_key_unchecked(&keys[2], &cipher->des3_key->keys[2]);
|
||||||
memcpy(cipher->des3_key->ivs, IV, 24);
|
memcpy(cipher->des3_key->ivs.v, IV, 24);
|
||||||
return SSH_OK;
|
return SSH_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void des3_1_encrypt(struct ssh_cipher_struct *cipher, void *in,
|
static void des3_1_encrypt(struct ssh_cipher_struct *cipher, void *in,
|
||||||
void *out, unsigned long len) {
|
void *out, unsigned long len) {
|
||||||
#ifdef DEBUG_CRYPTO
|
#ifdef DEBUG_CRYPTO
|
||||||
ssh_print_hexa("Encrypt IV before", cipher->des3_key->ivs, 24);
|
ssh_print_hexa("Encrypt IV before", cipher->des3_key->ivs.c, 24);
|
||||||
#endif
|
#endif
|
||||||
DES_ncbc_encrypt(in, out, len, &cipher->des3_key->keys[0], &cipher->des3_key->ivs[0], 1);
|
DES_ncbc_encrypt(in, out, len, &cipher->des3_key->keys[0], &cipher->des3_key->ivs.v[0], 1);
|
||||||
DES_ncbc_encrypt(out, in, len, &cipher->des3_key->keys[1], &cipher->des3_key->ivs[1], 0);
|
DES_ncbc_encrypt(out, in, len, &cipher->des3_key->keys[1], &cipher->des3_key->ivs.v[1], 0);
|
||||||
DES_ncbc_encrypt(in, out, len, &cipher->des3_key->keys[2], &cipher->des3_key->ivs[2], 1);
|
DES_ncbc_encrypt(in, out, len, &cipher->des3_key->keys[2], &cipher->des3_key->ivs.v[2], 1);
|
||||||
#ifdef DEBUG_CRYPTO
|
#ifdef DEBUG_CRYPTO
|
||||||
ssh_print_hexa("Encrypt IV after", cipher->des3_key->ivs, 24);
|
ssh_print_hexa("Encrypt IV after", cipher->des3_key->ivs.c, 24);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void des3_1_decrypt(struct ssh_cipher_struct *cipher, void *in,
|
static void des3_1_decrypt(struct ssh_cipher_struct *cipher, void *in,
|
||||||
void *out, unsigned long len) {
|
void *out, unsigned long len) {
|
||||||
#ifdef DEBUG_CRYPTO
|
#ifdef DEBUG_CRYPTO
|
||||||
ssh_print_hexa("Decrypt IV before", cipher->des3_key->ivs, 24);
|
ssh_print_hexa("Decrypt IV before", cipher->des3_key->ivs.c, 24);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DES_ncbc_encrypt(in, out, len, &cipher->des3_key->keys[2], &cipher->des3_key->ivs[0], 0);
|
DES_ncbc_encrypt(in, out, len, &cipher->des3_key->keys[2], &cipher->des3_key->ivs.v[0], 0);
|
||||||
DES_ncbc_encrypt(out, in, len, &cipher->des3_key->keys[1], &cipher->des3_key->ivs[1], 1);
|
DES_ncbc_encrypt(out, in, len, &cipher->des3_key->keys[1], &cipher->des3_key->ivs.v[1], 1);
|
||||||
DES_ncbc_encrypt(in, out, len, &cipher->des3_key->keys[0], &cipher->des3_key->ivs[2], 0);
|
DES_ncbc_encrypt(in, out, len, &cipher->des3_key->keys[0], &cipher->des3_key->ivs.v[2], 0);
|
||||||
|
|
||||||
#ifdef DEBUG_CRYPTO
|
#ifdef DEBUG_CRYPTO
|
||||||
ssh_print_hexa("Decrypt IV after", cipher->des3_key->ivs, 24);
|
ssh_print_hexa("Decrypt IV after", cipher->des3_key->ivs.c, 24);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -662,18 +665,18 @@ static int des1_set_key(struct ssh_cipher_struct *cipher, void *key, void *IV) {
|
|||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
DES_set_key_unchecked(key, &cipher->des3_key->keys[0]);
|
DES_set_key_unchecked(key, &cipher->des3_key->keys[0]);
|
||||||
memcpy(cipher->des3_key->ivs, IV, 8);
|
memcpy(cipher->des3_key->ivs.v, IV, 8);
|
||||||
return SSH_OK;
|
return SSH_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void des1_1_encrypt(struct ssh_cipher_struct *cipher, void *in, void *out,
|
static void des1_1_encrypt(struct ssh_cipher_struct *cipher, void *in, void *out,
|
||||||
unsigned long len){
|
unsigned long len){
|
||||||
DES_ncbc_encrypt(in, out, len, &cipher->des3_key->keys[0], &cipher->des3_key->ivs[0], 1);
|
DES_ncbc_encrypt(in, out, len, &cipher->des3_key->keys[0], &cipher->des3_key->ivs.v[0], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void des1_1_decrypt(struct ssh_cipher_struct *cipher, void *in, void *out,
|
static void des1_1_decrypt(struct ssh_cipher_struct *cipher, void *in, void *out,
|
||||||
unsigned long len){
|
unsigned long len){
|
||||||
DES_ncbc_encrypt(in,out,len, &cipher->des3_key->keys[0], &cipher->des3_key->ivs[0], 0);
|
DES_ncbc_encrypt(in,out,len, &cipher->des3_key->keys[0], &cipher->des3_key->ivs.v[0], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void des_cleanup(struct ssh_cipher_struct *cipher){
|
static void des_cleanup(struct ssh_cipher_struct *cipher){
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user