Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/dev/crypto auth error fix/adjustment for benchmark #8210

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion wolfcrypt/benchmark/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -1991,6 +1991,11 @@ static const char* bench_result_words2[][5] = {
#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 */
#ifdef BENCH_EMBEDDED
#ifndef BENCH_NTIMES
Expand Down Expand Up @@ -4798,6 +4803,14 @@ void bench_gmac(int useDeviceID)
const char* gmacStr = "GMAC Default";
#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 */
XMEMSET(bench_plain, 0, bench_size);
XMEMSET(tag, 0, sizeof(tag));
Expand Down Expand Up @@ -4828,7 +4841,13 @@ void bench_gmac(int useDeviceID)
#ifdef MULTI_VALUE_STATISTICS
bench_multi_value_stats(max, min, sum, squareSum, runs);
#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 */
Expand Down
5 changes: 5 additions & 0 deletions wolfcrypt/src/port/devcrypto/devcrypto_aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ static int wc_DevCrypto_AesGcm(Aes* aes, byte* out, byte* in, word32 sz,
dir, (byte*)authIn, authInSz, authTag, authTagSz);
ret = ioctl(aes->ctx.cfd, CIOCAUTHCRYPT, &crt);
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) {
return AES_GCM_AUTH_E;
}
Expand Down
Loading