forked from wolfSSL/wolfssl
Merge pull request #8210 from night1rider/devcrypto-authtag-error
/dev/crypto auth error fix/adjustment for benchmark
This commit is contained in:
@ -1992,6 +1992,11 @@ static const char* bench_result_words2[][5] = {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(WOLFSSL_DEVCRYPTO) && defined(WOLFSSL_AUTHSZ_BENCH)
|
||||||
|
#warning Large/Unalligned AuthSz could result in errors with /dev/crypto
|
||||||
|
#endif
|
||||||
|
|
||||||
/* use kB instead of mB for embedded benchmarking */
|
/* use kB instead of mB for embedded benchmarking */
|
||||||
#ifdef BENCH_EMBEDDED
|
#ifdef BENCH_EMBEDDED
|
||||||
#ifndef BENCH_NTIMES
|
#ifndef BENCH_NTIMES
|
||||||
@ -4799,6 +4804,14 @@ void bench_gmac(int useDeviceID)
|
|||||||
const char* gmacStr = "GMAC Default";
|
const char* gmacStr = "GMAC Default";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Implementations of /Dev/Crypto will error out if the size of Auth in is */
|
||||||
|
/* greater than the system's page size */
|
||||||
|
#if defined(WOLFSSL_DEVCRYPTO) && defined(WOLFSSL_AUTHSZ_BENCH)
|
||||||
|
bench_size = WOLFSSL_AUTHSZ_BENCH;
|
||||||
|
#elif defined(WOLFSSL_DEVCRYPTO)
|
||||||
|
bench_size = sysconf(_SC_PAGESIZE);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* init keys */
|
/* init keys */
|
||||||
XMEMSET(bench_plain, 0, bench_size);
|
XMEMSET(bench_plain, 0, bench_size);
|
||||||
XMEMSET(tag, 0, sizeof(tag));
|
XMEMSET(tag, 0, sizeof(tag));
|
||||||
@ -4829,7 +4842,13 @@ void bench_gmac(int useDeviceID)
|
|||||||
#ifdef MULTI_VALUE_STATISTICS
|
#ifdef MULTI_VALUE_STATISTICS
|
||||||
bench_multi_value_stats(max, min, sum, squareSum, runs);
|
bench_multi_value_stats(max, min, sum, squareSum, runs);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(WOLFSSL_DEVCRYPTO)
|
||||||
|
if (ret != 0 && (bench_size > sysconf(_SC_PAGESIZE))) {
|
||||||
|
printf("authIn Buffer Size[%d] greater than System Page Size[%ld]\n",
|
||||||
|
bench_size, sysconf(_SC_PAGESIZE));
|
||||||
|
}
|
||||||
|
bench_size = BENCH_SIZE;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAVE_AESGCM */
|
#endif /* HAVE_AESGCM */
|
||||||
|
@ -324,6 +324,11 @@ static int wc_DevCrypto_AesGcm(Aes* aes, byte* out, byte* in, word32 sz,
|
|||||||
dir, (byte*)authIn, authInSz, authTag, authTagSz);
|
dir, (byte*)authIn, authInSz, authTag, authTagSz);
|
||||||
ret = ioctl(aes->ctx.cfd, CIOCAUTHCRYPT, &crt);
|
ret = ioctl(aes->ctx.cfd, CIOCAUTHCRYPT, &crt);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
#ifdef WOLFSSL_DEBUG
|
||||||
|
if (authInSz > sysconf(_SC_PAGESIZE)) {
|
||||||
|
WOLFSSL_MSG("authIn Buffer greater than System Page Size");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (dir == COP_DECRYPT) {
|
if (dir == COP_DECRYPT) {
|
||||||
return AES_GCM_AUTH_E;
|
return AES_GCM_AUTH_E;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user