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



Reply via email to