aboutsummaryrefslogtreecommitdiff
path: root/src/libcrypto.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2015-10-22 08:17:01 +0200
committerAndreas Schneider <asn@cryptomilk.org>2015-10-22 08:17:01 +0200
commit94d00009cc37a790da46568ac2dd5894f0144f6f (patch)
tree0b6a98157244cd18763ca08cef60edb7acc526e9 /src/libcrypto.c
parent21bf499bb4fbb4127f74966a6ea66ba282ee1cf5 (diff)
downloadlibssh-94d00009cc37a790da46568ac2dd5894f0144f6f.tar.gz
libssh-94d00009cc37a790da46568ac2dd5894f0144f6f.tar.xz
libssh-94d00009cc37a790da46568ac2dd5894f0144f6f.zip
libcrypto: Fix build with DEBUG_CRYPTO turned on
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/libcrypto.c')
-rw-r--r--src/libcrypto.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/libcrypto.c b/src/libcrypto.c
index 28347a05..ac950109 100644
--- a/src/libcrypto.c
+++ b/src/libcrypto.c
@@ -602,7 +602,10 @@ typedef uint8_t des_iv_t[8];
struct ssh_3des_key_schedule {
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
@@ -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[1], &cipher->des3_key->keys[1]);
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;
}
static void des3_1_encrypt(struct ssh_cipher_struct *cipher, void *in,
void *out, unsigned long len) {
#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
- DES_ncbc_encrypt(in, out, len, &cipher->des3_key->keys[0], &cipher->des3_key->ivs[0], 1);
- DES_ncbc_encrypt(out, in, len, &cipher->des3_key->keys[1], &cipher->des3_key->ivs[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[0], &cipher->des3_key->ivs.v[0], 1);
+ 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.v[2], 1);
#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
}
static void des3_1_decrypt(struct ssh_cipher_struct *cipher, void *in,
void *out, unsigned long len) {
#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
- DES_ncbc_encrypt(in, out, len, &cipher->des3_key->keys[2], &cipher->des3_key->ivs[0], 0);
- DES_ncbc_encrypt(out, in, len, &cipher->des3_key->keys[1], &cipher->des3_key->ivs[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[2], &cipher->des3_key->ivs.v[0], 0);
+ 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.v[2], 0);
#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
}
@@ -662,18 +665,18 @@ static int des1_set_key(struct ssh_cipher_struct *cipher, void *key, void *IV) {
return SSH_ERROR;
}
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;
}
static void des1_1_encrypt(struct ssh_cipher_struct *cipher, void *in, void *out,
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,
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){