Skip to content

Param helper functions, continued#8451

Closed
levitte wants to merge 13 commits intoopenssl:masterfrom
levitte:paulidale-param-string
Closed

Param helper functions, continued#8451
levitte wants to merge 13 commits intoopenssl:masterfrom
levitte:paulidale-param-string

Conversation

@levitte
Copy link
Member

@levitte levitte commented Mar 11, 2019

This takes over #8400 for final adjustments, on @paulidale's request.

@levitte levitte added the branch: master Applies to master branch label Mar 11, 2019
@levitte levitte requested a review from mattcaswell March 11, 2019 09:19
@paulidale
Copy link
Contributor

Thanks.

@levitte levitte force-pushed the paulidale-param-string branch 2 times, most recently from 23d96fc to f34bcf6 Compare March 11, 2019 20:19
@levitte
Copy link
Member Author

levitte commented Mar 11, 2019

Please take note of 3690d01f86577d9438a333d8d459daa9dfa825f6, which renames buffer and buffer_size to data and data_size. I am thinking that names with buffer in them may give the wrong idea that they are meant to point at intermediary data, which is generally not the case (MPIs being the obvious exception)

paulidale and others added 10 commits March 12, 2019 15:10
Provide a number of functions to allow parameters to be set and retrieved
in a type safe manner.  Functions are provided for many integral types
plus double, BIGNUM, UTF8 strings and OCTET strings.

All of the integer functions will widen the parameter data as required.  This
permits a degree of malleability in the parameter definition.  For example a
type can be changed from a thirty two bit integer to a sixty four bit one
without changing application code.  Only four and eight byte integral sizes
are supported here.

A pair of real functions, a get and a set, that will accept all real and
integer types and automaticly convert to/from double as required.  There could
be some loss of precision when converting wide integral types to reals and
reals to any integer type.

A pair of functions is available for BIGNUMs.  These accept any sized unsigned
integer input and convert to/from a BIGNUM.

For each OCTET and UTF8 strings, four functions are defined.  This provide get
and set functionality for string and for pointers to strings.  The latter
avoiding copies but have other inherent risks.

Finally, some utility macros and functions are defined to allow OSSL_PARAM
definition arrays to be more simplify specified.  There are two macro and one
function for most types.  The exception being BIGNUM, for which there is one
macro and one function.
demacro the get/set/construct for the standard integral types
OSSL_PARAM.doc only describes the structure, not the added API, so
when a description says "must", that should remain.
doc/man3/OSSL_PARAM_TYPE.pod was marked as generic, but the majority
of it isn't, so remove that comment and adjust the page.

To make this possible, generic names were entered in util/private.num,
labeled "generic".
The return_size setting wasn't quite right
The OSSL_PARAM attribute names |buffer| and |buffer_size| may lead to
confusion, as they may make some think that the memory pointed at is
an intermediate memory are.  This is not generally the case, so we
rename |buffer| and |buffer_size| to |data| and |data_size|
@levitte levitte force-pushed the paulidale-param-string branch from c0af87d to 5e5a1c5 Compare March 12, 2019 14:12
This restricts the _get_ and _set_ functions to only handle their own
types.  This includes match of integer signedness, and doubles.

API test is adapted to match.
@levitte
Copy link
Member Author

levitte commented Mar 12, 2019

Last commit restricts the diverse _get_ and _set_ functions to only handle their own type. Widening still happens, but not conversion between different types, including int<->uint.

levitte added 2 commits March 12, 2019 17:10
Cleanup, making the coding patterns for _get_ and _set_ functions a
bit more uniform
@mattcaswell mattcaswell added the approval: done This pull request has the required number of approvals label Mar 12, 2019
@levitte
Copy link
Member Author

levitte commented Mar 12, 2019

Merged.

Thank you everyone!

e2146e1 Change OSSL_PARAM_UTF8_STRING_PTR to OSSL_PARAM_UTF8_PTR
eabf91c generated files
7ffbd7c OSSL_PARAM helper functions.
8c4412e Rename 'buffer' to 'data' in OSSL_PARAM

@levitte levitte closed this Mar 12, 2019
levitte added a commit that referenced this pull request Mar 12, 2019
The OSSL_PARAM attribute names |buffer| and |buffer_size| may lead to
confusion, as they may make some think that the memory pointed at is
an intermediate memory are.  This is not generally the case, so we
rename |buffer| and |buffer_size| to |data| and |data_size|

Reviewed-by: Matt Caswell <[email protected]>
(Merged from #8451)
levitte pushed a commit that referenced this pull request Mar 12, 2019
Provide a number of functions to allow parameters to be set and
retrieved in a type safe manner.  Functions are provided for many
integral types plus double, BIGNUM, UTF8 strings and OCTET strings.

All of the integer functions will widen the parameter data as
required.  This permits a degree of malleability in the parameter
definition.  For example a type can be changed from a thirty two bit
integer to a sixty four bit one without changing application code.
Only four and eight byte integral sizes are supported here.

A pair of real functions are available for doubles.

A pair of functions is available for BIGNUMs.  These accept any sized
unsigned integer input and convert to/from a BIGNUM.

For each OCTET and UTF8 strings, four functions are defined.  This
provide get and set functionality for string and for pointers to
strings.  The latter avoiding copies but have other inherent risks.

Finally, some utility macros and functions are defined to allow
OSSL_PARAM definition arrays to be specified in a simple manner.
There are two macro and one function for most types.  The exception
being BIGNUM, for which there is one macro and one function.

Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
(Merged from #8451)
levitte pushed a commit that referenced this pull request Mar 12, 2019
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
(Merged from #8451)
levitte added a commit that referenced this pull request Mar 12, 2019
In unrelated code

Reviewed-by: Matt Caswell <[email protected]>
(Merged from #8451)
@levitte levitte mentioned this pull request Mar 12, 2019
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: done This pull request has the required number of approvals branch: master Applies to master branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants