-
Notifications
You must be signed in to change notification settings - Fork 7
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
Experimental support for pkcs#11 #5
base: master
Are you sure you want to change the base?
Conversation
Use nxp-cst-signer with pkcs11 tokens
can we provide also the way we can modify the cfg file once we select pkcs#11? |
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.
Problematic call to DEBUG macro
src/cst_signer.c
Outdated
fprintf(fp_csf_file, "\tSource = \"%s/crts/%s\"\n", g_cst_path, rvalue); | ||
|
||
} else { // use PKCS#11 | ||
DEBUG("PKCS11:\n"); |
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.
This line results in a syntax error because the VA_ARGS is empty, leading to an extra comma before the closing parenthesis.
I get following error trying to compile this PR:
| In file included from cst_signer.c:9:
| cst_signer.c: In function ‘create_csf_file_v3’:
| ../inc/cst_signer.h:67:107: error: expected expression before ‘)’ token
| 67 | printf("%s:%s:%d: " fmt, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); \
| | ^
| cst_signer.c:552:17: note: in expansion of macro ‘DEBUG’
| 552 | DEBUG("PKCS11:\n");
| | ^~~~~
Following change to the macro fixes my problem:
--- a/inc/cst_signer.h
+++ b/inc/cst_signer.h
@@ -64,7 +64,7 @@ const char* desc_opt[] =
#define DEBUG(fmt, ...) do { \
if (1 == g_debug) { \
- printf("%s:%s:%d: " fmt, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); \
+ printf("%s:%s:%d: " fmt, __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
} \
} while(0)
nxp-cst-signer/inc/cst_signer.h
Line 65 in c632233
#define DEBUG(fmt, ...) do { \ |
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.
Fixed it, I must have added between testing and comitting (I'm not an expert on git).
Also added some details on how to find the pkcs#11 url, and an example (that must be changed), on PKCS#11 URL in the cfg.
Added some more details on pkcs#11 and csf example file. Fixed a typo in the debug() statement.
Three changes - When adding pkcs#11, accidentially s swapped arguments, causing HAB4 images to not work - nxp-cst signer is sensitive if the cfg have empty "variable=\x0" on last line,as may cause segementation failure - nxp-cst-siger fails invokation of of cst, if the cfg file contains CRLF.
Use nxp-cst-signer with cst, and sign images using pkcs11 tokens