Fix some clang warnings
The af_alg engine and associated test were creating warnings when compiled with clang. This fixes it. Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
parent
e2524943ce
commit
a193388811
@ -129,7 +129,7 @@ static int afalg_chk_platform(void);
|
|||||||
static const char *engine_afalg_id = "afalg";
|
static const char *engine_afalg_id = "afalg";
|
||||||
static const char *engine_afalg_name = "AFLAG engine support";
|
static const char *engine_afalg_name = "AFLAG engine support";
|
||||||
|
|
||||||
int afalg_cipher_nids[] = {
|
static int afalg_cipher_nids[] = {
|
||||||
NID_aes_128_cbc
|
NID_aes_128_cbc
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -445,14 +445,11 @@ static int afalg_start_cipher_sk(afalg_ctx *actx, const unsigned char *in,
|
|||||||
# ifdef ALG_ZERO_COPY
|
# ifdef ALG_ZERO_COPY
|
||||||
int ret;
|
int ret;
|
||||||
# endif
|
# endif
|
||||||
|
char cbuf[CMSG_SPACE(ALG_IV_LEN(ALG_AES_IV_LEN)) + CMSG_SPACE(ALG_OP_LEN)];
|
||||||
|
|
||||||
const ssize_t cbuf_sz = CMSG_SPACE(ALG_IV_LEN(ALG_AES_IV_LEN))
|
memset(cbuf, 0, sizeof(cbuf));
|
||||||
+ CMSG_SPACE(ALG_OP_LEN);
|
|
||||||
char cbuf[cbuf_sz];
|
|
||||||
|
|
||||||
memset(cbuf, 0, cbuf_sz);
|
|
||||||
msg.msg_control = cbuf;
|
msg.msg_control = cbuf;
|
||||||
msg.msg_controllen = cbuf_sz;
|
msg.msg_controllen = sizeof(cbuf);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* cipher direction (i.e. encrypt or decrypt) and iv are sent to the
|
* cipher direction (i.e. encrypt or decrypt) and iv are sent to the
|
||||||
|
@ -58,6 +58,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_AFALGENG
|
#ifndef OPENSSL_NO_AFALGENG
|
||||||
|
|
||||||
|
/* Use a buffer size which is not aligned to block size */
|
||||||
|
#define BUFFER_SIZE (8 * 1024) - 13
|
||||||
|
|
||||||
static int test_afalg_aes_128_cbc(ENGINE *e)
|
static int test_afalg_aes_128_cbc(ENGINE *e)
|
||||||
{
|
{
|
||||||
EVP_CIPHER_CTX *ctx;
|
EVP_CIPHER_CTX *ctx;
|
||||||
@ -66,11 +70,10 @@ static int test_afalg_aes_128_cbc(ENGINE *e)
|
|||||||
\x1D\x83\x27\xDE\xB8\x82\xCF\x99";
|
\x1D\x83\x27\xDE\xB8\x82\xCF\x99";
|
||||||
unsigned char iv[] = "\x2B\x95\x99\x0A\x91\x51\x37\x4A\
|
unsigned char iv[] = "\x2B\x95\x99\x0A\x91\x51\x37\x4A\
|
||||||
\xBD\x8F\xF8\xC5\xA7\xA0\xFE\x08";
|
\xBD\x8F\xF8\xC5\xA7\xA0\xFE\x08";
|
||||||
/* Use a buffer which is not aligned to block size */
|
|
||||||
const int bufsz = (8 * 1024) - 13;
|
unsigned char in[BUFFER_SIZE];
|
||||||
unsigned char in[bufsz];
|
unsigned char ebuf[BUFFER_SIZE + 32];
|
||||||
unsigned char ebuf[bufsz + 32];
|
unsigned char dbuf[BUFFER_SIZE + 32];
|
||||||
unsigned char dbuf[bufsz + 32];
|
|
||||||
int encl, encf, decl, decf;
|
int encl, encf, decl, decf;
|
||||||
unsigned int status = 0;
|
unsigned int status = 0;
|
||||||
|
|
||||||
@ -80,10 +83,10 @@ static int test_afalg_aes_128_cbc(ENGINE *e)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EVP_CIPHER_CTX_init(ctx);
|
EVP_CIPHER_CTX_init(ctx);
|
||||||
RAND_bytes(in, bufsz);
|
RAND_bytes(in, BUFFER_SIZE);
|
||||||
|
|
||||||
if ( !EVP_CipherInit_ex(ctx, cipher, e, key, iv, 1)
|
if ( !EVP_CipherInit_ex(ctx, cipher, e, key, iv, 1)
|
||||||
|| !EVP_CipherUpdate(ctx, ebuf, &encl, in, bufsz)
|
|| !EVP_CipherUpdate(ctx, ebuf, &encl, in, BUFFER_SIZE)
|
||||||
|| !EVP_CipherFinal_ex(ctx, ebuf+encl, &encf)) {
|
|| !EVP_CipherFinal_ex(ctx, ebuf+encl, &encf)) {
|
||||||
fprintf(stderr, "%s() failed encryption\n", __func__);
|
fprintf(stderr, "%s() failed encryption\n", __func__);
|
||||||
goto end;
|
goto end;
|
||||||
@ -99,8 +102,8 @@ static int test_afalg_aes_128_cbc(ENGINE *e)
|
|||||||
}
|
}
|
||||||
decl += decf;
|
decl += decf;
|
||||||
|
|
||||||
if ( decl != bufsz
|
if ( decl != BUFFER_SIZE
|
||||||
|| memcmp(dbuf, in, bufsz)) {
|
|| memcmp(dbuf, in, BUFFER_SIZE)) {
|
||||||
fprintf(stderr, "%s() failed Dec(Enc(P)) != P\n", __func__);
|
fprintf(stderr, "%s() failed Dec(Enc(P)) != P\n", __func__);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user