arpa2 / keehive

Remote PKCS #11 Client Library and Hosting Dæmon (comms uses ASN.1 spec over Kerberos-protected links)
Other
0 stars 1 forks source link

Softhsm2 test suite calls some functions with NULL argument, ans1 spec doesn't support this #11

Open gijzelaerr opened 6 years ago

gijzelaerr commented 6 years ago

C_DigestInit() https://github.com/arpa2/keehive/blob/master/src/static/test/softhsm2/DigestTests.cpp#L60

C_DigestUpdate() https://github.com/arpa2/keehive/blob/master/src/static/test/softhsm2/DigestTests.cpp#L162

C_DigestFinal() https://github.com/arpa2/keehive/blob/master/src/static/test/softhsm2/DigestTests.cpp#L241

C_GetSlotList() https://github.com/arpa2/keehive/blob/master/src/static/test/softhsm2/InfoTests.cpp#L91

vanrein commented 6 years ago

These four (cases? examples?) all point to situations where an anticipated pointer is absent without it having any meaning in terms of PKCS#11, so basically violating the operation preconditions. Excellent testing, and the expected return is CKR_ARGUMENTS_BAD. Any place where preconditions are violated, CKR_ARGUMENTS_BAD is a good return value to use, including in these four cases.

The code generator should therefore be adapted to respond with an error return in the cases where it finds it is provided with faulty arguments.

gijzelaerr commented 6 years ago

This is hard to automate in Some cases (as defined in the spec) having a NULL for an argument is valid. Maybe it is just easier to add some checks to api.c manually...

gijzelaerr commented 6 years ago

i've added some manual checks in this branch https://github.com/arpa2/keehive/tree/manual_check