chaps: Return CKR_BUFFER_TOO_SMALL if a buffer was provided by the user

As per PKCS#11 s11.2:
 - if the output buffer is NULL, the return code should be CKR_OK
 - if the output buffer is present but too small, the return code should be
   CKR_BUFFER_TOO_SMALL

BUG=None
TEST=Chaps unit tests (with ASAN) plus PKCS11 tests

Change-Id: Ia5fe6101df5ca7861950600119f5ef1f5f66f509
Reviewed-on: https://chromium-review.googlesource.com/221935
Reviewed-by: Darren Krahn <dkrahn@chromium.org>
Commit-Queue: David Drysdale <drysdale@google.com>
Tested-by: David Drysdale <drysdale@google.com>
2 files changed