aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2019-01-26 14:23:34 +0100
committerAndreas Schneider <asn@cryptomilk.org>2019-01-26 15:47:49 +0100
commit303bdc5a4f1b21d873c5175262de72d7aa4f0a8d (patch)
tree180dcfd932ba607fc27a092fb86665b30429b0e2
parent9b694f396c4d391f27802eba0cc3f708959324b1 (diff)
downloadlibssh-303bdc5a4f1b21d873c5175262de72d7aa4f0a8d.tar.gz
libssh-303bdc5a4f1b21d873c5175262de72d7aa4f0a8d.tar.xz
libssh-303bdc5a4f1b21d873c5175262de72d7aa4f0a8d.zip
tests: Initialize ssh_cipher_struct in torture_crypto_aes256_cbc()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--tests/unittests/torture_crypto.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/tests/unittests/torture_crypto.c b/tests/unittests/torture_crypto.c
index 755e5c0b..fd5e7753 100644
--- a/tests/unittests/torture_crypto.c
+++ b/tests/unittests/torture_crypto.c
@@ -38,16 +38,22 @@ uint8_t aes256_cbc_encrypted[144] =
"\x0c\xd3\xfa\xc1\x33\x5b\xe1\xa1\xd4\x3d\x8f\xb8\x50\xc5\xb5"
"\x72\xdd\x6d\x32\x1f\x58\x00\x48\xbe";
-static int get_cipher(struct ssh_cipher_struct *cipher, const char *ciphername){
+static int get_cipher(struct ssh_cipher_struct *cipher, const char *ciphername)
+{
struct ssh_cipher_struct *ciphers = ssh_get_ciphertab();
- int i, cmp;
+ size_t i;
+ int cmp;
+
+ assert_non_null(cipher);
+
for (i = 0; ciphers[i].name != NULL; i++) {
- cmp = strcmp(ciphername, ciphers[i].name);
- if (cmp == 0){
- memcpy(cipher, &ciphers[i], sizeof(*cipher));
- return SSH_OK;
- }
+ cmp = strcmp(ciphername, ciphers[i].name);
+ if (cmp == 0){
+ memcpy(cipher, &ciphers[i], sizeof(*cipher));
+ return SSH_OK;
}
+ }
+
return SSH_ERROR;
}
@@ -55,13 +61,16 @@ static void torture_crypto_aes256_cbc(void **state)
{
uint8_t output[sizeof(cleartext)] = {0};
uint8_t iv[16] = {0};
- struct ssh_cipher_struct cipher;
+ struct ssh_cipher_struct cipher = {0};
int rc;
(void)state;
rc = get_cipher(&cipher, "aes256-cbc");
assert_int_equal(rc, SSH_OK);
+ assert_non_null(cipher.set_encrypt_key);
+ assert_non_null(cipher.encrypt);
+
memcpy(iv, IV, sizeof(IV));
cipher.set_encrypt_key(&cipher,
key,
@@ -80,6 +89,9 @@ static void torture_crypto_aes256_cbc(void **state)
rc = get_cipher(&cipher, "aes256-cbc");
assert_int_equal(rc, SSH_OK);
+ assert_non_null(cipher.set_decrypt_key);
+ assert_non_null(cipher.decrypt);
+
memcpy(iv, IV, sizeof(IV));
cipher.set_decrypt_key(&cipher,
key,