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

Cumbersome cryptographic operations for speed tests #159

Open
baycan opened this issue Jun 9, 2022 · 0 comments
Open

Cumbersome cryptographic operations for speed tests #159

baycan opened this issue Jun 9, 2022 · 0 comments

Comments

@baycan
Copy link

baycan commented Jun 9, 2022

Hi,
Recently I have used this module to able to write a speed test application for a hsm device. Later on, I recognized that for some cryptographic operations api uses a method (calling with NULL ) to learn result size and then apply real cryptographic operation. Such as:
CK_RV Decrypt(struct ctx * c, CK_SESSION_HANDLE session, CK_BYTE_PTR cipher, CK_ULONG clen, CK_BYTE_PTR * plain, CK_ULONG_PTR plainlen) { **CK_RV e = c->sym->C_Decrypt(session, cipher, clen, NULL, plainlen);** if (e != CKR_OK) { return e; } *plain = calloc(*plainlen, sizeof(CK_BYTE)); if (*plain == NULL) { return CKR_HOST_MEMORY; } **e = c->sym->C_Decrypt(session, cipher, clen, *plain, plainlen);** return e; }
As you can see, here api calls C_Decrypt function 2 times. First one used to able to learn result size, second one used to apply cryptographic operations. Since we know the mechanism that we are using actually we know the result size. So in this case calling 2 times C_Decrypt function is cumbersome especially if you are calculating speeds for specific mechanism.
Nice to have that if we can give size from outsize and api does not need to call 2 times.

Best regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant