summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/cipher-alignment.c (renamed from tests/mini-alignment.c)21
2 files changed, 9 insertions, 14 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 075c2728f3..f08f76d0dd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -174,7 +174,7 @@ ctests += mini-record-2 simple gnutls_hmac_fast set_pkcs12_cred cert certuniquei
tls13-cert-key-exchange x509-cert-callback-ocsp gnutls_ocsp_resp_list_import2 \
server-sign-md5-rep privkey-keygen mini-tls-nonblock no-signal pkcs7-gen dtls-etm \
x509sign-verify-rsa x509sign-verify-ecdsa x509sign-verify-gost \
- mini-alignment oids atfork prf psk-file priority-init2 post-client-hello-change-prio \
+ cipher-alignment oids atfork prf psk-file priority-init2 post-client-hello-change-prio \
status-request status-request-ok rfc7633-missing sign-verify-ext \
fallback-scsv pkcs8-key-decode urls dtls-rehandshake-cert rfc7633-ok \
key-usage-rsa key-usage-ecdhe-rsa mini-session-verify-function auto-verify \
diff --git a/tests/mini-alignment.c b/tests/cipher-alignment.c
index 96f3d5b93a..bc5239281a 100644
--- a/tests/mini-alignment.c
+++ b/tests/cipher-alignment.c
@@ -68,10 +68,6 @@ static void tls_log_func(int level, const char *str)
str);
}
-/* A very basic TLS client, with anonymous authentication.
- */
-
-
#define MAX_BUF 1024
#define MSG "Hello TLS"
@@ -125,7 +121,7 @@ static unsigned char key_pem[] =
const gnutls_datum_t key = { key_pem, sizeof(key_pem) };
struct myaes_ctx {
- struct aes_ctx aes;
+ struct aes128_ctx aes;
unsigned char iv[16];
int enc;
};
@@ -133,10 +129,7 @@ struct myaes_ctx {
static int
myaes_init(gnutls_cipher_algorithm_t algorithm, void **_ctx, int enc)
{
- /* we use key size to distinguish */
- if (algorithm != GNUTLS_CIPHER_AES_128_CBC
- && algorithm != GNUTLS_CIPHER_AES_192_CBC
- && algorithm != GNUTLS_CIPHER_AES_256_CBC)
+ if (algorithm != GNUTLS_CIPHER_AES_128_CBC)
return GNUTLS_E_INVALID_REQUEST;
*_ctx = calloc(1, sizeof(struct myaes_ctx));
@@ -154,10 +147,12 @@ myaes_setkey(void *_ctx, const void *userkey, size_t keysize)
{
struct myaes_ctx *ctx = _ctx;
+ assert(keysize == 16);
+
if (ctx->enc)
- aes_set_encrypt_key(&ctx->aes, keysize, userkey);
+ aes128_set_encrypt_key(&ctx->aes, userkey);
else
- aes_set_decrypt_key(&ctx->aes, keysize, userkey);
+ aes128_set_decrypt_key(&ctx->aes, userkey);
return 0;
}
@@ -186,7 +181,7 @@ myaes_encrypt(void *_ctx, const void *src, size_t src_size,
fail("encrypt: dest is not 16-byte aligned: %lu\n", ((unsigned long)dst)%16);
}
- cbc_encrypt(&ctx->aes, (nettle_cipher_func*)aes_encrypt, 16, ctx->iv, src_size, dst, src);
+ cbc_encrypt(&ctx->aes, (nettle_cipher_func*)aes128_encrypt, 16, ctx->iv, src_size, dst, src);
return 0;
}
@@ -206,7 +201,7 @@ myaes_decrypt(void *_ctx, const void *src, size_t src_size,
}
#endif
- cbc_decrypt(&ctx->aes, (nettle_cipher_func*)aes_decrypt, 16, ctx->iv, src_size, dst, src);
+ cbc_decrypt(&ctx->aes, (nettle_cipher_func*)aes128_decrypt, 16, ctx->iv, src_size, dst, src);
return 0;
}