-
Notifications
You must be signed in to change notification settings - Fork 841
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
Port to RT1170 and expand CAAM driver #5938
Conversation
dd984b6
to
a584b07
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[check-source-text] [2 of 18] [8239ef801b]
weird control chars, hard tabs, CRs, trailing whitespace:
./wolfcrypt/src/random.c:3326:» defined(WOLFSSL_IMXRT1170_CAAM))
./wolfcrypt/src/pkcs7.c:7515:»»»»»»»»» pkcs7->devId, pkcs7->heap);
./wolfcrypt/src/pkcs7.c:7599:»»»»pkcs7->devId, pkcs7->heap);
./wolfcrypt/src/pkcs7.c:8381:»»»pkcs7->devId, pkcs7->heap);
./wolfcrypt/src/pkcs7.c:10901:»»»»»pkcs7->devId, pkcs7->heap);
./wolfcrypt/src/pkcs7.c:11315:»»»pkcs7->devId, pkcs7->heap);
./wolfcrypt/src/pkcs7.c:12199:»»»pkcs7->devId, pkcs7->heap);
./wolfcrypt/src/pkcs7.c:12648:»»»»»»»pkcs7->devId, pkcs7->heap);
./wolfcrypt/src/wc_port.c:436:» defined(WOLFSSL_SECO_CAAM) || defined(WOLFSSL_IMXRT1170_CAAM)
[...and more...]
warning, overlong lines added:
/IDE/MCUEXPRESSO/RT1170/PKCS7_example_cm7/source/PKCS7_example.c:354 ret = VerifyBundle(&rng, cert, certSz, key, keySz, bundle, bundleSz);
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:35 /* Note: If JR interface is cached and multiple jobs are being scheduled at the same time, */
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:36 /* it is recommended to move JR interfaces to non-cahed memory, rather than invalidate */
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:61 /* setup memory for job ring interfaces. Can be in system memory or CAAM's secure memory.
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:62 * Although this driver example only uses job ring interface 0, example setup for job ring interface 1 is also
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:123 static int wc_CAAM_CommonHash(caam_handle_t* hndl, caam_hash_ctx_t *ctx, const byte* in, int inSz, byte* digest,
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:135 tmpIn = (byte*)XMALLOC(inSz + 16, NULL, DYNAMIC_TYPE_TMP_BUFFER);
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:192 return wc_CAAM_CommonHash(&sha->hndl, &sha->ctx, in, inSz, digest, WC_SHA_DIGEST_SIZE, WC_HASH_TYPE_SHA);
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:198 int wc_CAAM_Sha224Hash(wc_Sha224* sha, const byte* in, word32 inSz, byte* digest)
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:200 return wc_CAAM_CommonHash(&sha->hndl, &sha->ctx, in, inSz, digest, WC_SHA224_DIGEST_SIZE, WC_HASH_TYPE_SHA224);
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:205 int wc_CAAM_Sha256Hash(wc_Sha256* sha, const byte* in, word32 inSz, byte* digest)
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:207 return wc_CAAM_CommonHash(&sha->hndl, &sha->ctx, in, inSz, digest, WC_SHA256_DIGEST_SIZE, WC_HASH_TYPE_SHA256);
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:212 int wc_CAAM_Sha384Hash(wc_Sha384* sha, const byte* in, word32 inSz, byte* digest)
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:214 return wc_CAAM_CommonHash(&sha->hndl, &sha->ctx, in, inSz, digest, WC_SHA384_DIGEST_SIZE, WC_HASH_TYPE_SHA384);
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:220 int wc_CAAM_Sha512Hash(wc_Sha512* sha, const byte* in, word32 inSz, byte* digest)
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:222 return wc_CAAM_CommonHash(&sha->hndl, &sha->ctx, in, inSz, digest, WC_SHA512_DIGEST_SIZE, WC_HASH_TYPE_SHA512);
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:236 status = CAAM_AES_DecryptCbc(CAAM, &hndl, (const uint8_t*)buf[2].TheAddress,
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:237 (uint8_t*)buf[3].TheAddress, buf[3].Length, (const uint8_t*)buf[4].TheAddress, (const uint8_t*)buf[0].TheAddress, buf[0].Length);
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:238 XMEMCPY((byte*)buf[4].TheAddress, (byte*)buf[2].TheAddress + buf[2].Length - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:241 status = CAAM_AES_EncryptCbc(CAAM, &hndl, (const uint8_t*)buf[2].TheAddress,
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:242 (uint8_t*)buf[3].TheAddress, buf[3].Length, (const uint8_t*)buf[4].TheAddress, (const uint8_t*)buf[0].TheAddress, buf[0].Length);
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:243 XMEMCPY((byte*)buf[4].TheAddress, (byte*)buf[3].TheAddress + buf[3].Length - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:265 tmpIn = (byte*)XMALLOC(buf[2].Length + 16, NULL, DYNAMIC_TYPE_TMP_BUFFER);
/wolfcrypt/src/port/caam/wolfcaam_fsl_nxp.c:275 tmpOut = (byte*)XMALLOC(buf[3].Length + 16, NULL, DYNAMIC_TYPE_TMP_BUFFER);
/wolfcrypt/src/port/caam/wolfcaam_init.c:28 * WOLFSSL_CAAM_DIRECT bypasses crypto callback shim layer meant for communicating with a driver, i.e. making use of NXP driver
/wolfcrypt/src/sha256.c:849 ret = wc_CAAM_HashInit(&sha256->hndl, &sha256->ctx, WC_HASH_TYPE_SHA256);
/wolfssl/internal.h:4222 word16 ownSuites:1; /* if suites are malloced in ssl object */
/wolfssl/internal.h:4870 byte cbioFlag; /* WOLFSSL_CBIO_RECV/SEND: CBIORecv/Send is set */
/wolfssl/internal.h:4900 void* hsKey; /* Handshake key (RsaKey or ecc_key) allocated from heap */
/wolfssl/wolfcrypt/port/caam/wolfcaam_hash.h:30 WOLFSSL_LOCAL int wc_CAAM_HashInit(caam_handle_t* hndl, caam_hash_ctx_t* ctx, int type);
check-source-text fail_AB
exiting with status 1
succeeded: check-file-modes
failed: check-source-text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the examples like IDE/MCUEXPRESSO/RT1170/CSR_example_cm7/source/CSR_example.c
be moved to a different repo like wolfssl-examples
?
That's what I get for developing in an IDE without setting up the formatting. Thanks David for the review. Yeah those examples could be moved and just the main wolfSSL library project left in the IDE/ directory along with the wolfcrypt_test. |
fc5c101
to
980a521
Compare
ok to test |
Can one of the admins verify this patch? |
6941409
to
b801a96
Compare
wolfssl/openssl/sha.h
Outdated
@@ -107,8 +111,20 @@ typedef WOLFSSL_SHA_CTX SHA_CTX; | |||
* to Sha224, is expected to also be 16 byte aligned addresses. */ | |||
typedef struct WOLFSSL_SHA224_CTX { | |||
/* big enough to hold wolfcrypt Sha224, but check on init */ | |||
#if defined(WOLFSSL_IMXRT1170_CAAM) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps you can hijack CTX_SHA2_HW_ADDER
instead to avoid duplication of this compatibility sizing? Comment applies to several places.
@@ -84,7 +85,7 @@ static int _InitSha(byte* ctx, word32 ctxSz, void* heap, int devId, | |||
arg[1] = ctxSz + WC_CAAM_CTXLEN; | |||
arg[2] = (word32)devId; | |||
|
|||
if ((ret = wc_caamAddAndWait(buf, arg, type)) != 0) { | |||
if ((ret = wc_caamAddAndWait(buf, 1, arg, type)) != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it would be helpful to add a macro/enum for the 1 and 2 values here?
static caam_job_ring_interface_t jr3; | ||
#endif | ||
|
||
wolfSSL_Mutex caamMutex; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be a static
? Same for the ones in qnx and seco?
byte *tmpIn = NULL; | ||
|
||
if ((wc_ptr_t)in % CAAM_BUFFER_ALIGN) { | ||
/* input not alligned */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few spelling alligned
-> aligned
.
@@ -0,0 +1,465 @@ | |||
--- fsl_caam-orig.c 2022-10-21 15:50:35.709951000 -0700 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you upstreaming any of these NXP patches?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
Contains MCUExpresso project for building on RT1170 and patches to expand the existing NXP CAAM driver for ECC and Blobs.