-
Notifications
You must be signed in to change notification settings - Fork 34
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
Finished Digest and mechanisms demo #11
Conversation
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.
👍
* demonstrates how to generate random numbers using PKCS #11. | ||
*/ | ||
extern void vPKCS11ManagementDemo( void ); | ||
extern void vPKCS11ManagementAndRNGDemo( void ); |
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.
For line 55, 61, 66, I understand that you are trying to not put none APIs into header files.
Just me... I would still put function prototypes into a header file, though it'll only be included where the functions are implemented and where the functions are called. It makes the scope clearer and safer. (Header file in examples/
folder in this case.)
The style here used is not banned by any rule as far as I know, but I agree with the first post https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152215 "the compiler will not be able to detect the inconsistency between the two translation units".
#define configPKCS11_MECHANISMS_AND_DIGESTS_DEMO 1 | ||
|
||
/* | ||
* @brief set this macro to "1" in order to run the PKCS #11 object demo. |
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.
The comment provided for configPKCS11_MECHANISMS_AND_DIGESTS_DEMO
and configPKCS11_OBJECT_DEMO
are the same. Copy-paste issue?
|
||
/* | ||
* @brief set this macro to "1" in order to run the PKCS #11 management demo. | ||
* @brief set this macro to "1" in order to run the PKCS #11 management and | ||
* random demo. |
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.
"random" --> "random number generator" maybe. I thought it runs any demo at first glance.. 😅
CK_RV xResult = CKR_OK; | ||
|
||
CK_FUNCTION_LIST_PTR pxFunctionList = NULL; | ||
CK_C_INITIALIZE_ARGS xInitArgs = { 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.
I'm not sure whether this library/demo is targeting at ANSI C. May get a warning with "{0}"
CK_ULONG ulDataLength ) | ||
{ | ||
#define BYTES_TO_DISPLAY_PER_ROW 16 | ||
char pcByteRow[ 1 + ( BYTES_TO_DISPLAY_PER_ROW * 2 ) + ( BYTES_TO_DISPLAY_PER_ROW / 2 ) ]; |
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.
Curious about the "math", a comment would help.
configPRINTF( ( "%s, %d bytes:\r\n", pcDescription, ulDataLength ) ); | ||
|
||
/* Iterate over the bytes of the encoded public key. */ | ||
for( ; ulIndex < ulDataLength; ulIndex++ ) |
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.
I would leave ulIndex = 0
in since another developer may come in and change the value in between this line and initialization. (I know... :( )
char pcByteRow[ 1 + ( BYTES_TO_DISPLAY_PER_ROW * 2 ) + ( BYTES_TO_DISPLAY_PER_ROW / 2 ) ]; | ||
char * pcNextChar = pcByteRow; | ||
uint32_t ulIndex = 0; | ||
uint8_t ucByteValue = 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.
CK_BYTE
instead of uint8_t
maybe?
CK_FUNCTION_LIST_PTR pxFunctionList; | ||
CK_KEY_TYPE xKeyType = 0; | ||
CK_ATTRIBUTE xTemplate = { 0 }; | ||
uint8_t pucEcP256AsnAndOid[] = |
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.
Would appreciate some comment on the key header format. If there's a quick link to wiki, that'll help.
* "management_and_rng.c" file for the demo code explaining this section | ||
* of cryptoki. | ||
*/ | ||
extern void prvStart( CK_SESSION_HANDLE * pxSession, |
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.
Same comment for the extern
here.
The question to "put function prototype in headers" may be how to distinguish "private" header and "shared" header if both live in the same folder. Could play with include path...
* Submoduled PKCS #11 repo. * Fix build.
No description provided.