Conversation
slontis
left a comment
There was a problem hiding this comment.
Looks a lot cleaner than the first attempt using memcpy.
Are Strings and byte arrays still TODO?
|
Yes, strings and octets are coming in another PR. |
|
We should also address the question as to which types exactly we want to include. I've only got the thirty two and sixty four bit ones here plus size_t. Do we need sixteen bit integers or floats? |
A point: this PR doesn't have to be feature complete. If it turns out later that we want those, it would be fairly easy to add. |
|
WIthout narrowing, adding them after 3.0 could be problematic. |
|
I'm looking at all this, and am thinking of a use case that I think will be fairly common... I'll write it raw form for now (macros lacking). So the case here is that an application wants to use some provider that's unknown to us, offering the asymmetric algorithm "blargh", and wants to find out the public parameters for some key (i.e. the numbers, like RSA's n and e), using some EVP_PKEY function that doesn't exist yet (totally top of my mind). The type and size of these parameters are documented with the provider, so the application author know what they're dealing with. int32_t blargh_f = 0;
double blargh_g = 0.0;
unsigned char blargh_p1[4096 / 8];
unsigned char blargh_p2[4096 / 8];
const OSSL_PARAM params[] = {
/* |f| is documented to be a 32-bit signed integer. No need for a return size */
{ "f", OSSL_PARAM_INTEGER, &blargh_f, sizeof(blargh_f), NULL },
/* |g| is documented to be a double. No need for a return size */
{ "g", OSSL_PARAM_REAL, &blargh_g, sizeof(blargh_g), NULL),
/* |p1| and |p2| are documented to be arbitrarily large unsigned integers, maximum 4096 bits */
{ "p1", OSSL_PARAM_UNSIGNED_INTEGER, &blargh_p1, sizeof(blargh_p1), &blargh_p1_l },
{ "p2", OSSL_PARAM_UNSIGNED_INTEGER, &blargh_p2, sizeof(blargh_p2), &blargh_p2_l },
{ 0 }
};
if (!EVP_PKEY_get_public_params(pkey, params))
goto err;
/*
* do whatever with the parameters
* among others, blargh_p1 and blargh_p2 should be imported into whatever MP type
* the application writer prefers
*/I have a hard time seeing how this is supported in this PR, which seems to be preoccupied with more dynamic aspects. Comments? |
|
I'm unsure what you're getting at. The macros will handle the first two entries fine. The final two aren't supported. At least at the moment. |
Cool. I was unsure how to understand this PR, so thanks for confirming.
(emphasis mine) Ok, I'll try to be patient 😉 |
|
There is a fair bit more to do. Strings and octets need supporting functions and (maybe) macros. I'd like the _PTR variations to be hidden from users. BIGNUMs also need some hiding and they'll need the length passed back (which are the missing cases above). I also need to do some BIGNUM test cases and confirm that the integer functions are adequately covered by the existing tests. I'm running out of time... |
I don't think that's a good idea. There are some very crucial differences between the It's possible that the |
|
Let's see if I can come up with a nice _PTR neutral flavour. I'm not sure it is possible but I'd like to at least try. |
Trying is good... I have my doubts, but please never let that stop you from trying. Worst case, we might both be pleasantly surprised 😉 |
levitte
left a comment
There was a problem hiding this comment.
Deal with this after sleep, yeah?
|
It is unfortunate that so much effort has been spent on re-doing this since #8377 starts from a cleaner space. |
|
The bulk of the changes took about half an hour :) That's roughly the time between my comment about prototyping a middle ground approach and the first push. |
9ef8687 to
bfb9499
Compare
richsalz
left a comment
There was a problem hiding this comment.
For the BN test. Can you show doing this with a list of PARAMS where the BIGNUM is the second or third? And show a set and a get. I.e., how it would be used in practice.
|
I've pulled OSSL_PARAM_locate out as a separate API and not called it from the get/set functions. |
|
The BIGNUM test is failing. I'll fix. |
0c429e6 to
4539ebc
Compare
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 float and double. All of the integer functions will widen and narrow 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. The fast path case where the types match is dealt with directly, so it is only when the types don't match that there is a performance impact. The two pairs of real functions accept all real and integer types and automaticly convert as required. There could be some loss of precision when converting wide integral types to reals, but the magnitude will remain correct. Unlike the integer functions which accept any width input, the real functions require standard integer widths. A pair of functions is available for BIGNUMs. These accept any unsigned integer input and convert to/from a BIGNUM. Finally, some utility macros are defined to allow OSSL_PARAM definition arrays to be more simplify specified. There is one macro for each native integer type and both floating point types.
|
Closing in favour if #8400 which includes a pile more functionality. |
A leaner version of the param api.
This supports fewer types and only supports widening of types (no narrowing).
Widening is done using cases rather than memcpy.
refer to #8320 and #8377