Browse Source

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)
master
Pauli 3 years ago
parent
commit
4e7991b497
33 changed files with 359 additions and 498 deletions
  1. +5
    -7
      crypto/evp/digest.c
  2. +97
    -110
      crypto/params.c
  3. +1
    -2
      crypto/provider.c
  4. +3
    -4
      crypto/provider_core.c
  5. +1
    -2
      doc/internal/man3/ossl_provider_new.pod
  6. +1
    -1
      doc/man3/EVP_DigestInit.pod
  7. +17
    -16
      doc/man3/OSSL_PARAM.pod
  8. +38
    -63
      doc/man3/OSSL_PARAM_int.pod
  9. +2
    -2
      doc/man3/OSSL_PROVIDER.pod
  10. +1
    -2
      include/internal/provider.h
  11. +1
    -1
      include/openssl/core.h
  12. +5
    -5
      include/openssl/core_numbers.h
  13. +1
    -1
      include/openssl/evp.h
  14. +51
    -102
      include/openssl/params.h
  15. +1
    -2
      include/openssl/provider.h
  16. +5
    -5
      providers/common/ciphers/aes.c
  17. +1
    -1
      providers/common/digests/sha2_prov.c
  18. +1
    -1
      providers/common/digests/sha3_prov.c
  19. +2
    -3
      providers/default/defltprov.c
  20. +1
    -1
      providers/default/digests/md5_sha1_prov.c
  21. +2
    -3
      providers/fips/fipsprov.c
  22. +1
    -1
      providers/legacy/digests/mdc2_prov.c
  23. +2
    -3
      providers/legacy/legacyprov.c
  24. +1
    -2
      ssl/s3_enc.c
  25. +1
    -1
      test/mdc2test.c
  26. +8
    -8
      test/p_test.c
  27. +43
    -67
      test/params_api_test.c
  28. +2
    -2
      test/params_conversion_test.c
  29. +52
    -68
      test/params_test.c
  30. +2
    -3
      test/provider_internal_test.c
  31. +2
    -3
      test/provider_test.c
  32. +1
    -0
      util/libcrypto.num
  33. +7
    -6
      util/private.num

+ 5
- 7
crypto/evp/digest.c View File

@ -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);
}


+ 97
- 110
crypto/params.c View File

@ -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)


+ 1
- 2
crypto/provider.c View File

@ -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);
}


+ 3
- 4
crypto/provider_core.c View File

@ -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);


+ 1
- 2
doc/internal/man3/ossl_provider_new.pod View File

@ -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);


+ 1
- 1
doc/man3/EVP_DigestInit.pod View File

@ -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);


+ 17
- 16
doc/man3/OSSL_PARAM.pod View File

@ -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 */
}


+ 38
- 63
doc/man3/OSSL_PARAM_int.pod View File

@ -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");


+ 2
- 2
doc/man3/OSSL_PROVIDER.pod View File

@ -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 }
};


+ 1
- 2
include/internal/provider.h View File

@ -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);


+ 1
- 1
include/openssl/core.h View File

@ -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 */


+ 5
- 5
include/openssl/core_numbers.h View File

@ -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[]))


+ 1
- 1
include/openssl/evp.h View File

@ -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);


+ 51
- 102
include/openssl/params.h View File

@ -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


+ 1
- 2
include/openssl/provider.h View File

@ -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,


+ 5
- 5
providers/common/ciphers/aes.c View File

@ -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;


+ 1
- 1
providers/common/digests/sha2_prov.c View File

@ -26,7 +26,7 @@ static int sha1_set_params(void *vctx, const OSSL_PARAM params[])
SHA_CTX *ctx = (SHA_CTX *)vctx;