OSSL_PARAM: Correct the assumptions on the UTF8 string length
authorRichard Levitte <levitte@openssl.org>
Fri, 12 Feb 2021 19:30:40 +0000 (20:30 +0100)
committerRichard Levitte <levitte@openssl.org>
Thu, 18 Feb 2021 15:58:17 +0000 (16:58 +0100)
commit247a1786e25dbf77548168572e383d57aa743af4
tree3bec7d6f6f3f8e008af68b39e47146264d6f620e
parentc1be4d617cf9435e8326ebba643aa4d7cbcb3645
OSSL_PARAM: Correct the assumptions on the UTF8 string length

When the string "ABCDEFGH" is passed, what's considered its data, this?

    { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' }

or this?

    { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', '\0' }

If it's passed as a pass phrase, should the terminating NUL byte be
considered part of the pass phrase, or not?

Our treatment of OSSL_PARAMs with the data type OSSL_PARAM_UTF8_STRING
set the length of the string to include the terminating NUL byte,
which is quite confusing.  What should the recipient of such a string
believe?

Instead of perpetuating this confusion, we change the assumption to
set the OSSL_PARAM to the length of the string, not including the
terminating NUL byte, thereby giving it the same value as a strlen()
call would give.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14168)
crypto/params.c
doc/man3/OSSL_PARAM.pod
doc/man3/OSSL_PARAM_int.pod
doc/man7/EVP_KDF-SSHKDF.pod
test/params_api_test.c
test/params_test.c