OSSL_PARAM thought
Richard Levitte
levitte at openssl.org
Tue Jul 2 13:36:14 UTC 2019
This was actually discussed in the design phase, and I think we
concluded that all arrays of this sort should be terminated rather
than counted. I frankly cannot remember what the reasoning was behind
this, and suspect it came down to personal taste.
However, whatever way we choose should be a consistent pattern. The
worst we can do is to have some arrays counted while having others
terminated with a special value. That's a recipe for confusion.
(I'll note, though, that some arrays must be counted because there is
no special terminating value to be had. As far as I can recall,
though, this is uniquely for arrays of bytes)
Cheers,
Richard
On Mon, 24 Jun 2019 03:04:21 +0200,
Dr Paul Dale wrote:
>
> [1 <text/plain; utf-8 (quoted-printable)>]
> [2 <text/html; utf-8 (quoted-printable)>]
> We’re only starting out, so there isn’t any issue yet. I am wondering if instead of terminating
> out OSSL_PARAM arrays with an empty element, would it make sense to pass a size and the array?
>
> I.e. changing this code sequence (from crypto/evp/digest.c):
>
> params[i++] = OSSL_PARAM_construct_size_t(OSSL_DIGEST_PARAM_XOFLEN,
> &size, NULL);
> params[i++] = OSSL_PARAM_construct_end();
> EVP_MD_CTX_set_params(ctx, params);
>
> into:
>
> params[i++] = OSSL_PARAM_construct_size_t(OSSL_DIGEST_PARAM_XOFLEN,
> &size, NULL);
> EVP_MD_CTX_set_params(ctx, i, params);
>
> For fixed arrays OSSL_NELEM would be used instead of the counter variable.
>
> There are downsides with both approaches of course and neither jumps out as being obviously
> superior.
>
> To me, at least, it looks like we’re going to have a lot of END’s throughout the codebase. Saving
> one line many times seems like a win.
>
> Pauli
> --
> Dr Paul Dale | Cryptographer | Network Security & Encryption
> Phone +61 7 3031 7217
> Oracle Australia
>
>
--
Richard Levitte levitte at openssl.org
OpenSSL Project http://www.openssl.org/~levitte/
More information about the openssl-project
mailing list