Path: blob/main/crypto/openssl/doc/designs/fast-param-find.md
34869 views
Proposal for OSSL_PARAM futures
Format:
THe top level attributes are:
"name" is the name the functions will derive from e.g. "kdf_scrypt" to this will be appended _[gs]et[_ctx]_params
"functions" is the functions to generate. By default both setters and getters but either can be omitted.
"prologue" defines some introductory code emitted in the generated functions. Function arguments are:
void *vctx, OSSL_PARAM params[]
and this can be used to specialise the void pointer or declare locals."epilogue" defines some post decode code emitted in the generated function
"params" defines the parameters both gettable and settable
Within the "params" the fields specify each parameter by label.
Each parameter is then specialised with attributes:
"type" is the OSSL_PARAM type
"ctype" is the underlying C type (e.g. for an integer parameter size_t could be the C type)
"access" is readwrite, readonly or writeonly. This determines if the parameter is a settable, gettable or both
"field" is an accessor to the field itself
"sanitycheck" is a validation check for the parameter. If present, code will be generated
if (!(sanitycheck)) return 0;
The local variablevar
will contain the C value if specified."setaction" is C code to execute when the parameter is being set. It will define an OSSL_PARAM pointer p to set.
"code" set to "no" skips code generation for this parameter, it defaults to "yes" which generates handlers. This is useful when a parameter is duplicated with differenting types (e.g. utf8 string and integer).
"published" set to "yes" includes the parameter in the gettable/settable lists. Set to "no" and it isn't included (but will still be processed). It defaults to "yes".
Flags include:
nostatic: do not make the function static
nocode: do not generate code for this parameter
This allows, e.g., two different types for a parameter (int & string)
unpublished: do not generate this parameter in the gettable/settable list
"engine" is the only one like this
readonly: create a getter but not a setter
writeonly: create a setting but not a getter
The idea is that the gettable and get functions will be simultaneously generated along with fast decoder to look up parameter names quickly.
The getter and setter functions will be pre-populated with some local variable:
A worked example for scrypt:
Would generate something along the lines of: