From 8bb53ae25cf121310ede56e9366905957c58be41 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Sun, 11 Dec 2011 14:13:17 +0100 Subject: [PATCH] cleanups --- tests/cipher-aead-srtp.c | 6 ------ tests/cipher-aead.c | 23 +++++++++++++---------- tests/cipher-gcm.c | 15 +++++---------- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/tests/cipher-aead-srtp.c b/tests/cipher-aead-srtp.c index d15fc3e..5a6836a 100644 --- a/tests/cipher-aead-srtp.c +++ b/tests/cipher-aead-srtp.c @@ -27,7 +27,6 @@ get_sha1_hmac(int cfd, void* key, int key_size, void* data, int data_size, void* { struct session_op sess; struct crypt_op cryp; - int i; memset(&sess, 0, sizeof(sess)); memset(&cryp, 0, sizeof(cryp)); @@ -84,7 +83,6 @@ test_crypto(int cfd) unsigned char tag[20]; unsigned char mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; int mackey_len = 16; - int pad, i; struct session_op sess; struct crypt_op co; @@ -234,11 +232,9 @@ test_encrypt_decrypt(int cfd) char ciphertext_raw[DATA_SIZE + 63], *ciphertext; char iv[BLOCK_SIZE]; char key[KEY_SIZE]; - unsigned char sha1mac[20]; unsigned char tag[20]; unsigned char mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; int mackey_len = 16; - int pad, i; struct session_op sess; struct crypt_auth_op cao; @@ -384,11 +380,9 @@ test_encrypt_decrypt_error(int cfd, int err) char ciphertext_raw[DATA_SIZE + 63], *ciphertext; char iv[BLOCK_SIZE]; char key[KEY_SIZE]; - unsigned char sha1mac[20]; unsigned char tag[20]; unsigned char mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; int mackey_len = 16; - int pad, i; struct session_op sess; struct crypt_auth_op cao; diff --git a/tests/cipher-aead.c b/tests/cipher-aead.c index ab29aec..4047030 100644 --- a/tests/cipher-aead.c +++ b/tests/cipher-aead.c @@ -25,7 +25,6 @@ get_sha1_hmac(int cfd, void* key, int key_size, void* data1, int data1_size, voi { struct session_op sess; struct crypt_op cryp; - int i; memset(&sess, 0, sizeof(sess)); memset(&cryp, 0, sizeof(cryp)); @@ -114,7 +113,7 @@ test_crypto(int cfd) /* Get crypto session for AES128 */ sess.cipher = CRYPTO_AES_CBC; sess.keylen = KEY_SIZE; - sess.key = key; + sess.key = (void*)key; sess.mac = CRYPTO_SHA1_HMAC; sess.mackeylen = 16; @@ -147,14 +146,14 @@ test_crypto(int cfd) return 1; } - //memcpy(ciphertext, plaintext, DATA_SIZE); + memcpy(ciphertext, plaintext, DATA_SIZE); /* Encrypt data.in to data.encrypted */ cao.ses = sess.ses; cao.auth_src = auth; cao.auth_len = sizeof(auth); cao.len = DATA_SIZE; - cao.src = plaintext; + cao.src = ciphertext; cao.dst = ciphertext; cao.iv = iv; cao.op = COP_ENCRYPT; @@ -253,7 +252,7 @@ test_encrypt_decrypt(int cfd) char key[KEY_SIZE]; char auth[AUTH_SIZE]; unsigned char sha1mac[20]; - int pad, i, enc_len; + int enc_len; struct session_op sess; struct crypt_op co; @@ -306,13 +305,15 @@ test_encrypt_decrypt(int cfd) return 1; } + memcpy(ciphertext, plaintext, DATA_SIZE); + /* Encrypt data.in to data.encrypted */ cao.ses = sess.ses; - cao.auth_src = auth; + cao.auth_src = (void*)auth; cao.auth_len = sizeof(auth); cao.len = DATA_SIZE; - cao.src = plaintext; - cao.dst = ciphertext; + cao.src = (void*)ciphertext; + cao.dst = (void*)ciphertext; cao.iv = iv; cao.op = COP_ENCRYPT; cao.flags = COP_FLAG_AEAD_TLS_TYPE; @@ -406,7 +407,7 @@ test_encrypt_decrypt_error(int cfd, int err) char key[KEY_SIZE]; char auth[AUTH_SIZE]; unsigned char sha1mac[20]; - int pad, i, enc_len; + int enc_len; struct session_op sess; struct crypt_op co; @@ -458,13 +459,15 @@ test_encrypt_decrypt_error(int cfd, int err) fprintf(stderr, "SHA1 MAC failed\n"); return 1; } + + memcpy(ciphertext, plaintext, DATA_SIZE); /* Encrypt data.in to data.encrypted */ cao.ses = sess.ses; cao.auth_src = auth; cao.auth_len = sizeof(auth); cao.len = DATA_SIZE; - cao.src = plaintext; + cao.src = ciphertext; cao.dst = ciphertext; cao.iv = iv; cao.op = COP_ENCRYPT; diff --git a/tests/cipher-gcm.c b/tests/cipher-gcm.c index 9b5f4f9..bf74d4d 100644 --- a/tests/cipher-gcm.c +++ b/tests/cipher-gcm.c @@ -91,16 +91,11 @@ struct aes_gcm_vectors_st aes_gcm_vectors[] = { */ static int test_crypto(int cfd) { - char iv[BLOCK_SIZE]; - unsigned char tag[16]; - int pad, i; + int i; int8_t tmp[128]; struct session_op sess; struct crypt_auth_op cao; -#ifdef CIOCGSESSINFO - struct session_info_op siop; -#endif /* Get crypto session for AES128 */ @@ -194,8 +189,7 @@ static int test_encrypt_decrypt(int cfd) char iv[BLOCK_SIZE]; char key[KEY_SIZE]; char auth[AUTH_SIZE]; - unsigned char sha1mac[20]; - int pad, i, enc_len; + int enc_len; struct session_op sess; struct crypt_auth_op cao; @@ -342,7 +336,7 @@ static int test_encrypt_decrypt_error(int cfd, int err) char iv[BLOCK_SIZE]; char key[KEY_SIZE]; char auth[AUTH_SIZE]; - int pad, i, enc_len; + int enc_len; struct session_op sess; struct crypt_op co; @@ -397,13 +391,14 @@ static int test_encrypt_decrypt_error(int cfd, int err) ciphertext = ciphertext_raw; #endif memset(plaintext, 0x15, DATA_SIZE); + memcpy(ciphertext, plaintext, DATA_SIZE); /* Encrypt data.in to data.encrypted */ cao.ses = sess.ses; cao.auth_src = auth; cao.auth_len = sizeof(auth); cao.len = DATA_SIZE; - cao.src = plaintext; + cao.src = ciphertext; cao.dst = ciphertext; cao.iv = iv; cao.op = COP_ENCRYPT; -- 2.11.4.GIT