# include <nettle/aes.h>
# include <nettle/cbc.h>
# include <nettle/gcm.h>
+# include <assert.h>
/* this tests whether the API to override ciphers works sanely.
*/
}
struct myaes_ctx {
- struct aes_ctx aes;
+ struct aes128_ctx aes;
unsigned char iv[16];
int enc;
};
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));
{
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;
}
struct myaes_ctx *ctx = _ctx;
used++;
- 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;
}
struct myaes_ctx *ctx = _ctx;
used++;
- 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;
}