Wan-Teh Chang wrote, On 2008-07-08 16:35:

> As Nelson said, if Firefox/NSS passes any of these NSS vendor-specific
> constants to your PKCS #11 DLL, you should return the appropriate error
> code (which I think is CKR_ATTRIBUTE_TYPE_INVALID or
> CKR_ATTRIBUTE_VALUE_INVALID, see page 64 and page 137 of
> PKCS #11 v2.20).  Your PKCS #11 DLL doesn't need to support these
> vendor-specific constants.

Note that, in PKCS#11, a returned non-zero CKR error code does not always
mean that the function failed.  For some functions in the API, some non-zero
error code return values do not imply a total failure of the
function.  The function goes on and finishes up successfully, even though
it returns a non-zero error code return value.

An example of this is C_GetAttributeValue (pages 133-135 in my copy of
PKCS#11 v2.20).  While processing the array of attribute templates, if
a template requests an attribute that is invalid for the object, (that is,
the object does not possess an attribute of the requested type) then the
function must modify the ulValueLen field in that template to hold the
value -1, and return CKR_ATTRIBUTE_TYPE_INVALID.  That will be the case
for any unrecognized attribute types (whether vendor defined or not).

But even when that happens, the values of any of the other attributes
in the template array that are valid for the object must be handled as if
the function returned CKR_OK.  Every attribute in the template array must
be given the correct answer (which may be to set the length to -1), even
if the function returns CKR_ATTRIBUTE_TYPE_INVALID.

The spec says:

> Note that the error codes CKR_ATTRIBUTE_SENSITIVE, 
> CKR_ATTRIBUTE_TYPE_INVALID, and CKR_BUFFER_TOO_SMALL do not denote true 
> errors for C_GetAttributeValue. If a call to C_GetAttributeValue returns 
> any of these three values, then the call must nonetheless have processed
> every attribute in the template supplied to C_GetAttributeValue. Each
> attribute in the template whose value can be returned by the call to
> C_GetAttributeValue will be returned by the call to C_GetAttributeValue.

That's why I said that, for each defined API function, an unrecognized
attribute value must be handled as specified for that function.
_______________________________________________
dev-tech-crypto mailing list
dev-tech-crypto@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-crypto

Reply via email to