summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2019-06-24 06:43:55 +0200
committerPauli <paul.dale@oracle.com>2019-06-24 06:43:55 +0200
commit4e7991b497b65145ec5d570485020e1658208866 (patch)
tree34e384b7aa820b0b7ccefddee9a0fbd86c8850fb
parentAdd documentation for CRYPTO_memcmp. (diff)
downloadopenssl-4e7991b497b65145ec5d570485020e1658208866.tar.xz
openssl-4e7991b497b65145ec5d570485020e1658208866.zip
Change OSSL_PARAM return size to not be a pointer.
Instead of referencing the return size from the OSSL_PARAM structure, make the size a field within the structure. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9135)
-rw-r--r--crypto/evp/digest.c12
-rw-r--r--crypto/params.c207
-rw-r--r--crypto/provider.c3
-rw-r--r--crypto/provider_core.c7
-rw-r--r--doc/internal/man3/ossl_provider_new.pod3
-rw-r--r--doc/man3/EVP_DigestInit.pod2
-rw-r--r--doc/man3/OSSL_PARAM.pod33
-rw-r--r--doc/man3/OSSL_PARAM_int.pod101
-rw-r--r--doc/man3/OSSL_PROVIDER.pod4
-rw-r--r--include/internal/provider.h3
-rw-r--r--include/openssl/core.h2
-rw-r--r--include/openssl/core_numbers.h10
-rw-r--r--include/openssl/evp.h2
-rw-r--r--include/openssl/params.h153
-rw-r--r--include/openssl/provider.h3
-rw-r--r--providers/common/ciphers/aes.c10
-rw-r--r--providers/common/digests/sha2_prov.c2
-rw-r--r--providers/common/digests/sha3_prov.c2
-rw-r--r--providers/default/defltprov.c5
-rw-r--r--providers/default/digests/md5_sha1_prov.c2
-rw-r--r--providers/fips/fipsprov.c5
-rw-r--r--providers/legacy/digests/mdc2_prov.c2
-rw-r--r--providers/legacy/legacyprov.c5
-rw-r--r--ssl/s3_enc.c3
-rw-r--r--test/mdc2test.c2
-rw-r--r--test/p_test.c16
-rw-r--r--test/params_api_test.c110
-rw-r--r--test/params_conversion_test.c4
-rw-r--r--test/params_test.c120
-rw-r--r--test/provider_internal_test.c5
-rw-r--r--test/provider_test.c5
-rw-r--r--util/libcrypto.num1
-rw-r--r--util/private.num13
33 files changed, 359 insertions, 498 deletions
diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c
index 604bf7fea0..9f19744606 100644
--- a/crypto/evp/digest.c
+++ b/crypto/evp/digest.c
@@ -365,8 +365,7 @@ int EVP_DigestFinalXOF(EVP_MD_CTX *ctx, unsigned char *md, size_t size)
return 0;
}
- params[i++] = OSSL_PARAM_construct_size_t(OSSL_DIGEST_PARAM_XOFLEN,
- &size, NULL);
+ params[i++] = OSSL_PARAM_construct_size_t(OSSL_DIGEST_PARAM_XOFLEN, &size);
params[i++] = OSSL_PARAM_construct_end();
if (EVP_MD_CTX_set_params(ctx, params) > 0)
@@ -532,7 +531,7 @@ int EVP_MD_CTX_set_params(EVP_MD_CTX *ctx, const OSSL_PARAM params[])
return 0;
}
-int EVP_MD_CTX_get_params(EVP_MD_CTX *ctx, const OSSL_PARAM params[])
+int EVP_MD_CTX_get_params(EVP_MD_CTX *ctx, OSSL_PARAM params[])
{
if (ctx->digest != NULL && ctx->digest->get_params != NULL)
return ctx->digest->get_params(ctx->provctx, params);
@@ -545,7 +544,7 @@ int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2)
if (ctx->digest != NULL) {
if (ctx->digest->prov != NULL) {
OSSL_PARAM params[2];
- size_t i, sz, n = 0;
+ size_t i, n = 0;
switch (cmd) {
case EVP_MD_CTRL_XOF_LEN:
@@ -553,8 +552,7 @@ int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2)
break;
i = (size_t)p1;
params[n++] =
- OSSL_PARAM_construct_size_t(OSSL_DIGEST_PARAM_XOFLEN, &i,
- &sz);
+ OSSL_PARAM_construct_size_t(OSSL_DIGEST_PARAM_XOFLEN, &i);
params[n++] = OSSL_PARAM_construct_end();
return ctx->digest->set_params(ctx->provctx, params);
case EVP_MD_CTRL_MICALG:
@@ -562,7 +560,7 @@ int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2)
break;
params[n++] =
OSSL_PARAM_construct_utf8_string(OSSL_DIGEST_PARAM_MICALG,
- p2, p1 ? p1 : 9999, &sz);
+ p2, p1 ? p1 : 9999);
params[n++] = OSSL_PARAM_construct_end();
return ctx->digest->get_params(ctx->provctx, params);
}
diff --git a/crypto/params.c b/crypto/params.c
index 183884fa79..0c9e6f3ef7 100644
--- a/crypto/params.c
+++ b/crypto/params.c
@@ -12,11 +12,7 @@
#include <openssl/params.h>
#include "internal/thread_once.h"
-#define SET_RETURN_SIZE(p, sz) \
- if ((p)->return_size != NULL) \
- *(p)->return_size = (sz)
-
-const OSSL_PARAM *OSSL_PARAM_locate(const OSSL_PARAM *p, const char *key)
+OSSL_PARAM *OSSL_PARAM_locate(OSSL_PARAM *p, const char *key)
{
if (p != NULL && key != NULL)
for (; p->key != NULL; p++)
@@ -25,9 +21,13 @@ const OSSL_PARAM *OSSL_PARAM_locate(const OSSL_PARAM *p, const char *key)
return NULL;
}
+const OSSL_PARAM *OSSL_PARAM_locate_const(const OSSL_PARAM *p, const char *key)
+{
+ return OSSL_PARAM_locate((OSSL_PARAM *)p, key);
+}
+
static OSSL_PARAM ossl_param_construct(const char *key, unsigned int data_type,
- void *data, size_t data_size,
- size_t *return_size)
+ void *data, size_t data_size)
{
OSSL_PARAM res;
@@ -35,7 +35,7 @@ static OSSL_PARAM ossl_param_construct(const char *key, unsigned int data_type,
res.data_type = data_type;
res.data = data;
res.data_size = data_size;
- res.return_size = return_size;
+ res.return_size = 0;
return res;
}
@@ -50,7 +50,7 @@ int OSSL_PARAM_get_int(const OSSL_PARAM *p, int *val)
return 0;
}
-int OSSL_PARAM_set_int(const OSSL_PARAM *p, int val)
+int OSSL_PARAM_set_int(OSSL_PARAM *p, int val)
{
switch (sizeof(int)) {
case sizeof(int32_t):
@@ -61,10 +61,9 @@ int OSSL_PARAM_set_int(const OSSL_PARAM *p, int val)
return 0;
}
-OSSL_PARAM OSSL_PARAM_construct_int(const char *key, int *buf, size_t *rsize)
+OSSL_PARAM OSSL_PARAM_construct_int(const char *key, int *buf)
{
- return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(int),
- rsize);
+ return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(int));
}
int OSSL_PARAM_get_uint(const OSSL_PARAM *p, unsigned int *val)
@@ -78,7 +77,7 @@ int OSSL_PARAM_get_uint(const OSSL_PARAM *p, unsigned int *val)
return 0;
}
-int OSSL_PARAM_set_uint(const OSSL_PARAM *p, unsigned int val)
+int OSSL_PARAM_set_uint(OSSL_PARAM *p, unsigned int val)
{
switch (sizeof(unsigned int)) {
case sizeof(uint32_t):
@@ -89,11 +88,10 @@ int OSSL_PARAM_set_uint(const OSSL_PARAM *p, unsigned int val)
return 0;
}
-OSSL_PARAM OSSL_PARAM_construct_uint(const char *key, unsigned int *buf,
- size_t *rsize)
+OSSL_PARAM OSSL_PARAM_construct_uint(const char *key, unsigned int *buf)
{
return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf,
- sizeof(unsigned int), rsize);
+ sizeof(unsigned int));
}
int OSSL_PARAM_get_long(const OSSL_PARAM *p, long int *val)
@@ -107,7 +105,7 @@ int OSSL_PARAM_get_long(const OSSL_PARAM *p, long int *val)
return 0;
}
-int OSSL_PARAM_set_long(const OSSL_PARAM *p, long int val)
+int OSSL_PARAM_set_long(OSSL_PARAM *p, long int val)
{
switch (sizeof(long int)) {
case sizeof(int32_t):
@@ -118,11 +116,9 @@ int OSSL_PARAM_set_long(const OSSL_PARAM *p, long int val)
return 0;
}
-OSSL_PARAM OSSL_PARAM_construct_long(const char *key, long int *buf,
- size_t *rsize)
+OSSL_PARAM OSSL_PARAM_construct_long(const char *key, long int *buf)
{
- return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(long int),
- rsize);
+ return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(long int));
}
int OSSL_PARAM_get_ulong(const OSSL_PARAM *p, unsigned long int *val)
@@ -136,7 +132,7 @@ int OSSL_PARAM_get_ulong(const OSSL_PARAM *p, unsigned long int *val)
return 0;
}
-int OSSL_PARAM_set_ulong(const OSSL_PARAM *p, unsigned long int val)
+int OSSL_PARAM_set_ulong(OSSL_PARAM *p, unsigned long int val)
{
switch (sizeof(unsigned long int)) {
case sizeof(uint32_t):
@@ -147,11 +143,10 @@ int OSSL_PARAM_set_ulong(const OSSL_PARAM *p, unsigned long int val)
return 0;
}
-OSSL_PARAM OSSL_PARAM_construct_ulong(const char *key, unsigned long int *buf,
- size_t *rsize)
+OSSL_PARAM OSSL_PARAM_construct_ulong(const char *key, unsigned long int *buf)
{
return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf,
- sizeof(unsigned long int), rsize);
+ sizeof(unsigned long int));
}
int OSSL_PARAM_get_int32(const OSSL_PARAM *p, int32_t *val)
@@ -208,35 +203,35 @@ int OSSL_PARAM_get_int32(const OSSL_PARAM *p, int32_t *val)
return 0;
}
-int OSSL_PARAM_set_int32(const OSSL_PARAM *p, int32_t val)
+int OSSL_PARAM_set_int32(OSSL_PARAM *p, int32_t val)
{
if (p == NULL)
return 0;
- SET_RETURN_SIZE(p, 0);
+ p->return_size = 0;
if (p->data_type == OSSL_PARAM_INTEGER) {
- SET_RETURN_SIZE(p, sizeof(int32_t)); /* Minimum expected size */
+ p->return_size = sizeof(int32_t); /* Minimum expected size */
switch (p->data_size) {
case sizeof(int32_t):
*(int32_t *)p->data = val;
return 1;
case sizeof(int64_t):
- SET_RETURN_SIZE(p, sizeof(int64_t));
+ p->return_size = sizeof(int64_t);
*(int64_t *)p->data = (int64_t)val;
return 1;
}
} else if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER && val >= 0) {
- SET_RETURN_SIZE(p, sizeof(uint32_t)); /* Minimum expected size */
+ p->return_size = sizeof(uint32_t); /* Minimum expected size */
switch (p->data_size) {
case sizeof(uint32_t):
*(uint32_t *)p->data = (uint32_t)val;
return 1;
case sizeof(uint64_t):
- SET_RETURN_SIZE(p, sizeof(uint64_t));
+ p->return_size = sizeof(uint64_t);
*(uint64_t *)p->data = (uint64_t)val;
return 1;
}
} else if (p->data_type == OSSL_PARAM_REAL) {
- SET_RETURN_SIZE(p, sizeof(double));
+ p->return_size = sizeof(double);
switch (p->data_size) {
case sizeof(double):
*(double *)p->data = (double)val;
@@ -246,11 +241,10 @@ int OSSL_PARAM_set_int32(const OSSL_PARAM *p, int32_t val)
return 0;
}
-OSSL_PARAM OSSL_PARAM_construct_int32(const char *key, int32_t *buf,
- size_t *rsize)
+OSSL_PARAM OSSL_PARAM_construct_int32(const char *key, int32_t *buf)
{
return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf,
- sizeof(int32_t), rsize);
+ sizeof(int32_t));
}
int OSSL_PARAM_get_uint32(const OSSL_PARAM *p, uint32_t *val)
@@ -307,25 +301,25 @@ int OSSL_PARAM_get_uint32(const OSSL_PARAM *p, uint32_t *val)
return 0;
}
-int OSSL_PARAM_set_uint32(const OSSL_PARAM *p, uint32_t val)
+int OSSL_PARAM_set_uint32(OSSL_PARAM *p, uint32_t val)
{
if (p == NULL)
return 0;
- SET_RETURN_SIZE(p, 0);
+ p->return_size = 0;
if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER) {
- SET_RETURN_SIZE(p, sizeof(uint32_t)); /* Minimum expected size */
+ p->return_size = sizeof(uint32_t); /* Minimum expected size */
switch (p->data_size) {
case sizeof(uint32_t):
*(uint32_t *)p->data = val;
return 1;
case sizeof(uint64_t):
- SET_RETURN_SIZE(p, sizeof(uint64_t));
+ p->return_size = sizeof(uint64_t);
*(uint64_t *)p->data = val;
return 1;
}
} else if (p->data_type == OSSL_PARAM_INTEGER) {
- SET_RETURN_SIZE(p, sizeof(int32_t)); /* Minimum expected size */
+ p->return_size = sizeof(int32_t); /* Minimum expected size */
switch (p->data_size) {
case sizeof(int32_t):
if (val <= INT32_MAX) {
@@ -334,12 +328,12 @@ int OSSL_PARAM_set_uint32(const OSSL_PARAM *p, uint32_t val)
}
break;
case sizeof(int64_t):
- SET_RETURN_SIZE(p, sizeof(int64_t));
+ p->return_size = sizeof(int64_t);
*(int64_t *)p->data = (int64_t)val;
return 1;
}
} else if (p->data_type == OSSL_PARAM_REAL) {
- SET_RETURN_SIZE(p, sizeof(double));
+ p->return_size = sizeof(double);
switch (p->data_size) {
case sizeof(double):
*(double *)p->data = (double)val;
@@ -349,11 +343,10 @@ int OSSL_PARAM_set_uint32(const OSSL_PARAM *p, uint32_t val)
return 0;
}
-OSSL_PARAM OSSL_PARAM_construct_uint32(const char *key, uint32_t *buf,
- size_t *rsize)
+OSSL_PARAM OSSL_PARAM_construct_uint32(const char *key, uint32_t *buf)
{
return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf,
- sizeof(uint32_t), rsize);
+ sizeof(uint32_t));
}
int OSSL_PARAM_get_int64(const OSSL_PARAM *p, int64_t *val)
@@ -400,19 +393,19 @@ int OSSL_PARAM_get_int64(const OSSL_PARAM *p, int64_t *val)
return 0;
}
-int OSSL_PARAM_set_int64(const OSSL_PARAM *p, int64_t val)
+int OSSL_PARAM_set_int64(OSSL_PARAM *p, int64_t val)
{
uint64_t u64;
if (p == NULL)
return 0;
- SET_RETURN_SIZE(p, 0);
+ p->return_size = 0;
if (p->data_type == OSSL_PARAM_INTEGER) {
- SET_RETURN_SIZE(p, sizeof(int64_t)); /* Expected size */
+ p->return_size = sizeof(int64_t); /* Expected size */
switch (p->data_size) {
case sizeof(int32_t):
if (val >= INT32_MIN && val <= INT32_MAX) {
- SET_RETURN_SIZE(p, sizeof(int32_t));
+ p->return_size = sizeof(int32_t);
*(int32_t *)p->data = (int32_t)val;
return 1;
}
@@ -422,11 +415,11 @@ int OSSL_PARAM_set_int64(const OSSL_PARAM *p, int64_t val)
return 1;
}
} else if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER && val >= 0) {
- SET_RETURN_SIZE(p, sizeof(uint64_t)); /* Expected size */
+ p->return_size = sizeof(uint64_t); /* Expected size */
switch (p->data_size) {
case sizeof(uint32_t):
if (val <= UINT32_MAX) {
- SET_RETURN_SIZE(p, sizeof(uint32_t));
+ p->return_size = sizeof(uint32_t);
*(uint32_t *)p->data = (uint32_t)val;
return 1;
}
@@ -436,7 +429,7 @@ int OSSL_PARAM_set_int64(const OSSL_PARAM *p, int64_t val)
return 1;
}
} else if (p->data_type == OSSL_PARAM_REAL) {
- SET_RETURN_SIZE(p, sizeof(double));
+ p->return_size = sizeof(double);
switch (p->data_size) {
case sizeof(double):
u64 = val < 0 ? -val : val;
@@ -450,11 +443,9 @@ int OSSL_PARAM_set_int64(const OSSL_PARAM *p, int64_t val)
return 0;
}
-OSSL_PARAM OSSL_PARAM_construct_int64(const char *key, int64_t *buf,
- size_t *rsize)
+OSSL_PARAM OSSL_PARAM_construct_int64(const char *key, int64_t *buf)
{
- return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(int64_t),
- rsize);
+ return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(int64_t));
}
int OSSL_PARAM_get_uint64(const OSSL_PARAM *p, uint64_t *val)
@@ -506,18 +497,18 @@ int OSSL_PARAM_get_uint64(const OSSL_PARAM *p, uint64_t *val)
return 0;
}
-int OSSL_PARAM_set_uint64(const OSSL_PARAM *p, uint64_t val)
+int OSSL_PARAM_set_uint64(OSSL_PARAM *p, uint64_t val)
{
if (p == NULL)
return 0;
- SET_RETURN_SIZE(p, 0);
+ p->return_size = 0;
if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER) {
- SET_RETURN_SIZE(p, sizeof(uint64_t)); /* Expected size */
+ p->return_size = sizeof(uint64_t); /* Expected size */
switch (p->data_size) {
case sizeof(uint32_t):
if (val <= UINT32_MAX) {
- SET_RETURN_SIZE(p, sizeof(uint32_t));
+ p->return_size = sizeof(uint32_t);
*(uint32_t *)p->data = (uint32_t)val;
return 1;
}
@@ -527,11 +518,11 @@ int OSSL_PARAM_set_uint64(const OSSL_PARAM *p, uint64_t val)
return 1;
}
} else if (p->data_type == OSSL_PARAM_INTEGER) {
- SET_RETURN_SIZE(p, sizeof(int64_t)); /* Expected size */
+ p->return_size = sizeof(int64_t); /* Expected size */
switch (p->data_size) {
case sizeof(int32_t):
if (val <= INT32_MAX) {
- SET_RETURN_SIZE(p, sizeof(int32_t));
+ p->return_size = sizeof(int32_t);
*(int32_t *)p->data = (int32_t)val;
return 1;
}
@@ -544,7 +535,7 @@ int OSSL_PARAM_set_uint64(const OSSL_PARAM *p, uint64_t val)
break;
}
} else if (p->data_type == OSSL_PARAM_REAL) {
- SET_RETURN_SIZE(p, sizeof(double));
+ p->return_size = sizeof(double);
switch (p->data_size) {
case sizeof(double):
if ((val >> 53) == 0) { /* 53 significant bits in the mantissa */
@@ -557,10 +548,10 @@ int OSSL_PARAM_set_uint64(const OSSL_PARAM *p, uint64_t val)
return 0;
}
-OSSL_PARAM OSSL_PARAM_construct_uint64(const char *key, uint64_t *buf,
- size_t *rsize) {
+OSSL_PARAM OSSL_PARAM_construct_uint64(const char *key, uint64_t *buf)
+{
return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf,
- sizeof(uint64_t), rsize);
+ sizeof(uint64_t));
}
int OSSL_PARAM_get_size_t(const OSSL_PARAM *p, size_t *val)
@@ -574,7 +565,7 @@ int OSSL_PARAM_get_size_t(const OSSL_PARAM *p, size_t *val)
return 0;
}
-int OSSL_PARAM_set_size_t(const OSSL_PARAM *p, size_t val)
+int OSSL_PARAM_set_size_t(OSSL_PARAM *p, size_t val)
{
switch (sizeof(size_t)) {
case sizeof(uint32_t):
@@ -585,11 +576,11 @@ int OSSL_PARAM_set_size_t(const OSSL_PARAM *p, size_t val)
return 0;
}
-OSSL_PARAM OSSL_PARAM_construct_size_t(const char *key, size_t *buf,
- size_t *rsize)
+OSSL_PARAM OSSL_PARAM_construct_size_t(const char *key, size_t *buf)
{
return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf,
- sizeof(size_t), rsize); }
+ sizeof(size_t));
+}
#ifndef FIPS_MODE
/*
@@ -615,13 +606,13 @@ int OSSL_PARAM_get_BN(const OSSL_PARAM *p, BIGNUM **val)
return 0;
}
-int OSSL_PARAM_set_BN(const OSSL_PARAM *p, const BIGNUM *val)
+int OSSL_PARAM_set_BN(OSSL_PARAM *p, const BIGNUM *val)
{
size_t bytes;
if (p == NULL)
return 0;
- SET_RETURN_SIZE(p, 0);
+ p->return_size = 0;
if (val == NULL || p->data_type != OSSL_PARAM_UNSIGNED_INTEGER)
return 0;
@@ -630,16 +621,16 @@ int OSSL_PARAM_set_BN(const OSSL_PARAM *p, const BIGNUM *val)
return 0;
bytes = (size_t)BN_num_bytes(val);
- SET_RETURN_SIZE(p, bytes);
+ p->return_size = bytes;
return p->data_size >= bytes
&& BN_bn2nativepad(val, p->data, bytes) >= 0;
}
OSSL_PARAM OSSL_PARAM_construct_BN(const char *key, unsigned char *buf,
- size_t bsize, size_t *rsize)
+ size_t bsize)
{
return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER,
- buf, bsize, rsize);
+ buf, bsize);
}
#endif
@@ -688,14 +679,14 @@ int OSSL_PARAM_get_double(const OSSL_PARAM *p, double *val)
return 0;
}
-int OSSL_PARAM_set_double(const OSSL_PARAM *p, double val)
+int OSSL_PARAM_set_double(OSSL_PARAM *p, double val)
{
if (p == NULL)
return 0;
- SET_RETURN_SIZE(p, 0);
+ p->return_size = 0;
if (p->data_type == OSSL_PARAM_REAL) {
- SET_RETURN_SIZE(p, sizeof(double));
+ p->return_size = sizeof(double);
switch (p->data_size) {
case sizeof(double):
*(double *)p->data = val;
@@ -703,35 +694,35 @@ int OSSL_PARAM_set_double(const OSSL_PARAM *p, double val)
}
} else if (p->data_type == OSSL_PARAM_UNSIGNED_INTEGER
&& val == (uintmax_t)val) {
- SET_RETURN_SIZE(p, sizeof(double));
+ p->return_size = sizeof(double);
switch (p->data_size) {
case sizeof(uint32_t):
if (val >= 0 && val <= UINT32_MAX) {
- SET_RETURN_SIZE(p, sizeof(uint32_t));
+ p->return_size = sizeof(uint32_t);
*(uint32_t *)p->data = (uint32_t)val;
return 1;
}
break;
case sizeof(uint64_t):
if (val >= 0 && val <= UINT64_MAX) {
- SET_RETURN_SIZE(p, sizeof(uint64_t));
+ p->return_size = sizeof(uint64_t);
*(uint64_t *)p->data = (uint64_t)val;
return 1;
}
break; }
} else if (p->data_type == OSSL_PARAM_INTEGER && val == (intmax_t)val) {
- SET_RETURN_SIZE(p, sizeof(double));
+ p->return_size = sizeof(double);
switch (p->data_size) {
case sizeof(int32_t):
if (val >= INT32_MIN && val <= INT32_MAX) {
- SET_RETURN_SIZE(p, sizeof(int32_t));
+ p->return_size = sizeof(int32_t);
*(int32_t *)p->data = (int32_t)val;
return 1;
}
break;
case sizeof(int64_t):
if (val >= INT64_MIN && val <= INT64_MAX) {
- SET_RETURN_SIZE(p, sizeof(int64_t));
+ p->return_size = sizeof(int64_t);
*(int64_t *)p->data = (int64_t)val;
return 1;
}
@@ -741,11 +732,9 @@ int OSSL_PARAM_set_double(const OSSL_PARAM *p, double val)
return 0;
}
-OSSL_PARAM OSSL_PARAM_construct_double(const char *key, double *buf,
- size_t *rsize)
+OSSL_PARAM OSSL_PARAM_construct_double(const char *key, double *buf)
{
- return ossl_param_construct(key, OSSL_PARAM_REAL, buf, sizeof(double),
- rsize);
+ return ossl_param_construct(key, OSSL_PARAM_REAL, buf, sizeof(double));
}
static int get_string_internal(const OSSL_PARAM *p, void **val, size_t max_len,
@@ -789,10 +778,10 @@ int OSSL_PARAM_get_octet_string(const OSSL_PARAM *p, void **val, size_t max_len,
OSSL_PARAM_OCTET_STRING);
}
-static int set_string_internal(const OSSL_PARAM *p, const void *val, size_t len,
+static int set_string_internal(OSSL_PARAM *p, const void *val, size_t len,
unsigned int type)
{
- SET_RETURN_SIZE(p, len);
+ p->return_size = len;
if (p->data_type != type || p->data_size < len)
return 0;
@@ -800,41 +789,39 @@ static int set_string_internal(const OSSL_PARAM *p, const void *val, size_t len,
return 1;
}
-int OSSL_PARAM_set_utf8_string(const OSSL_PARAM *p, const char *val)
+int OSSL_PARAM_set_utf8_string(OSSL_PARAM *p, const char *val)
{
if (p == NULL)
return 0;
- SET_RETURN_SIZE(p, 0);
+ p->return_size = 0;
if (val == NULL)
return 0;
return set_string_internal(p, val, strlen(val) + 1, OSSL_PARAM_UTF8_STRING);
}
-int OSSL_PARAM_set_octet_string(const OSSL_PARAM *p, const void *val,
+int OSSL_PARAM_set_octet_string(OSSL_PARAM *p, const void *val,
size_t len)
{
if (p == NULL)
return 0;
- SET_RETURN_SIZE(p, 0);
+ p->return_size = 0;
if (val == NULL)
return 0;
return set_string_internal(p, val, len, OSSL_PARAM_OCTET_STRING);
}
OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf,
- size_t bsize, size_t *rsize)
+ size_t bsize)
{
- return ossl_param_construct(key, OSSL_PARAM_UTF8_STRING, buf, bsize,
- rsize);
+ return ossl_param_construct(key, OSSL_PARAM_UTF8_STRING, buf, bsize);
}
OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf,
- size_t bsize, size_t *rsize)
+ size_t bsize)
{
- return ossl_param_construct(key, OSSL_PARAM_OCTET_STRING, buf, bsize,
- rsize);
+ return ossl_param_construct(key, OSSL_PARAM_OCTET_STRING, buf, bsize);
}
static int get_ptr_internal(const OSSL_PARAM *p, const void **val,
@@ -859,47 +846,47 @@ int OSSL_PARAM_get_octet_ptr(const OSSL_PARAM *p, const void **val,
return get_ptr_internal(p, val, used_len, OSSL_PARAM_OCTET_PTR);
}
-static int set_ptr_internal(const OSSL_PARAM *p, const void *val,
+static int set_ptr_internal(OSSL_PARAM *p, const void *val,
unsigned int type, size_t len)
{
- SET_RETURN_SIZE(p, len);
+ p->return_size = len;
if (p->data_type != type)
return 0;
*(const void **)p->data = val;
return 1;
}
-int OSSL_PARAM_set_utf8_ptr(const OSSL_PARAM *p, const char *val)
+int OSSL_PARAM_set_utf8_ptr(OSSL_PARAM *p, const char *val)
{
if (p == NULL)
return 0;
- SET_RETURN_SIZE(p, 0);
+ p->return_size = 0;
if (val == NULL)
return 0;
return set_ptr_internal(p, val, OSSL_PARAM_UTF8_PTR, strlen(val) + 1);
}
-int OSSL_PARAM_set_octet_ptr(const OSSL_PARAM *p, const void *val,
+int OSSL_PARAM_set_octet_ptr(OSSL_PARAM *p, const void *val,
size_t used_len)
{
if (p == NULL)
return 0;
- SET_RETURN_SIZE(p, 0);
+ p->return_size = 0;
if (val == NULL)
return 0;
return set_ptr_internal(p, val, OSSL_PARAM_OCTET_PTR, used_len);
}
OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf,
- size_t bsize, size_t *rsize)
+ size_t bsize)
{
- return ossl_param_construct(key, OSSL_PARAM_UTF8_PTR, buf, bsize, rsize);
+ return ossl_param_construct(key, OSSL_PARAM_UTF8_PTR, buf, bsize);
}
OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf,
- size_t bsize, size_t *rsize)
+ size_t bsize)
{
- return ossl_param_construct(key, OSSL_PARAM_OCTET_PTR, buf, bsize, rsize);
+ return ossl_param_construct(key, OSSL_PARAM_OCTET_PTR, buf, bsize);
}
OSSL_PARAM OSSL_PARAM_construct_end(void)
diff --git a/crypto/provider.c b/crypto/provider.c
index 249502413f..4e21bfe6d7 100644
--- a/crypto/provider.c
+++ b/crypto/provider.c
@@ -40,8 +40,7 @@ const OSSL_ITEM *OSSL_PROVIDER_get_param_types(const OSSL_PROVIDER *prov)
return ossl_provider_get_param_types(prov);
}
-int OSSL_PROVIDER_get_params(const OSSL_PROVIDER *prov,
- const OSSL_PARAM params[])
+int OSSL_PROVIDER_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[])
{
return ossl_provider_get_params(prov, params);
}
diff --git a/crypto/provider_core.c b/crypto/provider_core.c
index 274bdf94ba..f1b3925faa 100644
--- a/crypto/provider_core.c
+++ b/crypto/provider_core.c
@@ -603,8 +603,7 @@ const OSSL_ITEM *ossl_provider_get_param_types(const OSSL_PROVIDER *prov)
? NULL : prov->get_param_types(prov->provctx);
}
-int ossl_provider_get_params(const OSSL_PROVIDER *prov,
- const OSSL_PARAM params[])
+int ossl_provider_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[])
{
return prov->get_params == NULL
? 0 : prov->get_params(prov->provctx, params);
@@ -641,10 +640,10 @@ static const OSSL_ITEM *core_get_param_types(const OSSL_PROVIDER *prov)
return param_types;
}
-static int core_get_params(const OSSL_PROVIDER *prov, const OSSL_PARAM params[])
+static int core_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[])
{
int i;
- const OSSL_PARAM *p;
+ OSSL_PARAM *p;
if ((p = OSSL_PARAM_locate(params, "openssl-version")) != NULL)
OSSL_PARAM_set_utf8_ptr(p, OPENSSL_VERSION_STR);
diff --git a/doc/internal/man3/ossl_provider_new.pod b/doc/internal/man3/ossl_provider_new.pod
index 04535086be..9e96c7203c 100644
--- a/doc/internal/man3/ossl_provider_new.pod
+++ b/doc/internal/man3/ossl_provider_new.pod
@@ -47,8 +47,7 @@ ossl_provider_get_params, ossl_provider_query_operation
/* Thin wrappers around calls to the provider */
void ossl_provider_teardown(const OSSL_PROVIDER *prov);
const OSSL_ITEM *ossl_provider_get_param_types(const OSSL_PROVIDER *prov);
- int ossl_provider_get_params(const OSSL_PROVIDER *prov,
- const OSSL_PARAM params[]);
+ int ossl_provider_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]);
const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov,
int operation_id,
int *no_cache);
diff --git a/doc/man3/EVP_DigestInit.pod b/doc/man3/EVP_DigestInit.pod
index ec8f6cc1c7..bc10fa36c5 100644
--- a/doc/man3/EVP_DigestInit.pod
+++ b/doc/man3/EVP_DigestInit.pod
@@ -22,7 +22,7 @@ EVP_MD_CTX_pkey_ctx, EVP_MD_CTX_set_pkey_ctx - EVP digest routines
int EVP_MD_CTX_reset(EVP_MD_CTX *ctx);
void EVP_MD_CTX_free(EVP_MD_CTX *ctx);
void EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void* p2);
- int EVP_MD_CTX_get_params(EVP_MD_CTX *ctx, const OSSL_PARAM params[]);
+ int EVP_MD_CTX_get_params(EVP_MD_CTX *ctx, OSSL_PARAM params[]);
int EVP_MD_CTX_set_params(EVP_MD_CTX *ctx, const OSSL_PARAM params[]);
void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);
void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);
diff --git a/doc/man3/OSSL_PARAM.pod b/doc/man3/OSSL_PARAM.pod
index fb8c6fdae3..fbe37b4b13 100644
--- a/doc/man3/OSSL_PARAM.pod
+++ b/doc/man3/OSSL_PARAM.pod
@@ -14,7 +14,7 @@ OSSL_PARAM - a structure to pass or request object parameters
unsigned char data_type; /* declare what kind of content is in data */
void *data; /* value being passed in or out */
size_t data_size; /* data size */
- size_t *return_size; /* OPTIONAL: address to content size */
+ size_t return_size; /* returned size */
};
=head1 DESCRIPTION
@@ -143,7 +143,7 @@ C<data_size> must be set to the size of the data, not the size of the
pointer to the data.
If this is used in a parameter request,
C<data_size> is not relevant. However, the I<responder> will set
-C<*return_size> to the size of the data.
+C<return_size> to the size of the data.
Note that the use of this type is B<fragile> and can only be safely
used for data that remains constant and in a constant location for a
@@ -166,7 +166,7 @@ C<data_size> must be set to the size of the data, not the size of the
pointer to the data.
If this is used in a parameter request,
C<data_size> is not relevant. However, the I<responder> will set
-C<*return_size> to the size of the data.
+C<return_size> to the size of the data.
Note that the use of this type is B<fragile> and can only be safely
used for data that remains constant and in a constant location for a
@@ -196,9 +196,10 @@ enough set of data, that call should succeed.
=item *
-A I<responder> must never change the fields of an C<OSSL_PARAM>, it
-may only change the contents of the memory that C<data> and
-C<return_size> point at.
+Apart from the C<return_size>, a I<responder> must never change the fields
+of an C<OSSL_PARAM>.
+To return a value, it should change the contents of the memory that
+C<data> points at.
=item *
@@ -214,7 +215,7 @@ C<OSSL_PARAM_OCTET_STRING>), but this is in no way mandatory.
=item *
If a I<responder> finds that some data sizes are too small for the
-requested data, it must set C<*return_size> for each such
+requested data, it must set C<return_size> for each such
C<OSSL_PARAM> item to the required size, and eventually return an
error.
@@ -244,9 +245,9 @@ This example is for setting parameters on some object:
const char *foo = "some string";
size_t foo_l = strlen(foo) + 1;
const char bar[] = "some other string";
- const OSSL_PARAM set[] = {
- { "foo", OSSL_PARAM_UTF8_STRING_PTR, &foo, foo_l, NULL },
- { "bar", OSSL_PARAM_UTF8_STRING, &bar, sizeof(bar), NULL },
+ OSSL_PARAM set[] = {
+ { "foo", OSSL_PARAM_UTF8_STRING_PTR, &foo, foo_l, 0 },
+ { "bar", OSSL_PARAM_UTF8_STRING, &bar, sizeof(bar), 0 },
{ NULL, 0, NULL, 0, NULL }
};
@@ -258,26 +259,26 @@ This example is for requesting parameters on some object:
size_t foo_l;
char bar[1024];
size_t bar_l;
- const OSSL_PARAM request[] = {
- { "foo", OSSL_PARAM_UTF8_STRING_PTR, &foo, 0 /*irrelevant*/, &foo_l },
- { "bar", OSSL_PARAM_UTF8_STRING, &bar, sizeof(bar), &bar_l },
+ OSSL_PARAM request[] = {
+ { "foo", OSSL_PARAM_UTF8_STRING_PTR, &foo, 0 /*irrelevant*/, 0 },
+ { "bar", OSSL_PARAM_UTF8_STRING, &bar, sizeof(bar), 0 },
{ NULL, 0, NULL, 0, NULL }
};
A I<responder> that receives this array (as C<params> in this example)
could fill in the parameters like this:
- /* const OSSL_PARAM *params */
+ /* OSSL_PARAM *params */
int i;
for (i = 0; params[i].key != NULL; i++) {
if (strcmp(params[i].key, "foo") == 0) {
*(char **)params[i].data = "foo value";
- *params[i].return_size = 10; /* size of "foo value" */
+ params[i].return_size = 10; /* size of "foo value" */
} else if (strcmp(params[i].key, "bar") == 0) {
memcpy(params[i].data, "bar value", 10);
- *params[i].return_size = 10; /* size of "bar value" */
+ params[i].return_size = 10; /* size of "bar value" */
}
/* Ignore stuff we don't know */
}
diff --git a/doc/man3/OSSL_PARAM_int.pod b/doc/man3/OSSL_PARAM_int.pod
index f8d8c501e0..6d19068962 100644
--- a/doc/man3/OSSL_PARAM_int.pod
+++ b/doc/man3/OSSL_PARAM_int.pod
@@ -4,14 +4,9 @@
OSSL_PARAM_double, OSSL_PARAM_int, OSSL_PARAM_int32, OSSL_PARAM_int64,
OSSL_PARAM_long, OSSL_PARAM_size_t, OSSL_PARAM_uint, OSSL_PARAM_uint32,
-OSSL_PARAM_uint64, OSSL_PARAM_ulong, OSSL_PARAM_utf8_string,
+OSSL_PARAM_uint64, OSSL_PARAM_ulong, OSSL_PARAM_BN, OSSL_PARAM_utf8_string,
OSSL_PARAM_octet_string, OSSL_PARAM_utf8_ptr, OSSL_PARAM_octet_ptr,
-OSSL_PARAM_SIZED_double, OSSL_PARAM_SIZED_int, OSSL_PARAM_SIZED_int32,
-OSSL_PARAM_SIZED_int64, OSSL_PARAM_SIZED_long, OSSL_PARAM_SIZED_size_t,
-OSSL_PARAM_SIZED_uint, OSSL_PARAM_SIZED_uint32, OSSL_PARAM_SIZED_uint64,
-OSSL_PARAM_SIZED_ulong, OSSL_PARAM_SIZED_BN, OSSL_PARAM_SIZED_utf8_string,
-OSSL_PARAM_SIZED_octet_string, OSSL_PARAM_SIZED_utf8_ptr,
-OSSL_PARAM_SIZED_octet_ptr, OSSL_PARAM_END, OSSL_PARAM_construct_double,
+OSSL_PARAM_END, OSSL_PARAM_construct_BN, OSSL_PARAM_construct_double,
OSSL_PARAM_construct_int, OSSL_PARAM_construct_int32,
OSSL_PARAM_construct_int64, OSSL_PARAM_construct_long,
OSSL_PARAM_construct_size_t, OSSL_PARAM_construct_uint,
@@ -19,15 +14,15 @@ OSSL_PARAM_construct_uint32, OSSL_PARAM_construct_uint64,
OSSL_PARAM_construct_ulong, OSSL_PARAM_END, OSSL_PARAM_construct_BN,
OSSL_PARAM_construct_utf8_string, OSSL_PARAM_construct_utf8_ptr,
OSSL_PARAM_construct_octet_string, OSSL_PARAM_construct_octet_ptr,
-OSSL_PARAM_construct_end, OSSL_PARAM_locate, OSSL_PARAM_get_double,
-OSSL_PARAM_get_int, OSSL_PARAM_get_int32, OSSL_PARAM_get_int64,
-OSSL_PARAM_get_long, OSSL_PARAM_get_size_t, OSSL_PARAM_get_uint,
-OSSL_PARAM_get_uint32, OSSL_PARAM_get_uint64, OSSL_PARAM_get_ulong,
-OSSL_PARAM_set_double, OSSL_PARAM_set_int, OSSL_PARAM_set_int32,
-OSSL_PARAM_set_int64, OSSL_PARAM_set_long, OSSL_PARAM_set_size_t,
-OSSL_PARAM_set_uint, OSSL_PARAM_set_uint32, OSSL_PARAM_set_uint64,
-OSSL_PARAM_set_ulong, OSSL_PARAM_get_BN, OSSL_PARAM_set_BN,
-OSSL_PARAM_get_utf8_string, OSSL_PARAM_set_utf8_string,
+OSSL_PARAM_construct_end, OSSL_PARAM_locate, OSSL_PARAM_locate_const,
+OSSL_PARAM_get_double, OSSL_PARAM_get_int, OSSL_PARAM_get_int32,
+OSSL_PARAM_get_int64, OSSL_PARAM_get_long, OSSL_PARAM_get_size_t,
+OSSL_PARAM_get_uint, OSSL_PARAM_get_uint32, OSSL_PARAM_get_uint64,
+OSSL_PARAM_get_ulong, OSSL_PARAM_set_double, OSSL_PARAM_set_int,
+OSSL_PARAM_set_int32, OSSL_PARAM_set_int64, OSSL_PARAM_set_long,
+OSSL_PARAM_set_size_t, OSSL_PARAM_set_uint, OSSL_PARAM_set_uint32,
+OSSL_PARAM_set_uint64, OSSL_PARAM_set_ulong, OSSL_PARAM_get_BN,
+OSSL_PARAM_set_BN, OSSL_PARAM_get_utf8_string, OSSL_PARAM_set_utf8_string,
OSSL_PARAM_get_octet_string, OSSL_PARAM_set_octet_string,
OSSL_PARAM_get_utf8_ptr, OSSL_PARAM_set_utf8_ptr, OSSL_PARAM_get_octet_ptr,
OSSL_PARAM_set_octet_ptr
@@ -44,52 +39,46 @@ OSSL_PARAM_set_octet_ptr
#define OSSL_PARAM_octet_string(key, address, size)
#define OSSL_PARAM_utf8_ptr(key, address, size)
#define OSSL_PARAM_octet_ptr(key, address, size)
-
- #define OSSL_PARAM_SIZED_TYPE(key, address, return_size)
- #define OSSL_PARAM_SIZED_BN(key, address, size, return_size)
- #define OSSL_PARAM_SIZED_utf8_string(key, address, size, return_size)
- #define OSSL_PARAM_SIZED_octet_string(key, address, size, return_size)
- #define OSSL_PARAM_SIZED_utf8_ptr(key, address, size, return_size)
- #define OSSL_PARAM_SIZED_octet_ptr(key, address, size, return_size)
-
+ #define OSSL_PARAM_BN(key, address, size)
#define OSSL_PARAM_END
OSSL_PARAM OSSL_PARAM_construct_TYPE(const char *key, TYPE *buf, size_t *ret);
OSSL_PARAM OSSL_PARAM_construct_BN(const char *key, unsigned char *buf,
- size_t bsize, size_t *rsize);
+ size_t bsize);
OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf,
- size_t bsize, size_t *rsize);
+ size_t bsize);
OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf,
- size_t bsize, size_t *rsize);
+ size_t bsize);
OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf,
- size_t bsize, size_t *rsize);
+ size_t bsize);
OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf,
- size_t bsize, size_t *rsize);
+ size_t bsize);
OSSL_PARAM OSSL_PARAM_construct_end(void);
OSSL_PARAM *OSSL_PARAM_locate(OSSL_PARAM *array, const char *key);
+ const OSSL_PARAM *OSSL_PARAM_locate_const(const OSSL_PARAM *array,
+ const char *key);
int OSSL_PARAM_get_TYPE(const OSSL_PARAM *p, const char *key, TYPE *val);
- int OSSL_PARAM_set_TYPE(const OSSL_PARAM *p, const char *key, TYPE val);
+ int OSSL_PARAM_set_TYPE(OSSL_PARAM *p, const char *key, TYPE val);
int OSSL_PARAM_get_BN(const OSSL_PARAM *p, const char *key, BIGNUM **val);
- int OSSL_PARAM_set_BN(const OSSL_PARAM *p, const char *key, const BIGNUM *val);
+ int OSSL_PARAM_set_BN(OSSL_PARAM *p, const char *key, const BIGNUM *val);
int OSSL_PARAM_get_utf8_string(const OSSL_PARAM *p, char **val,
size_t max_len);
- int OSSL_PARAM_set_utf8_string(const OSSL_PARAM *p, const char *val);
+ int OSSL_PARAM_set_utf8_string(OSSL_PARAM *p, const char *val);
int OSSL_PARAM_get_octet_string(const OSSL_PARAM *p, void **val,
size_t max_len, size_t *used_len);
- int OSSL_PARAM_set_octet_string(const OSSL_PARAM *p, const void *val,
- size_t len);
+ int OSSL_PARAM_set_octet_string(OSSL_PARAM *p, const void *val, size_t len);
int OSSL_PARAM_get_utf8_ptr(const OSSL_PARAM *p, char **val);
- int OSSL_PARAM_set_utf8_ptr(const OSSL_PARAM *p, char *val);
+ int OSSL_PARAM_set_utf8_ptr(OSSL_PARAM *p, char *val);
int OSSL_PARAM_get_octet_ptr(const OSSL_PARAM *p, void **val,
size_t *used_len);
- int OSSL_PARAM_set_octet_ptr(const OSSL_PARAM *p, void *val, size_t used_len);
+ int OSSL_PARAM_set_octet_ptr(OSSL_PARAM *p, void *val, size_t used_len);
=head1 DESCRIPTION
@@ -146,26 +135,11 @@ Each of these macros defines a parameter of the specified B<TYPE> with the
provided B<key> and parameter variable B<address>.
OSSL_PARAM_utf8_string(), OSSL_PARAM_octet_string(), OSSL_PARAM_utf8_ptr(),
-OSSL_PARAM_octet_ptr() are macros that provide support for defining UTF8
-strings and OCTET strings.
+OSSL_PARAM_octet_ptr(), OSSL_PARAM_BN() are macros that provide support
+for defining UTF8 strings, OCTET strings and big numbers.
A parameter with name B<key> is defined.
The storage for this parameter is at B<address> and is of B<size> bytes.
-OSSL_PARAM_SIZED_TYPE() are a second series of macros designed to assist with
-the initialisation of OSSL_PARAM structures.
-They are similar to the OSSL_PARAM_TYPE() macros but also include a
-B<return_size> argument which contains the address of a size_t variable which
-will be populated with the actual size of the parameter upon return from a
-OSSL_PARAM_set_TYPE() call.
-
-OSSL_PARAM_SIZED_BN(), OSSL_PARAM_SIZED_utf8_string(),
-OSSL_PARAM_SIZED_octet_string(), OSSL_PARAM_SIZED_utf8_ptr(),
-OSSL_PARAM_SIZED_octet_ptr() are macros that provide support for defining large
-integers, UTF8 string and OCTET strings in an OSSL_PARAM array.
-A parameter with name B<key> is defined.
-The storage for this parameter is at B<address> and is of B<size> bytes.
-The size used by the parameter value, in bytes, is written to B<return_size>.
-
OSSL_PARAM_END provides an end of parameter list marker.
This should terminate all OSSL_PARAM arrays.
@@ -205,6 +179,9 @@ OSSL_PARAM structure.
OSSL_PARAM_locate() is a function that searches an B<array> of parameters for
the one matching the B<key> name.
+OSSL_PARAM_locate_const() behaves exactly like OSSL_PARAM_locate() except for
+the presence of I<const> for the B<array> argument and its return value.
+
OSSL_PARAM_get_TYPE() retrieves a value of type B<TYPE> from the parameter B<p>.
The value is copied to the address B<val>.
Type coercion takes place as discussed in the NOTES section.
@@ -260,9 +237,9 @@ OSSL_PARAM_construct_utf8_string(), OSSL_PARAM_construct_octet_string(),
OSSL_PARAM_construct_utf8_ptr() and OSSL_PARAM_construct_octet_ptr()
return a populated OSSL_PARAM structure.
-OSSL_PARAM_locate() returns a pointer to the matching OSSL_PARAM object.
-It returns B<NULL> on error or when no object matching B<key> exists in
-the B<array>.
+OSSL_PARAM_locate() and OSSL_PARAM_locate_const() return a pointer to
+the matching OSSL_PARAM object. They return B<NULL> on error or when
+no object matching B<key> exists in the B<array>.
All other functions return B<1> on success and B<0> on failure.
@@ -308,21 +285,19 @@ demonstrates that the requestor isn't obligated to request all
available parameters:
const char *foo = NULL;
- size_t foo_l;
char bar[1024];
- size_t bar_l;
- const OSSL_PARAM request[] = {
- OSSL_PARAM_UTF8_PTR("foo", foo, 0, foo_l),
- OSSL_PARAM_UTF8_STRING("bar", bar, sizeof(bar), bar_l),
+ OSSL_PARAM request[] = {
+ OSSL_PARAM_utf8_ptr("foo", foo, 0),
+ OSSL_PARAM_utf8_string("bar", bar, sizeof(bar)),
OSSL_PARAM_END
};
A I<responder> that receives this array (as C<params> in this example)
could fill in the parameters like this:
- /* const OSSL_PARAM *params */
+ /* OSSL_PARAM *params */
- const OSSL_PARAM *p;
+ OSSL_PARAM *p;
if ((p = OSSL_PARAM_locate(params, "foo")) == NULL)
OSSL_PARAM_set_utf8_ptr(p, "foo value");
diff --git a/doc/man3/OSSL_PROVIDER.pod b/doc/man3/OSSL_PROVIDER.pod
index e3653663b2..9fe2e18a69 100644
--- a/doc/man3/OSSL_PROVIDER.pod
+++ b/doc/man3/OSSL_PROVIDER.pod
@@ -16,7 +16,7 @@ OSSL_PROVIDER_add_builtin - provider routines
int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov);
const OSSL_ITEM *OSSL_PROVIDER_get_param_types(OSSL_PROVIDER *prov);
- int OSSL_PROVIDER_get_params(OSSL_PROVIDER *prov, const OSSL_PARAM params[]);
+ int OSSL_PROVIDER_get_params(OSSL_PROVIDER *prov, OSSL_PARAM params[]);
int OSSL_PROVIDER_add_builtin(OPENSSL_CTX *, const char *name,
ossl_provider_init_fn *init_fn);
@@ -81,7 +81,7 @@ its build number.
OSSL_PROVIDER *prov = NULL;
const char *build = NULL;
size_t built_l = 0;
- const OSSL_PARAM request[] = {
+ OSSL_PARAM request[] = {
{ "build", OSSL_PARAM_UTF8_STRING_PTR, &build, 0, &build_l },
{ NULL, 0, NULL, 0, NULL }
};
diff --git a/include/internal/provider.h b/include/internal/provider.h
index f48c758479..7d50701c1d 100644
--- a/include/internal/provider.h
+++ b/include/internal/provider.h
@@ -63,8 +63,7 @@ const char *ossl_provider_module_path(const OSSL_PROVIDER *prov);
/* Thin wrappers around calls to the provider */
void ossl_provider_teardown(const OSSL_PROVIDER *prov);
const OSSL_ITEM *ossl_provider_get_param_types(const OSSL_PROVIDER *prov);
-int ossl_provider_get_params(const OSSL_PROVIDER *prov,
- const OSSL_PARAM params[]);
+int ossl_provider_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]);
const OSSL_ALGORITHM *ossl_provider_query_operation(const OSSL_PROVIDER *prov,
int operation_id,
int *no_cache);
diff --git a/include/openssl/core.h b/include/openssl/core.h
index f59695703e..848b71431a 100644
--- a/include/openssl/core.h
+++ b/include/openssl/core.h
@@ -77,7 +77,7 @@ struct ossl_param_st {
unsigned int data_type; /* declare what kind of content is in buffer */
void *data; /* value being passed in or out */
size_t data_size; /* data size */
- size_t *return_size; /* OPTIONAL: address to content size */
+ size_t return_size; /* returned content size */
};
/* Currently supported OSSL_PARAM data types */
diff --git a/include/openssl/core_numbers.h b/include/openssl/core_numbers.h
index e1f02001be..8807942606 100644
--- a/include/openssl/core_numbers.h
+++ b/include/openssl/core_numbers.h
@@ -57,7 +57,7 @@ OSSL_CORE_MAKE_FUNC(const OSSL_ITEM *,
core_get_param_types,(const OSSL_PROVIDER *prov))
# define OSSL_FUNC_CORE_GET_PARAMS 2
OSSL_CORE_MAKE_FUNC(int,core_get_params,(const OSSL_PROVIDER *prov,
- const OSSL_PARAM params[]))
+ OSSL_PARAM params[]))
# define OSSL_FUNC_CORE_THREAD_START 3
OSSL_CORE_MAKE_FUNC(int,core_thread_start,(const OSSL_PROVIDER *prov,
OSSL_thread_stop_handler_fn handfn))
@@ -79,7 +79,7 @@ OSSL_CORE_MAKE_FUNC(const OSSL_ITEM *,
provider_get_param_types,(void *provctx))
# define OSSL_FUNC_PROVIDER_GET_PARAMS 1026
OSSL_CORE_MAKE_FUNC(int,provider_get_params,(void *provctx,
- const OSSL_PARAM params[]))
+ OSSL_PARAM params[]))
# define OSSL_FUNC_PROVIDER_QUERY_OPERATION 1027
OSSL_CORE_MAKE_FUNC(const OSSL_ALGORITHM *,provider_query_operation,
(void *provctx, int operation_id, const int *no_store))
@@ -120,7 +120,7 @@ OSSL_CORE_MAKE_FUNC(size_t, OP_digest_block_size, (void))
OSSL_CORE_MAKE_FUNC(int, OP_digest_set_params,
(void *vctx, const OSSL_PARAM params[]))
OSSL_CORE_MAKE_FUNC(int, OP_digest_get_params,
- (void *vctx, const OSSL_PARAM params[]))
+ (void *vctx, OSSL_PARAM params[]))
/* Symmetric Ciphers */
@@ -168,9 +168,9 @@ OSSL_CORE_MAKE_FUNC(void *, OP_cipher_dupctx, (void *cctx))
OSSL_CORE_MAKE_FUNC(size_t, OP_cipher_key_length, (void))
OSSL_CORE_MAKE_FUNC(size_t, OP_cipher_iv_length, (void))
OSSL_CORE_MAKE_FUNC(size_t, OP_cipher_block_size, (void))
-OSSL_CORE_MAKE_FUNC(int, OP_cipher_get_params, (const OSSL_PARAM params[]))
+OSSL_CORE_MAKE_FUNC(int, OP_cipher_get_params, (OSSL_PARAM params[]))
OSSL_CORE_MAKE_FUNC(int, OP_cipher_ctx_get_params, (void *cctx,
- const OSSL_PARAM params[]))
+ OSSL_PARAM params[]))
OSSL_CORE_MAKE_FUNC(int, OP_cipher_ctx_set_params, (void *cctx,
const OSSL_PARAM params[]))
diff --git a/include/openssl/evp.h b/include/openssl/evp.h
index 5fb04d15c3..8195d11250 100644
--- a/include/openssl/evp.h
+++ b/include/openssl/evp.h
@@ -541,7 +541,7 @@ void BIO_set_md(BIO *, const EVP_MD *md);
OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);
int EVP_MD_CTX_set_params(EVP_MD_CTX *ctx, const OSSL_PARAM params[]);
-int EVP_MD_CTX_get_params(EVP_MD_CTX *ctx, const OSSL_PARAM params[]);
+int EVP_MD_CTX_get_params(EVP_MD_CTX *ctx, OSSL_PARAM params[]);
int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2);
EVP_MD_CTX *EVP_MD_CTX_new(void);
int EVP_MD_CTX_reset(EVP_MD_CTX *ctx);
diff --git a/include/openssl/params.h b/include/openssl/params.h
index aea24bb2ff..0e830dee0d 100644
--- a/include/openssl/params.h
+++ b/include/openssl/params.h
@@ -19,124 +19,74 @@ extern "C" {
# endif
# define OSSL_PARAM_END \
- { NULL, 0, NULL, 0, NULL }
+ { NULL, 0, NULL, 0, 0 }
-# define OSSL_PARAM_DEFN(key, type, addr, sz, rsz) \
- { (key), (type), (addr), (sz), (rsz) }
+# define OSSL_PARAM_DEFN(key, type, addr, sz) \
+ { (key), (type), (addr), (sz), 0 }
/* Basic parameter types without return sizes */
# define OSSL_PARAM_int(key, addr) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int), NULL)
+ OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int))
# define OSSL_PARAM_uint(key, addr) \
OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \
- sizeof(unsigned int), NULL)
+ sizeof(unsigned int))
# define OSSL_PARAM_long(key, addr) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(long int), \
- NULL)
+ OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(long int))
# define OSSL_PARAM_ulong(key, addr) \
OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \
- sizeof(unsigned long int), NULL)
+ sizeof(unsigned long int))
# define OSSL_PARAM_int32(key, addr) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int32_t), NULL)
+ OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int32_t))
# define OSSL_PARAM_uint32(key, addr) \
OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \
- sizeof(uint32_t), NULL)
+ sizeof(uint32_t))
# define OSSL_PARAM_int64(key, addr) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int64_t), NULL)
+ OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int64_t))
# define OSSL_PARAM_uint64(key, addr) \
OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \
- sizeof(uint64_t), NULL)
+ sizeof(uint64_t))
# define OSSL_PARAM_size_t(key, addr) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sizeof(size_t), \
- NULL)
+ OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sizeof(size_t))
# define OSSL_PARAM_double(key, addr) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_REAL, (addr), sizeof(double), NULL)
+ OSSL_PARAM_DEFN((key), OSSL_PARAM_REAL, (addr), sizeof(double))
+# define OSSL_PARAM_BN(key, bn, sz) \
+ OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (bn), (sz))
# define OSSL_PARAM_utf8_string(key, addr, sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_STRING, (addr), sz, NULL)
+ OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_STRING, (addr), sz)
# define OSSL_PARAM_octet_string(key, addr, sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_STRING, (addr), sz, NULL)
+ OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_STRING, (addr), sz)
# define OSSL_PARAM_utf8_ptr(key, addr, sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_PTR, &(addr), sz, NULL)
+ OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_PTR, &(addr), sz)
# define OSSL_PARAM_octet_ptr(key, addr, sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_PTR, &(addr), sz, NULL)
-
-/* Basic parameter types including return sizes */
-# define OSSL_PARAM_SIZED_int(key, addr, r_sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int), &(r_sz))
-# define OSSL_PARAM_SIZED_uint(key, addr, r_sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \
- sizeof(unsigned int), &(r_sz))
-# define OSSL_PARAM_SIZED_long(key, addr, r_sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(long int), \
- &(r_sz))
-# define OSSL_PARAM_SIZED_ulong(key, addr, r_sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \
- sizeof(unsigned long int), &(r_sz))
-# define OSSL_PARAM_SIZED_int32(key, addr, r_sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int32_t), &(r_sz))
-# define OSSL_PARAM_SIZED_uint32(key, addr, r_sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \
- sizeof(uint32_t), &(r_sz))
-# define OSSL_PARAM_SIZED_int64(key, addr, r_sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int64_t), &(r_sz))
-# define OSSL_PARAM_SIZED_uint64(key, addr, r_sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \
- sizeof(uint64_t), &(r_sz))
-# define OSSL_PARAM_SIZED_size_t(key, addr, r_sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \
- sizeof(size_t), &(r_sz))
-# define OSSL_PARAM_SIZED_double(key, addr, r_sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_REAL, (addr), sizeof(double), &(r_sz))
-
-# define OSSL_PARAM_SIZED_BN(key, addr, sz, r_sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sz, \
- &(r_sz))
-
-# define OSSL_PARAM_SIZED_utf8_string(key, addr, sz, r_sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_STRING, (addr), sz, &(r_sz))
-# define OSSL_PARAM_SIZED_octet_string(key, addr, sz, r_sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_STRING, (addr), sz, &(r_sz))
-
-# define OSSL_PARAM_SIZED_utf8_ptr(key, addr, sz, r_sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_PTR, &(addr), sz, &(r_sz))
-# define OSSL_PARAM_SIZED_octet_ptr(key, addr, sz, r_sz) \
- OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_PTR, &(addr), sz, &(r_sz))
+ OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_PTR, &(addr), sz)
/* Search an OSSL_PARAM array for a matching name */
-const OSSL_PARAM *OSSL_PARAM_locate(const OSSL_PARAM *p, const char *key);
+OSSL_PARAM *OSSL_PARAM_locate(OSSL_PARAM *p, const char *key);
+const OSSL_PARAM *OSSL_PARAM_locate_const(const OSSL_PARAM *p, const char *key);
/* Basic parameter type run-time construction */
-OSSL_PARAM OSSL_PARAM_construct_int(const char *key, int *buf, size_t *ret);
-OSSL_PARAM OSSL_PARAM_construct_uint(const char *key, unsigned int *buf,
- size_t *ret);
-OSSL_PARAM OSSL_PARAM_construct_long(const char *key, long int *buf,
- size_t *ret);
-OSSL_PARAM OSSL_PARAM_construct_ulong(const char *key, unsigned long int *buf,
- size_t *ret);
-OSSL_PARAM OSSL_PARAM_construct_int32(const char *key, int32_t *buf,
- size_t *ret);
-OSSL_PARAM OSSL_PARAM_construct_uint32(const char *key, uint32_t *buf,
- size_t *ret);
-OSSL_PARAM OSSL_PARAM_construct_int64(const char *key, int64_t *buf,
- size_t *ret);
-OSSL_PARAM OSSL_PARAM_construct_uint64(const char *key, uint64_t *buf,
- size_t *ret);
-OSSL_PARAM OSSL_PARAM_construct_size_t(const char *key, size_t *buf,
- size_t *ret);
+OSSL_PARAM OSSL_PARAM_construct_int(const char *key, int *buf);
+OSSL_PARAM OSSL_PARAM_construct_uint(const char *key, unsigned int *buf);
+OSSL_PARAM OSSL_PARAM_construct_long(const char *key, long int *buf);
+OSSL_PARAM OSSL_PARAM_construct_ulong(const char *key, unsigned long int *buf);
+OSSL_PARAM OSSL_PARAM_construct_int32(const char *key, int32_t *buf);
+OSSL_PARAM OSSL_PARAM_construct_uint32(const char *key, uint32_t *buf);
+OSSL_PARAM OSSL_PARAM_construct_int64(const char *key, int64_t *buf);
+OSSL_PARAM OSSL_PARAM_construct_uint64(const char *key, uint64_t *buf);
+OSSL_PARAM OSSL_PARAM_construct_size_t(const char *key, size_t *buf);
OSSL_PARAM OSSL_PARAM_construct_BN(const char *key, unsigned char *buf,
- size_t bsize, size_t *rsize);
-OSSL_PARAM OSSL_PARAM_construct_double(const char *key, double *buf,
- size_t *rsize);
+ size_t bsize);
+OSSL_PARAM OSSL_PARAM_construct_double(const char *key, double *buf);
OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf,
- size_t bsize, size_t *rsize);
+ size_t bsize);
OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf,
- size_t bsize, size_t *rsize);
+ size_t bsize);
OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf,
- size_t bsize, size_t *rsize);
+ size_t bsize);
OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf,
- size_t bsize, size_t *rsize);
+ size_t bsize);
OSSL_PARAM OSSL_PARAM_construct_end(void);
int OSSL_PARAM_get_int(const OSSL_PARAM *p, int *val);
@@ -149,36 +99,35 @@ int OSSL_PARAM_get_int64(const OSSL_PARAM *p, int64_t *val);
int OSSL_PARAM_get_uint64(const OSSL_PARAM *p, uint64_t *val);
int OSSL_PARAM_get_size_t(const OSSL_PARAM *p, size_t *val);
-int OSSL_PARAM_set_int(const OSSL_PARAM *p, int val);
-int OSSL_PARAM_set_uint(const OSSL_PARAM *p, unsigned int val);
-int OSSL_PARAM_set_long(const OSSL_PARAM *p, long int val);
-int OSSL_PARAM_set_ulong(const OSSL_PARAM *p, unsigned long int val);
-int OSSL_PARAM_set_int32(const OSSL_PARAM *p, int32_t val);
-int OSSL_PARAM_set_uint32(const OSSL_PARAM *p, uint32_t val);
-int OSSL_PARAM_set_int64(const OSSL_PARAM *p, int64_t val);
-int OSSL_PARAM_set_uint64(const OSSL_PARAM *p, uint64_t val);
-int OSSL_PARAM_set_size_t(const OSSL_PARAM *p, size_t val);
+int OSSL_PARAM_set_int(OSSL_PARAM *p, int val);
+int OSSL_PARAM_set_uint(OSSL_PARAM *p, unsigned int val);
+int OSSL_PARAM_set_long(OSSL_PARAM *p, long int val);
+int OSSL_PARAM_set_ulong(OSSL_PARAM *p, unsigned long int val);
+int OSSL_PARAM_set_int32(OSSL_PARAM *p, int32_t val);
+int OSSL_PARAM_set_uint32(OSSL_PARAM *p, uint32_t val);
+int OSSL_PARAM_set_int64(OSSL_PARAM *p, int64_t val);
+int OSSL_PARAM_set_uint64(OSSL_PARAM *p, uint64_t val);
+int OSSL_PARAM_set_size_t(OSSL_PARAM *p, size_t val);
int OSSL_PARAM_get_double(const OSSL_PARAM *p, double *val);
-int OSSL_PARAM_set_double(const OSSL_PARAM *p, double val);
+int OSSL_PARAM_set_double(OSSL_PARAM *p, double val);
int OSSL_PARAM_get_BN(const OSSL_PARAM *p, BIGNUM **val);
-int OSSL_PARAM_set_BN(const OSSL_PARAM *p, const BIGNUM *val);
+int OSSL_PARAM_set_BN(OSSL_PARAM *p, const BIGNUM *val);
int OSSL_PARAM_get_utf8_string(const OSSL_PARAM *p, char **val, size_t max_len);
-int OSSL_PARAM_set_utf8_string(const OSSL_PARAM *p, const char *val);
+int OSSL_PARAM_set_utf8_string(OSSL_PARAM *p, const char *val);
int OSSL_PARAM_get_octet_string(const OSSL_PARAM *p, void **val, size_t max_len,
size_t *used_len);
-int OSSL_PARAM_set_octet_string(const OSSL_PARAM *p, const void *val,
- size_t len);
+int OSSL_PARAM_set_octet_string(OSSL_PARAM *p, const void *val, size_t len);
int OSSL_PARAM_get_utf8_ptr(const OSSL_PARAM *p, const char **val);
-int OSSL_PARAM_set_utf8_ptr(const OSSL_PARAM *p, const char *val);
+int OSSL_PARAM_set_utf8_ptr(OSSL_PARAM *p, const char *val);
int OSSL_PARAM_get_octet_ptr(const OSSL_PARAM *p, const void **val,
size_t *used_len);
-int OSSL_PARAM_set_octet_ptr(const OSSL_PARAM *p, const void *val,
+int OSSL_PARAM_set_octet_ptr(OSSL_PARAM *p, const void *val,
size_t used_len);
# ifdef __cplusplus
diff --git a/include/openssl/provider.h b/include/openssl/provider.h
index ce75ee9e14..c7f66645f7 100644
--- a/include/openssl/provider.h
+++ b/include/openssl/provider.h
@@ -21,8 +21,7 @@ OSSL_PROVIDER *OSSL_PROVIDER_load(OPENSSL_CTX *, const char *name);
int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov);
const OSSL_ITEM *OSSL_PROVIDER_get_param_types(const OSSL_PROVIDER *prov);
-int OSSL_PROVIDER_get_params(const OSSL_PROVIDER *prov,
- const OSSL_PARAM params[]);
+int OSSL_PROVIDER_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]);
/* Add a built in providers */
int OSSL_PROVIDER_add_builtin(OPENSSL_CTX *, const char *name,
diff --git a/providers/common/ciphers/aes.c b/providers/common/ciphers/aes.c
index 8d91ff4804..be769e83df 100644
--- a/providers/common/ciphers/aes.c
+++ b/providers/common/ciphers/aes.c
@@ -257,9 +257,9 @@ static int aes_cipher(void *vctx,
#define IMPLEMENT_new_params(lcmode, UCMODE) \
static OSSL_OP_cipher_get_params_fn aes_##lcmode##_get_params; \
- static int aes_##lcmode##_get_params(const OSSL_PARAM params[]) \
+ static int aes_##lcmode##_get_params(OSSL_PARAM params[]) \
{ \
- const OSSL_PARAM *p; \
+ OSSL_PARAM *p; \
\
p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_MODE); \
if (p != NULL && !OSSL_PARAM_set_int(p, EVP_CIPH_##UCMODE##_MODE)) \
@@ -375,10 +375,10 @@ static size_t block_size_1(void)
return 1;
}
-static int aes_ctx_get_params(void *vctx, const OSSL_PARAM params[])
+static int aes_ctx_get_params(void *vctx, OSSL_PARAM params[])
{
PROV_AES_KEY *ctx = (PROV_AES_KEY *)vctx;
- const OSSL_PARAM *p;
+ OSSL_PARAM *p;
p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_PADDING);
if (p != NULL && !OSSL_PARAM_set_int(p, ctx->pad)) {
@@ -394,7 +394,7 @@ static int aes_ctx_set_params(void *vctx, const OSSL_PARAM params[])
PROV_AES_KEY *ctx = (PROV_AES_KEY *)vctx;
const OSSL_PARAM *p;
- p = OSSL_PARAM_locate(params, OSSL_CIPHER_PARAM_PADDING);
+ p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_PADDING);
if (p != NULL) {
int pad;
diff --git a/providers/common/digests/sha2_prov.c b/providers/common/digests/sha2_prov.c
index 547d1bcab6..0e49ae679c 100644
--- a/providers/common/digests/sha2_prov.c
+++ b/providers/common/digests/sha2_prov.c
@@ -26,7 +26,7 @@ static int sha1_set_params(void *vctx, const OSSL_PARAM params[])
SHA_CTX *ctx = (SHA_CTX *)vctx;
if (ctx != NULL && params != NULL) {
- p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_SSL3_MS);
+ p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_SSL3_MS);
if (p != NULL && p->data_type == OSSL_PARAM_OCTET_STRING)
return sha1_ctrl(ctx, EVP_CTRL_SSL3_MASTER_SECRET, p->data_size,
p->data);
diff --git a/providers/common/digests/sha3_prov.c b/providers/common/digests/sha3_prov.c
index 7b898b6c94..278ddfb855 100644
--- a/providers/common/digests/sha3_prov.c
+++ b/providers/common/digests/sha3_prov.c
@@ -246,7 +246,7 @@ static int shake_set_params(void *vctx, const OSSL_PARAM params[])
KECCAK1600_CTX *ctx = (KECCAK1600_CTX *)vctx;
if (ctx != NULL && params != NULL) {
- p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_XOFLEN);
+ p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_XOFLEN);
if (p != NULL && !OSSL_PARAM_get_size_t(p, &ctx->md_size))
return 0;
return 1;
diff --git a/providers/default/defltprov.c b/providers/default/defltprov.c
index b9c8c36ef0..76ef2bcf9a 100644
--- a/providers/default/defltprov.c
+++ b/providers/default/defltprov.c
@@ -32,10 +32,9 @@ static const OSSL_ITEM *deflt_get_param_types(const OSSL_PROVIDER *prov)
return deflt_param_types;
}
-static int deflt_get_params(const OSSL_PROVIDER *prov,
- const OSSL_PARAM params[])
+static int deflt_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[])
{
- const OSSL_PARAM *p;
+ OSSL_PARAM *p;
p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_NAME);
if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, "OpenSSL Default Provider"))
diff --git a/providers/default/digests/md5_sha1_prov.c b/providers/default/digests/md5_sha1_prov.c
index e6091bd80f..490134e7eb 100644
--- a/providers/default/digests/md5_sha1_prov.c
+++ b/providers/default/digests/md5_sha1_prov.c
@@ -26,7 +26,7 @@ static int md5_sha1_set_params(void *vctx, const OSSL_PARAM params[])
MD5_SHA1_CTX *ctx = (MD5_SHA1_CTX *)vctx;
if (ctx != NULL && params != NULL) {
- p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_SSL3_MS);
+ p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_SSL3_MS);
if (p != NULL && p->data_type == OSSL_PARAM_OCTET_STRING)
return md5_sha1_ctrl(ctx, EVP_CTRL_SSL3_MASTER_SECRET, p->data_size,
p->data);
diff --git a/providers/fips/fipsprov.c b/providers/fips/fipsprov.c
index 61729e5817..78e30266c5 100644
--- a/providers/fips/fipsprov.c
+++ b/providers/fips/fipsprov.c
@@ -127,10 +127,9 @@ static const OSSL_ITEM *fips_get_param_types(const OSSL_PROVIDER *prov)
return fips_param_types;
}
-static int fips_get_params(const OSSL_PROVIDER *prov,
- const OSSL_PARAM params[])
+static int fips_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[])
{
- const OSSL_PARAM *p;
+ OSSL_PARAM *p;
p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_NAME);
if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, "OpenSSL FIPS Provider"))
diff --git a/providers/legacy/digests/mdc2_prov.c b/providers/legacy/digests/mdc2_prov.c
index 75d9398c7d..31e95cb391 100644
--- a/providers/legacy/digests/mdc2_prov.c
+++ b/providers/legacy/digests/mdc2_prov.c
@@ -23,7 +23,7 @@ static int mdc2_set_params(void *vctx, const OSSL_PARAM params[])
MDC2_CTX *ctx = (MDC2_CTX *)vctx;
if (ctx != NULL && params != NULL) {
- p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_PAD_TYPE);
+ p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_PAD_TYPE);
if (p != NULL && !OSSL_PARAM_get_int(p, &ctx->pad_type))
return 0;
return 1;
diff --git a/providers/legacy/legacyprov.c b/providers/legacy/legacyprov.c
index 9b5533708f..0be58d8e31 100644
--- a/providers/legacy/legacyprov.c
+++ b/providers/legacy/legacyprov.c
@@ -32,10 +32,9 @@ static const OSSL_ITEM *legacy_get_param_types(const OSSL_PROVIDER *prov)
return legacy_param_types;
}
-static int legacy_get_params(const OSSL_PROVIDER *prov,
- const OSSL_PARAM params[])
+static int legacy_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[])
{
- const OSSL_PARAM *p;
+ OSSL_PARAM *p;
p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_NAME);
if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, "OpenSSL Legacy Provider"))
diff --git a/ssl/s3_enc.c b/ssl/s3_enc.c
index 6c3b711072..3edbae284e 100644
--- a/ssl/s3_enc.c
+++ b/ssl/s3_enc.c
@@ -417,8 +417,7 @@ void ssl3_digest_master_key_set_params(const SSL_SESSION *session,
int n = 0;
params[n++] = OSSL_PARAM_construct_octet_string(OSSL_DIGEST_PARAM_SSL3_MS,
(void *)session->master_key,
- session->master_key_length,
- NULL);
+ session->master_key_length);
params[n++] = OSSL_PARAM_construct_end();
}
diff --git a/test/mdc2test.c b/test/mdc2test.c
index 418a2566de..5b54f1038b 100644
--- a/test/mdc2test.c
+++ b/test/mdc2test.c
@@ -48,7 +48,7 @@ static int test_mdc2(void)
OSSL_PARAM params[2];
params[i++] = OSSL_PARAM_construct_int(OSSL_DIGEST_PARAM_PAD_TYPE,
- &pad_type, NULL),
+ &pad_type),
params[i++] = OSSL_PARAM_construct_end();
prov = OSSL_PROVIDER_load(NULL, "legacy");
diff --git a/test/p_test.c b/test/p_test.c
index 15213b6c1d..925e3b8948 100644
--- a/test/p_test.c
+++ b/test/p_test.c
@@ -47,10 +47,10 @@ static const OSSL_ITEM *p_get_param_types(void *_)
return p_param_types;
}
-static int p_get_params(void *vprov, const OSSL_PARAM params[])
+static int p_get_params(void *vprov, OSSL_PARAM params[])
{
const OSSL_PROVIDER *prov = vprov;
- const OSSL_PARAM *p = params;
+ OSSL_PARAM *p = params;
int ok = 1;
for (; ok && p->key != NULL; p++) {
@@ -58,18 +58,18 @@ static int p_get_params(void *vprov, const OSSL_PARAM params[])
static char *opensslv;
static char *provname;
static char *greeting;
- static const OSSL_PARAM counter_request[] = {
+ static OSSL_PARAM counter_request[] = {
/* Known libcrypto provided parameters */
{ "openssl-version", OSSL_PARAM_UTF8_PTR,
- &opensslv, sizeof(&opensslv), NULL },
+ &opensslv, sizeof(&opensslv), 0 },
{ "provider-name", OSSL_PARAM_UTF8_PTR,
- &provname, sizeof(&provname), NULL},
+ &provname, sizeof(&provname), 0},
/* This might be present, if there's such a configuration */
{ "greeting", OSSL_PARAM_UTF8_PTR,
- &greeting, sizeof(&greeting), NULL },
+ &greeting, sizeof(&greeting), 0 },
- { NULL, 0, NULL, 0, NULL }
+ { NULL, 0, NULL, 0, 0 }
};
char buf[256];
size_t buf_l;
@@ -90,7 +90,7 @@ static int p_get_params(void *vprov, const OSSL_PARAM params[])
sprintf(buf, "Howdy stranger...");
}
- *p->return_size = buf_l = strlen(buf) + 1;
+ p->return_size = buf_l = strlen(buf) + 1;
if (p->data_size >= buf_l)
strncpy(p->data, buf, buf_l);
else
diff --git a/test/params_api_test.c b/test/params_api_test.c
index df708da7e1..616035ecc4 100644
--- a/test/params_api_test.c
+++ b/test/params_api_test.c
@@ -58,8 +58,8 @@ static const struct {
0x89, 0x67, 0xf2, 0x68, 0x33, 0xa0, 0x14, 0xb0 } },
};
-static int test_param_type_extra(const OSSL_PARAM *param,
- const unsigned char *cmp, size_t width)
+static int test_param_type_extra(OSSL_PARAM *param, const unsigned char *cmp,
+ size_t width)
{
int32_t i32;
int64_t i64;
@@ -374,24 +374,22 @@ static int test_param_bignum(int n)
{
unsigned char buf[MAX_LEN], bnbuf[MAX_LEN];
const size_t len = raw_values[n].len;
- size_t bnsize;
BIGNUM *b = NULL, *c = NULL;
OSSL_PARAM param = OSSL_PARAM_DEFN("bn", OSSL_PARAM_UNSIGNED_INTEGER,
- NULL, 0, NULL);
+ NULL, 0);
int ret = 0;
param.data = bnbuf;
param.data_size = len;
- param.return_size = &bnsize;
le_copy(buf, raw_values[n].value, len);
if (!TEST_ptr(b = BN_lebin2bn(raw_values[n].value, (int)len, NULL)))
goto err;
if (!TEST_true(OSSL_PARAM_set_BN(&param, b))
- || !TEST_mem_eq(bnbuf, bnsize, buf, bnsize))
+ || !TEST_mem_eq(bnbuf, param.return_size, buf, param.return_size))
goto err;
- param.data_size = *param.return_size;
+ param.data_size = param.return_size;
if (!TEST_true(OSSL_PARAM_get_BN(&param, &c))
|| !TEST_BN_eq(b, c))
goto err;
@@ -413,23 +411,6 @@ static int test_param_real(void)
&& TEST_double_eq(p, 3.14159);
}
-/*
- * The tests are a bit special in that they are trying to do both sides
- * of the param passing. This means that the OSSL_PARAM structure needs to
- * be updated so that a get call matches size with the corresponding set call.
- * This is not a problem in normal usage because the owner of the OSSL_PARAM
- * "knows" the size of what it wants to put in and gets the size back via the
- * return_size pointer when it needs to get data out. That is, the owner
- * does not need to call these APIs since it has direct access.
- *
- * The result is that the tests need the locate call to return a non-const
- * pointer at times. Hence the cast here.
- */
-static OSSL_PARAM *locate(OSSL_PARAM *p, const char *name)
-{
- return (OSSL_PARAM *)OSSL_PARAM_locate(p, name);
-}
-
static int test_param_construct(void)
{
static const char *int_names[] = {
@@ -446,8 +427,7 @@ static int test_param_construct(void)
char buf[100], buf2[100], *bufp, *bufp2;
unsigned char ubuf[100];
void *vp, *vpn = NULL, *vp2;
- OSSL_PARAM *p;
- const OSSL_PARAM *cp;
+ OSSL_PARAM *cp;
int i, n = 0, ret = 0;
unsigned int u;
long int l;
@@ -456,27 +436,25 @@ static int test_param_construct(void)
uint32_t u32;
int64_t i64;
uint64_t u64;
- size_t j, k, s, sz;
+ size_t j, k, s;
double d, d2;
BIGNUM *bn = NULL, *bn2 = NULL;
- params[n++] = OSSL_PARAM_construct_int("int", &i, &sz);
- params[n++] = OSSL_PARAM_construct_uint("uint", &u, &sz);
- params[n++] = OSSL_PARAM_construct_long("long", &l, &sz);
- params[n++] = OSSL_PARAM_construct_ulong("ulong", &ul, &sz);
- params[n++] = OSSL_PARAM_construct_int32("int32", &i32, &sz);
- params[n++] = OSSL_PARAM_construct_int64("int64", &i64, &sz);
- params[n++] = OSSL_PARAM_construct_uint32("uint32", &u32, &sz);
- params[n++] = OSSL_PARAM_construct_uint64("uint64", &u64, &sz);
- params[n++] = OSSL_PARAM_construct_size_t("size_t", &s, &sz);
- params[n++] = OSSL_PARAM_construct_double("double", &d, &sz);
- params[n++] = OSSL_PARAM_construct_BN("bignum", ubuf, sizeof(ubuf), &sz);
- params[n++] = OSSL_PARAM_construct_utf8_string("utf8str", buf, sizeof(buf),
- &sz);
- params[n++] = OSSL_PARAM_construct_octet_string("octstr", buf, sizeof(buf),
- &sz);
- params[n++] = OSSL_PARAM_construct_utf8_ptr("utf8ptr", &bufp, 0, &sz);
- params[n++] = OSSL_PARAM_construct_octet_ptr("octptr", &vp, 0, &sz);
+ params[n++] = OSSL_PARAM_construct_int("int", &i);
+ params[n++] = OSSL_PARAM_construct_uint("uint", &u);
+ params[n++] = OSSL_PARAM_construct_long("long", &l);
+ params[n++] = OSSL_PARAM_construct_ulong("ulong", &ul);
+ params[n++] = OSSL_PARAM_construct_int32("int32", &i32);
+ params[n++] = OSSL_PARAM_construct_int64("int64", &i64);
+ params[n++] = OSSL_PARAM_construct_uint32("uint32", &u32);
+ params[n++] = OSSL_PARAM_construct_uint64("uint64", &u64);
+ params[n++] = OSSL_PARAM_construct_size_t("size_t", &s);
+ params[n++] = OSSL_PARAM_construct_double("double", &d);
+ params[n++] = OSSL_PARAM_construct_BN("bignum", ubuf, sizeof(ubuf));
+ params[n++] = OSSL_PARAM_construct_utf8_string("utf8str", buf, sizeof(buf));
+ params[n++] = OSSL_PARAM_construct_octet_string("octstr", buf, sizeof(buf));
+ params[n++] = OSSL_PARAM_construct_utf8_ptr("utf8ptr", &bufp, 0);
+ params[n++] = OSSL_PARAM_construct_octet_ptr("octptr", &vp, 0);
params[n] = OSSL_PARAM_construct_end();
/* Search failure */
@@ -488,7 +466,7 @@ static int test_param_construct(void)
if (!TEST_ptr(cp = OSSL_PARAM_locate(params, int_names[j]))
|| !TEST_true(OSSL_PARAM_set_int32(cp, (int32_t)(3 + j)))
|| !TEST_true(OSSL_PARAM_get_int64(cp, &i64))
- || !TEST_size_t_eq(cp->data_size, sz)
+ || !TEST_size_t_eq(cp->data_size, cp->return_size)
|| !TEST_size_t_eq((size_t)i64, 3 + j)) {
TEST_note("iteration %zu var %s", j + 1, int_names[j]);
goto err;
@@ -499,7 +477,7 @@ static int test_param_construct(void)
if (!TEST_ptr(cp = OSSL_PARAM_locate(params, uint_names[j]))
|| !TEST_true(OSSL_PARAM_set_uint32(cp, (uint32_t)(3 + j)))
|| !TEST_true(OSSL_PARAM_get_uint64(cp, &u64))
- || !TEST_size_t_eq(cp->data_size, sz)
+ || !TEST_size_t_eq(cp->data_size, cp->return_size)
|| !TEST_size_t_eq((size_t)u64, 3 + j)) {
TEST_note("iteration %zu var %s", j + 1, uint_names[j]);
goto err;
@@ -509,14 +487,14 @@ static int test_param_construct(void)
if (!TEST_ptr(cp = OSSL_PARAM_locate(params, "double"))
|| !TEST_true(OSSL_PARAM_set_double(cp, 3.14))
|| !TEST_true(OSSL_PARAM_get_double(cp, &d2))
- || !TEST_size_t_eq(sz, sizeof(double))
+ || !TEST_size_t_eq(cp->return_size, sizeof(double))
|| !TEST_double_eq(d, d2))
goto err;
/* UTF8 string */
bufp = NULL;
if (!TEST_ptr(cp = OSSL_PARAM_locate(params, "utf8str"))
|| !TEST_true(OSSL_PARAM_set_utf8_string(cp, "abcdef"))
- || !TEST_size_t_eq(sz, sizeof("abcdef"))
+ || !TEST_size_t_eq(cp->return_size, sizeof("abcdef"))
|| !TEST_true(OSSL_PARAM_get_utf8_string(cp, &bufp, 0))
|| !TEST_str_eq(bufp, "abcdef"))
goto err;
@@ -527,56 +505,54 @@ static int test_param_construct(void)
goto err;
/* UTF8 pointer */
bufp = buf;
- sz = 0;
if (!TEST_ptr(cp = OSSL_PARAM_locate(params, "utf8ptr"))
|| !TEST_true(OSSL_PARAM_set_utf8_ptr(cp, "tuvwxyz"))
- || !TEST_size_t_eq(sz, sizeof("tuvwxyz"))
+ || !TEST_size_t_eq(cp->return_size, sizeof("tuvwxyz"))
|| !TEST_str_eq(bufp, "tuvwxyz")
|| !TEST_true(OSSL_PARAM_get_utf8_ptr(cp, (const char **)&bufp2))
|| !TEST_ptr_eq(bufp2, bufp))
goto err;
/* OCTET string */
- if (!TEST_ptr(p = locate(params, "octstr"))
- || !TEST_true(OSSL_PARAM_set_octet_string(p, "abcdefghi",
+ if (!TEST_ptr(cp = OSSL_PARAM_locate(params, "octstr"))
+ || !TEST_true(OSSL_PARAM_set_octet_string(cp, "abcdefghi",
sizeof("abcdefghi")))
- || !TEST_size_t_eq(sz, sizeof("abcdefghi")))
+ || !TEST_size_t_eq(cp->return_size, sizeof("abcdefghi")))
goto err;
/* Match the return size to avoid trailing garbage bytes */
- p->data_size = *p->return_size;
- if (!TEST_true(OSSL_PARAM_get_octet_string(p, &vpn, 0, &s))
+ cp->data_size = cp->return_size;
+ if (!TEST_true(OSSL_PARAM_get_octet_string(cp, &vpn, 0, &s))
|| !TEST_size_t_eq(s, sizeof("abcdefghi"))
|| !TEST_mem_eq(vpn, sizeof("abcdefghi"),
"abcdefghi", sizeof("abcdefghi")))
goto err;
vp = buf2;
- if (!TEST_true(OSSL_PARAM_get_octet_string(p, &vp, sizeof(buf2), &s))
+ if (!TEST_true(OSSL_PARAM_get_octet_string(cp, &vp, sizeof(buf2), &s))
|| !TEST_size_t_eq(s, sizeof("abcdefghi"))
|| !TEST_mem_eq(vp, sizeof("abcdefghi"),
"abcdefghi", sizeof("abcdefghi")))
goto err;
/* OCTET pointer */
vp = &l;
- sz = 0;
- if (!TEST_ptr(p = locate(params, "octptr"))
- || !TEST_true(OSSL_PARAM_set_octet_ptr(p, &ul, sizeof(ul)))
- || !TEST_size_t_eq(sz, sizeof(ul))
+ if (!TEST_ptr(cp = OSSL_PARAM_locate(params, "octptr"))
+ || !TEST_true(OSSL_PARAM_set_octet_ptr(cp, &ul, sizeof(ul)))
+ || !TEST_size_t_eq(cp->return_size, sizeof(ul))
|| !TEST_ptr_eq(vp, &ul))
goto err;
/* Match the return size to avoid trailing garbage bytes */
- p->data_size = *p->return_size;
- if (!TEST_true(OSSL_PARAM_get_octet_ptr(p, (const void **)&vp2, &k))
+ cp->data_size = cp->return_size;
+ if (!TEST_true(OSSL_PARAM_get_octet_ptr(cp, (const void **)&vp2, &k))
|| !TEST_size_t_eq(k, sizeof(ul))
|| !TEST_ptr_eq(vp2, vp))
goto err;
/* BIGNUM */
- if (!TEST_ptr(p = locate(params, "bignum"))
+ if (!TEST_ptr(cp = OSSL_PARAM_locate(params, "bignum"))
|| !TEST_ptr(bn = BN_lebin2bn(bn_val, (int)sizeof(bn_val), NULL))
- || !TEST_true(OSSL_PARAM_set_BN(p, bn))
- || !TEST_size_t_eq(sz, sizeof(bn_val)))
+ || !TEST_true(OSSL_PARAM_set_BN(cp, bn))
+ || !TEST_size_t_eq(cp->return_size, sizeof(bn_val)))
goto err;
/* Match the return size to avoid trailing garbage bytes */
- p->data_size = *p->return_size;
- if(!TEST_true(OSSL_PARAM_get_BN(p, &bn2))
+ cp->data_size = cp->return_size;
+ if(!TEST_true(OSSL_PARAM_get_BN(cp, &bn2))
|| !TEST_BN_eq(bn, bn2))
goto err;
ret = 1;
diff --git a/test/params_conversion_test.c b/test/params_conversion_test.c
index 9db5bd8b9b..d6490833a9 100644
--- a/test/params_conversion_test.c
+++ b/test/params_conversion_test.c
@@ -20,7 +20,7 @@
# endif
typedef struct {
- const OSSL_PARAM *param;
+ OSSL_PARAM *param;
int32_t i32;
int64_t i64;
uint32_t u32;
@@ -39,7 +39,7 @@ static int param_conversion_load_stanza(PARAM_CONVERSION *pc, const STANZA *s)
static uint32_t datum_u32, ref_u32;
static uint64_t datum_u64, ref_u64;
static double datum_d, ref_d;
- static const OSSL_PARAM params[] = {
+ static OSSL_PARAM params[] = {
OSSL_PARAM_int32("int32", &datum_i32),
OSSL_PARAM_int64("int64", &datum_i64),
OSSL_PARAM_uint32("uint32", &datum_u32),
diff --git a/test/params_test.c b/test/params_test.c
index aae91f1f84..64fd4b828e 100644
--- a/test/params_test.c
+++ b/test/params_test.c
@@ -152,40 +152,35 @@ static int raw_set_params(void *vobj, const OSSL_PARAM *params)
return 1;
}
-static int raw_get_params(void *vobj, const OSSL_PARAM *params)
+static int raw_get_params(void *vobj, OSSL_PARAM *params)
{
struct object_st *obj = vobj;
for (; params->key != NULL; params++)
if (strcmp(params->key, "p1") == 0) {
- if (params->return_size != NULL)
- *params->return_size = sizeof(obj->p1);
+ params->return_size = sizeof(obj->p1);
*(int *)params->data = obj->p1;
} else if (strcmp(params->key, "p2") == 0) {
- if (params->return_size != NULL)
- *params->return_size = sizeof(obj->p2);
+ params->return_size = sizeof(obj->p2);
*(double *)params->data = obj->p2;
} else if (strcmp(params->key, "p3") == 0) {
size_t bytes = BN_num_bytes(obj->p3);
- if (params->return_size != NULL)
- *params->return_size = bytes;
+ params->return_size = bytes;
if (!TEST_size_t_ge(params->data_size, bytes))
return 0;
BN_bn2nativepad(obj->p3, params->data, bytes);
} else if (strcmp(params->key, "p4") == 0) {
size_t bytes = strlen(obj->p4) + 1;
- if (params->return_size != NULL)
- *params->return_size = bytes;
+ params->return_size = bytes;
if (!TEST_size_t_ge(params->data_size, bytes))
return 0;
strcpy(params->data, obj->p4);
} else if (strcmp(params->key, "p5") == 0) {
size_t bytes = strlen(obj->p5) + 1;
- if (params->return_size != NULL)
- *params->return_size = bytes;
+ params->return_size = bytes;
if (!TEST_size_t_ge(params->data_size, bytes))
return 0;
strcpy(params->data, obj->p5);
@@ -198,8 +193,7 @@ static int raw_get_params(void *vobj, const OSSL_PARAM *params)
*/
size_t bytes = strlen(obj->p6) + 1;
- if (params->return_size != NULL)
- *params->return_size = bytes;
+ params->return_size = bytes;
*(const char **)params->data = obj->p6;
}
@@ -215,29 +209,29 @@ static int api_set_params(void *vobj, const OSSL_PARAM *params)
struct object_st *obj = vobj;
const OSSL_PARAM *p = NULL;
- if ((p = OSSL_PARAM_locate(params, "p1")) != NULL
+ if ((p = OSSL_PARAM_locate_const(params, "p1")) != NULL
&& !TEST_true(OSSL_PARAM_get_int(p, &obj->p1)))
return 0;
- if ((p = OSSL_PARAM_locate(params, "p2")) != NULL
+ if ((p = OSSL_PARAM_locate_const(params, "p2")) != NULL
&& !TEST_true(OSSL_PARAM_get_double(p, &obj->p2)))
return 0;
- if ((p = OSSL_PARAM_locate(params, "p3")) != NULL
+ if ((p = OSSL_PARAM_locate_const(params, "p3")) != NULL
&& !TEST_true(OSSL_PARAM_get_BN(p, &obj->p3)))
return 0;
- if ((p = OSSL_PARAM_locate(params, "p4")) != NULL) {
+ if ((p = OSSL_PARAM_locate_const(params, "p4")) != NULL) {
OPENSSL_free(obj->p4);
obj->p4 = NULL;
/* If the value pointer is NULL, we get it automatically allocated */
if (!TEST_true(OSSL_PARAM_get_utf8_string(p, &obj->p4, 0)))
return 0;
}
- if ((p = OSSL_PARAM_locate(params, "p5")) != NULL) {
+ if ((p = OSSL_PARAM_locate_const(params, "p5")) != NULL) {
char *p5_ptr = obj->p5;
if (!TEST_true(OSSL_PARAM_get_utf8_string(p, &p5_ptr, sizeof(obj->p5))))
return 0;
obj->p5_l = strlen(obj->p5) + 1;
}
- if ((p = OSSL_PARAM_locate(params, "p6")) != NULL) {
+ if ((p = OSSL_PARAM_locate_const(params, "p6")) != NULL) {
if (!TEST_true(OSSL_PARAM_get_utf8_ptr(p, &obj->p6)))
return 0;
obj->p6_l = strlen(obj->p6) + 1;
@@ -246,10 +240,10 @@ static int api_set_params(void *vobj, const OSSL_PARAM *params)
return 1;
}
-static int api_get_params(void *vobj, const OSSL_PARAM *params)
+static int api_get_params(void *vobj, OSSL_PARAM *params)
{
struct object_st *obj = vobj;
- const OSSL_PARAM *p = NULL;
+ OSSL_PARAM *p = NULL;
if ((p = OSSL_PARAM_locate(params, "p1")) != NULL
&& !TEST_true(OSSL_PARAM_set_int(p, obj->p1)))
@@ -279,7 +273,7 @@ static int api_get_params(void *vobj, const OSSL_PARAM *params)
*/
struct provider_dispatch_st {
int (*set_params)(void *obj, const OSSL_PARAM *params);
- int (*get_params)(void *obj, const OSSL_PARAM *params);
+ int (*get_params)(void *obj, OSSL_PARAM *params);
};
/* "raw" provider */
@@ -312,13 +306,9 @@ static BIGNUM *app_p3 = NULL; /* "p3" */
static unsigned char bignumbin[4096]; /* "p3" */
static size_t bignumbin_l; /* "p3" */
static char app_p4[256]; /* "p4" */
-static size_t app_p4_l; /* "p4" */
static char app_p5[256]; /* "p5" */
-static size_t app_p5_l; /* "p5" */
static const char *app_p6 = NULL; /* "p6" */
-static size_t app_p6_l; /* "p6" */
static unsigned char foo[1]; /* "foo" */
-static size_t foo_l; /* "foo" */
#define app_p1_init 17 /* A random number */
#define app_p2_init 47.11 /* Another random number */
@@ -348,12 +338,9 @@ static int init_app_variables(void)
return 0;
bignumbin_l = (size_t)l;
strcpy(app_p4, app_p4_init);
- app_p4_l = sizeof(app_p4_init);
strcpy(app_p5, app_p5_init);
- app_p5_l = sizeof(app_p5_init);
app_p6 = app_p6_init;
foo[0] = app_foo_init;
- foo_l = sizeof(app_foo_init);
return 1;
}
@@ -363,30 +350,26 @@ static int init_app_variables(void)
*/
/* An array of OSSL_PARAM, specific in the most raw manner possible */
-static const OSSL_PARAM static_raw_params[] = {
- { "p1", OSSL_PARAM_INTEGER, &app_p1, sizeof(app_p1), NULL },
- { "p3", OSSL_PARAM_UNSIGNED_INTEGER, &bignumbin, sizeof(bignumbin),
- &bignumbin_l },
- { "p4", OSSL_PARAM_UTF8_STRING, &app_p4, sizeof(app_p4), &app_p4_l },
- { "p5", OSSL_PARAM_UTF8_STRING, &app_p5, sizeof(app_p5), &app_p5_l },
+static OSSL_PARAM static_raw_params[] = {
+ { "p1", OSSL_PARAM_INTEGER, &app_p1, sizeof(app_p1), 0 },
+ { "p3", OSSL_PARAM_UNSIGNED_INTEGER, &bignumbin, sizeof(bignumbin), 0 },
+ { "p4", OSSL_PARAM_UTF8_STRING, &app_p4, sizeof(app_p4), 0 },
+ { "p5", OSSL_PARAM_UTF8_STRING, &app_p5, sizeof(app_p5), 0 },
/* sizeof(app_p6_init), because we know that's what we're using */
- { "p6", OSSL_PARAM_UTF8_PTR, &app_p6, sizeof(app_p6_init), &app_p6_l },
- { "foo", OSSL_PARAM_OCTET_STRING, &foo, sizeof(foo), &foo_l },
- { NULL, 0, NULL, 0, NULL }
+ { "p6", OSSL_PARAM_UTF8_PTR, &app_p6, sizeof(app_p6_init), 0 },
+ { "foo", OSSL_PARAM_OCTET_STRING, &foo, sizeof(foo), 0 },
+ { NULL, 0, NULL, 0, 0 }
};
/* The same array of OSSL_PARAM, specified with the macros from params.h */
-static const OSSL_PARAM static_api_params[] = {
+static OSSL_PARAM static_api_params[] = {
OSSL_PARAM_int("p1", &app_p1),
- OSSL_PARAM_SIZED_BN("p3", &bignumbin, sizeof(bignumbin), bignumbin_l),
- OSSL_PARAM_DEFN("p4", OSSL_PARAM_UTF8_STRING,
- &app_p4, sizeof(app_p4), &app_p4_l),
- OSSL_PARAM_DEFN("p5", OSSL_PARAM_UTF8_STRING,
- &app_p5, sizeof(app_p5), &app_p5_l),
+ OSSL_PARAM_BN("p3", &bignumbin, sizeof(bignumbin)),
+ OSSL_PARAM_DEFN("p4", OSSL_PARAM_UTF8_STRING, &app_p4, sizeof(app_p4)),
+ OSSL_PARAM_DEFN("p5", OSSL_PARAM_UTF8_STRING, &app_p5, sizeof(app_p5)),
/* sizeof(app_p6_init), because we know that's what we're using */
- OSSL_PARAM_DEFN("p6", OSSL_PARAM_UTF8_PTR,
- &app_p6, sizeof(app_p6_init), &app_p6_l),
- OSSL_PARAM_DEFN("foo", OSSL_PARAM_OCTET_STRING, &foo, sizeof(foo), &foo_l),
+ OSSL_PARAM_DEFN("p6", OSSL_PARAM_UTF8_PTR, &app_p6, sizeof(app_p6_init)),
+ OSSL_PARAM_DEFN("foo", OSSL_PARAM_OCTET_STRING, &foo, sizeof(foo)),
OSSL_PARAM_END
};
@@ -399,25 +382,23 @@ static OSSL_PARAM *construct_api_params(void)
size_t n = 0;
static OSSL_PARAM params[10];
- params[n++] = OSSL_PARAM_construct_int("p1", &app_p1, NULL);
- params[n++] = OSSL_PARAM_construct_BN("p3", bignumbin, sizeof(bignumbin),
- &bignumbin_l);
- params[n++] = OSSL_PARAM_construct_utf8_string("p4", app_p4, sizeof(app_p4),
- &app_p4_l);
+ params[n++] = OSSL_PARAM_construct_int("p1", &app_p1);
+ params[n++] = OSSL_PARAM_construct_BN("p3", bignumbin, sizeof(bignumbin));
+ params[n++] = OSSL_PARAM_construct_utf8_string("p4", app_p4,
+ sizeof(app_p4));
params[n++] = OSSL_PARAM_construct_utf8_string("p5", app_p5,
- sizeof(app_p5), &app_p5_l);
+ sizeof(app_p5));
/* sizeof(app_p6_init), because we know that's what we're using */
params[n++] = OSSL_PARAM_construct_utf8_ptr("p6", (char **)&app_p6,
- sizeof(app_p6_init), &app_p6_l);
- params[n++] = OSSL_PARAM_construct_octet_string("foo", &foo, sizeof(foo),
- &foo_l);
+ sizeof(app_p6_init));
+ params[n++] = OSSL_PARAM_construct_octet_string("foo", &foo, sizeof(foo));
params[n++] = OSSL_PARAM_construct_end();
return params;
}
struct param_owner_st {
- const OSSL_PARAM *static_params;
+ OSSL_PARAM *static_params;
OSSL_PARAM *(*constructed_params)(void);
};
@@ -452,12 +433,12 @@ static struct {
};
/* Generic tester of combinations of "providers" and params */
-static int test_case_variant(const OSSL_PARAM *params,
- const struct provider_dispatch_st *prov)
+static int test_case_variant(OSSL_PARAM *params, const struct provider_dispatch_st *prov)
{
BIGNUM *verify_p3 = NULL;
void *obj = NULL;
int errcnt = 0;
+ OSSL_PARAM *p;
/*
* Initialize
@@ -480,12 +461,15 @@ static int test_case_variant(const OSSL_PARAM *params,
|| !TEST_ptr(BN_native2bn(bignumbin, bignumbin_l, app_p3))
|| !TEST_BN_eq(app_p3, verify_p3) /* "provider" value */
|| !TEST_str_eq(app_p4, p4_init) /* "provider" value */
- || !TEST_size_t_eq(app_p5_l, sizeof(p5_init)) /* "provider" value */
+ || !TEST_ptr(p = OSSL_PARAM_locate(params, "p5"))
+ || !TEST_size_t_eq(p->return_size, sizeof(p5_init)) /* "provider" value */
|| !TEST_str_eq(app_p5, p5_init) /* "provider" value */
- || !TEST_size_t_eq(app_p6_l, sizeof(p6_init)) /* "provider" value */
+ || !TEST_ptr(p = OSSL_PARAM_locate(params, "p6"))
+ || !TEST_size_t_eq(p->return_size, sizeof(p6_init)) /* "provider" value */
|| !TEST_str_eq(app_p6, p6_init) /* "provider" value */
|| !TEST_char_eq(foo[0], app_foo_init) /* Should remain untouched */
- || !TEST_int_eq(foo_l, sizeof(app_foo_init)))
+ || !TEST_ptr(p = OSSL_PARAM_locate(params, "foo"))
+ || !TEST_int_eq(p->return_size, 0))
errcnt++;
/*
@@ -503,10 +487,7 @@ static int test_case_variant(const OSSL_PARAM *params,
|| !TEST_double_eq(sneakpeek->p2, p2_init) /* Should remain untouched */
|| !TEST_BN_eq(sneakpeek->p3, app_p3) /* app value set */
|| !TEST_str_eq(sneakpeek->p4, app_p4) /* app value set */
- || !TEST_size_t_eq(sneakpeek->p5_l, app_p5_l) /* app value set */
|| !TEST_str_eq(sneakpeek->p5, app_p5) /* app value set */
- || !TEST_size_t_eq(sneakpeek->p6_l,
- sizeof(app_p6_init)) /* app value set */
|| !TEST_str_eq(sneakpeek->p6, app_p6)) /* app value set */
errcnt++;
}
@@ -529,14 +510,17 @@ static int test_case_variant(const OSSL_PARAM *params,
|| !TEST_ptr(BN_native2bn(bignumbin, bignumbin_l, app_p3))
|| !TEST_BN_eq(app_p3, verify_p3) /* app value */
|| !TEST_str_eq(app_p4, app_p4_init) /* app value */
- || !TEST_size_t_eq(app_p5_l,
+ || !TEST_ptr(p = OSSL_PARAM_locate(params, "p5"))
+ || !TEST_size_t_eq(p->return_size,
sizeof(app_p5_init)) /* app value */
|| !TEST_str_eq(app_p5, app_p5_init) /* app value */
- || !TEST_size_t_eq(app_p6_l,
+ || !TEST_ptr(p = OSSL_PARAM_locate(params, "p6"))
+ || !TEST_size_t_eq(p->return_size,
sizeof(app_p6_init)) /* app value */
|| !TEST_str_eq(app_p6, app_p6_init) /* app value */
|| !TEST_char_eq(foo[0], app_foo_init) /* Should remain untouched */
- || !TEST_int_eq(foo_l, sizeof(app_foo_init)))
+ || !TEST_ptr(p = OSSL_PARAM_locate(params, "foo"))
+ || !TEST_int_eq(p->return_size, 0))
errcnt++;
fin:
diff --git a/test/provider_internal_test.c b/test/provider_internal_test.c
index 6123d6b4f8..aff858f323 100644
--- a/test/provider_internal_test.c
+++ b/test/provider_internal_test.c
@@ -15,10 +15,9 @@
extern OSSL_provider_init_fn PROVIDER_INIT_FUNCTION_NAME;
static char buf[256];
-static size_t buf_l = 0;
static OSSL_PARAM greeting_request[] = {
- { "greeting", OSSL_PARAM_UTF8_STRING, buf, sizeof(buf), &buf_l },
- { NULL, 0, NULL, 0, NULL }
+ { "greeting", OSSL_PARAM_UTF8_STRING, buf, sizeof(buf), 0 },
+ { NULL, 0, NULL, 0, 0 }
};
static int test_provider(OSSL_PROVIDER *prov, const char *expected_greeting)
diff --git a/test/provider_test.c b/test/provider_test.c
index c00f5ab4eb..acb9f2000e 100644
--- a/test/provider_test.c
+++ b/test/provider_test.c
@@ -14,10 +14,9 @@
extern OSSL_provider_init_fn PROVIDER_INIT_FUNCTION_NAME;
static char buf[256];
-static size_t buf_l = 0;
static OSSL_PARAM greeting_request[] = {
- { "greeting", OSSL_PARAM_UTF8_STRING, buf, sizeof(buf), &buf_l },
- { NULL, 0, NULL, 0, NULL }
+ { "greeting", OSSL_PARAM_UTF8_STRING, buf, sizeof(buf) },
+ { NULL, 0, NULL, 0, 0 }
};
static int test_provider(const char *name)
diff --git a/util/libcrypto.num b/util/libcrypto.num
index af6e2b96b4..766c735b2f 100644
--- a/util/libcrypto.num
+++ b/util/libcrypto.num
@@ -4832,3 +4832,4 @@ OPENSSL_CTX_get0_private_drbg 4776 3_0_0 EXIST::FUNCTION:
BN_CTX_new_ex 4777 3_0_0 EXIST::FUNCTION:
BN_CTX_secure_new_ex 4778 3_0_0 EXIST::FUNCTION:
OPENSSL_thread_stop_ex 4779 3_0_0 EXIST::FUNCTION:
+OSSL_PARAM_locate_const 4780 3_0_0 EXIST::FUNCTION:
diff --git a/util/private.num b/util/private.num
index 7f4bf907ea..fb5d0b2644 100644
--- a/util/private.num
+++ b/util/private.num
@@ -332,14 +332,15 @@ OSSL_PARAM_TYPE define
OSSL_PARAM_octet_ptr define
OSSL_PARAM_octet_string define
OSSL_PARAM_utf8_ptr define
+OSSL_PARAM_BN define
+OSSL_PARAM_TYPE generic
+OSSL_PARAM_construct_TYPE generic
+OSSL_PARAM_octet_string define
OSSL_PARAM_utf8_string define
-OSSL_PARAM_SIZED_BN define
-OSSL_PARAM_SIZED_TYPE define
-OSSL_PARAM_SIZED_octet_ptr define
-OSSL_PARAM_SIZED_octet_string define
-OSSL_PARAM_SIZED_utf8_ptr define
-OSSL_PARAM_SIZED_utf8_string define
+OSSL_PARAM_octet_ptr define
+OSSL_PARAM_get_TYPE generic
OSSL_PARAM_END define
+OSSL_PARAM_set_TYPE generic
PEM_FLAG_EAY_COMPATIBLE define
PEM_FLAG_ONLY_B64 define
PEM_FLAG_SECURE define