#include "crypto/evp.h"
#include <openssl/cms.h>
#include <openssl/core_names.h>
-#include "internal/param_build.h"
+#include "openssl/param_build.h"
#include "internal/ffc.h"
/*
if (p == NULL || g == NULL)
return 0;
- ossl_param_bld_init(&tmpl);
- if (!ossl_param_bld_push_BN(&tmpl, OSSL_PKEY_PARAM_FFC_P, p)
- || !ossl_param_bld_push_BN(&tmpl, OSSL_PKEY_PARAM_FFC_G, g))
+ OSSL_PARAM_BLD_init(&tmpl);
+ if (!OSSL_PARAM_BLD_push_BN(&tmpl, OSSL_PKEY_PARAM_FFC_P, p)
+ || !OSSL_PARAM_BLD_push_BN(&tmpl, OSSL_PKEY_PARAM_FFC_G, g))
return 0;
if (q != NULL) {
- if (!ossl_param_bld_push_BN(&tmpl, OSSL_PKEY_PARAM_FFC_Q, q))
+ if (!OSSL_PARAM_BLD_push_BN(&tmpl, OSSL_PKEY_PARAM_FFC_Q, q))
return 0;
}
selection |= OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS;
if (pub_key != NULL) {
- if (!ossl_param_bld_push_BN(&tmpl, OSSL_PKEY_PARAM_PUB_KEY, pub_key))
+ if (!OSSL_PARAM_BLD_push_BN(&tmpl, OSSL_PKEY_PARAM_PUB_KEY, pub_key))
return 0;
selection |= OSSL_KEYMGMT_SELECT_PUBLIC_KEY;
}
if (priv_key != NULL) {
- if (!ossl_param_bld_push_BN(&tmpl, OSSL_PKEY_PARAM_PRIV_KEY,
+ if (!OSSL_PARAM_BLD_push_BN(&tmpl, OSSL_PKEY_PARAM_PRIV_KEY,
priv_key))
return 0;
selection |= OSSL_KEYMGMT_SELECT_PRIVATE_KEY;
}
- if ((params = ossl_param_bld_to_param(&tmpl)) == NULL)
+ if ((params = OSSL_PARAM_BLD_to_param(&tmpl)) == NULL)
return 0;
/* We export, the provider imports */
rv = evp_keymgmt_import(to_keymgmt, to_keydata, selection, params);
- ossl_param_bld_free(params);
+ OSSL_PARAM_BLD_free(params);
return rv;
}
#include "crypto/asn1.h"
#include "crypto/dsa.h"
#include "crypto/evp.h"
-#include "internal/param_build.h"
+#include "openssl/param_build.h"
#include "internal/ffc.h"
#include "dsa_local.h"
if (p == NULL || q == NULL || g == NULL)
return 0;
- ossl_param_bld_init(&tmpl);
- if (!ossl_param_bld_push_BN(&tmpl, OSSL_PKEY_PARAM_FFC_P, p)
- || !ossl_param_bld_push_BN(&tmpl, OSSL_PKEY_PARAM_FFC_Q, q)
- || !ossl_param_bld_push_BN(&tmpl, OSSL_PKEY_PARAM_FFC_G, g))
+ OSSL_PARAM_BLD_init(&tmpl);
+ if (!OSSL_PARAM_BLD_push_BN(&tmpl, OSSL_PKEY_PARAM_FFC_P, p)
+ || !OSSL_PARAM_BLD_push_BN(&tmpl, OSSL_PKEY_PARAM_FFC_Q, q)
+ || !OSSL_PARAM_BLD_push_BN(&tmpl, OSSL_PKEY_PARAM_FFC_G, g))
return 0;
selection |= OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS;
if (pub_key != NULL) {
- if (!ossl_param_bld_push_BN(&tmpl, OSSL_PKEY_PARAM_PUB_KEY,
+ if (!OSSL_PARAM_BLD_push_BN(&tmpl, OSSL_PKEY_PARAM_PUB_KEY,
pub_key))
return 0;
selection |= OSSL_KEYMGMT_SELECT_PUBLIC_KEY;
}
if (priv_key != NULL) {
- if (!ossl_param_bld_push_BN(&tmpl, OSSL_PKEY_PARAM_PRIV_KEY,
+ if (!OSSL_PARAM_BLD_push_BN(&tmpl, OSSL_PKEY_PARAM_PRIV_KEY,
priv_key))
return 0;
selection |= OSSL_KEYMGMT_SELECT_PRIVATE_KEY;
}
- if ((params = ossl_param_bld_to_param(&tmpl)) == NULL)
+ if ((params = OSSL_PARAM_BLD_to_param(&tmpl)) == NULL)
return 0;
/* We export, the provider imports */
rv = evp_keymgmt_import(to_keymgmt, to_keydata, selection, params);
- ossl_param_bld_free(params);
+ OSSL_PARAM_BLD_free(params);
return rv;
}
#include "crypto/asn1.h"
#include "crypto/evp.h"
#include <openssl/core_names.h>
-#include "internal/param_build.h"
+#include "openssl/param_build.h"
#include "ec_local.h"
#ifndef OPENSSL_NO_CMS
if ((curve_name = OBJ_nid2sn(curve_nid)) == NULL)
return 0;
- if (!ossl_param_bld_push_utf8_string(tmpl, OSSL_PKEY_PARAM_EC_NAME, curve_name, 0))
+ if (!OSSL_PARAM_BLD_push_utf8_string(tmpl, OSSL_PKEY_PARAM_EC_NAME, curve_name, 0))
return 0;
}
if (EC_KEY_get_method(eckey) != EC_KEY_OpenSSL())
return 0;
- ossl_param_bld_init(&tmpl);
+ OSSL_PARAM_BLD_init(&tmpl);
/* export the domain parameters */
if (!ecparams_to_params(eckey, &tmpl))
if ((pub_key_buflen = EC_POINT_point2buf(ecg, pub_point,
POINT_CONVERSION_COMPRESSED,
&pub_key_buf, NULL)) == 0
- || !ossl_param_bld_push_octet_string(&tmpl,
+ || !OSSL_PARAM_BLD_push_octet_string(&tmpl,
OSSL_PKEY_PARAM_PUB_KEY,
pub_key_buf,
pub_key_buflen))
goto err;
sz = (ecbits + 7 ) / 8;
- if (!ossl_param_bld_push_BN_pad(&tmpl,
+ if (!OSSL_PARAM_BLD_push_BN_pad(&tmpl,
OSSL_PKEY_PARAM_PRIV_KEY,
priv_key, sz))
goto err;
(EC_KEY_get_flags(eckey) & EC_FLAG_COFACTOR_ECDH) ? 1 : 0;
/* Export the ECDH_COFACTOR_MODE parameter */
- if (!ossl_param_bld_push_int(&tmpl,
+ if (!OSSL_PARAM_BLD_push_int(&tmpl,
OSSL_PKEY_PARAM_USE_COFACTOR_ECDH,
ecdh_cofactor_mode))
goto err;
selection |= OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS;
}
- params = ossl_param_bld_to_param(&tmpl);
+ params = OSSL_PARAM_BLD_to_param(&tmpl);
/* We export, the provider imports */
rv = evp_keymgmt_import(to_keymgmt, to_keydata, selection, params);
err:
- ossl_param_bld_free(params);
+ OSSL_PARAM_BLD_free(params);
OPENSSL_free(pub_key_buf);
return rv;
}
#include <openssl/ec.h>
#include <openssl/rand.h>
#include <openssl/core_names.h>
-#include "internal/param_build.h"
+#include "openssl/param_build.h"
#include "crypto/asn1.h"
#include "crypto/evp.h"
#include "crypto/ecx.h"
int selection = 0;
int rv = 0;
- ossl_param_bld_init(&tmpl);
+ OSSL_PARAM_BLD_init(&tmpl);
/* A key must at least have a public part */
- if (!ossl_param_bld_push_octet_string(&tmpl, OSSL_PKEY_PARAM_PUB_KEY,
+ if (!OSSL_PARAM_BLD_push_octet_string(&tmpl, OSSL_PKEY_PARAM_PUB_KEY,
key->pubkey, key->keylen))
goto err;
selection |= OSSL_KEYMGMT_SELECT_PUBLIC_KEY;
if (key->privkey != NULL) {
- if (!ossl_param_bld_push_octet_string(&tmpl,
+ if (!OSSL_PARAM_BLD_push_octet_string(&tmpl,
OSSL_PKEY_PARAM_PRIV_KEY,
key->privkey, key->keylen))
goto err;
selection |= OSSL_KEYMGMT_SELECT_PRIVATE_KEY;
}
- params = ossl_param_bld_to_param(&tmpl);
+ params = OSSL_PARAM_BLD_to_param(&tmpl);
/* We export, the provider imports */
rv = evp_keymgmt_import(to_keymgmt, to_keydata, selection, params);
err:
- ossl_param_bld_free(params);
+ OSSL_PARAM_BLD_free(params);
return rv;
}
#include <openssl/cryptoerr.h>
#include <openssl/params.h>
#include "internal/cryptlib.h"
-#include "internal/param_build.h"
+#include "openssl/param_build.h"
#define OSSL_PARAM_ALLOCATED_END 127
return 1;
}
-void ossl_param_bld_init(OSSL_PARAM_BLD *bld)
+void OSSL_PARAM_BLD_init(OSSL_PARAM_BLD *bld)
{
memset(bld, 0, sizeof(*bld));
}
-int ossl_param_bld_push_int(OSSL_PARAM_BLD *bld, const char *key, int num)
+int OSSL_PARAM_BLD_push_int(OSSL_PARAM_BLD *bld, const char *key, int num)
{
return param_push_num(bld, key, &num, sizeof(num), OSSL_PARAM_INTEGER);
}
-int ossl_param_bld_push_uint(OSSL_PARAM_BLD *bld, const char *key,
+int OSSL_PARAM_BLD_push_uint(OSSL_PARAM_BLD *bld, const char *key,
unsigned int num)
{
return param_push_num(bld, key, &num, sizeof(num),
OSSL_PARAM_UNSIGNED_INTEGER);
}
-int ossl_param_bld_push_long(OSSL_PARAM_BLD *bld, const char *key,
+int OSSL_PARAM_BLD_push_long(OSSL_PARAM_BLD *bld, const char *key,
long int num)
{
return param_push_num(bld, key, &num, sizeof(num), OSSL_PARAM_INTEGER);
}
-int ossl_param_bld_push_ulong(OSSL_PARAM_BLD *bld, const char *key,
+int OSSL_PARAM_BLD_push_ulong(OSSL_PARAM_BLD *bld, const char *key,
unsigned long int num)
{
return param_push_num(bld, key, &num, sizeof(num),
OSSL_PARAM_UNSIGNED_INTEGER);
}
-int ossl_param_bld_push_int32(OSSL_PARAM_BLD *bld, const char *key,
+int OSSL_PARAM_BLD_push_int32(OSSL_PARAM_BLD *bld, const char *key,
int32_t num)
{
return param_push_num(bld, key, &num, sizeof(num), OSSL_PARAM_INTEGER);
}
-int ossl_param_bld_push_uint32(OSSL_PARAM_BLD *bld, const char *key,
+int OSSL_PARAM_BLD_push_uint32(OSSL_PARAM_BLD *bld, const char *key,
uint32_t num)
{
return param_push_num(bld, key, &num, sizeof(num),
OSSL_PARAM_UNSIGNED_INTEGER);
}
-int ossl_param_bld_push_int64(OSSL_PARAM_BLD *bld, const char *key,
+int OSSL_PARAM_BLD_push_int64(OSSL_PARAM_BLD *bld, const char *key,
int64_t num)
{
return param_push_num(bld, key, &num, sizeof(num), OSSL_PARAM_INTEGER);
}
-int ossl_param_bld_push_uint64(OSSL_PARAM_BLD *bld, const char *key,
+int OSSL_PARAM_BLD_push_uint64(OSSL_PARAM_BLD *bld, const char *key,
uint64_t num)
{
return param_push_num(bld, key, &num, sizeof(num),
OSSL_PARAM_UNSIGNED_INTEGER);
}
-int ossl_param_bld_push_size_t(OSSL_PARAM_BLD *bld, const char *key,
+int OSSL_PARAM_BLD_push_size_t(OSSL_PARAM_BLD *bld, const char *key,
size_t num)
{
return param_push_num(bld, key, &num, sizeof(num),
OSSL_PARAM_UNSIGNED_INTEGER);
}
-int ossl_param_bld_push_double(OSSL_PARAM_BLD *bld, const char *key,
+int OSSL_PARAM_BLD_push_double(OSSL_PARAM_BLD *bld, const char *key,
double num)
{
return param_push_num(bld, key, &num, sizeof(num), OSSL_PARAM_REAL);
}
-int ossl_param_bld_push_BN(OSSL_PARAM_BLD *bld, const char *key,
+int OSSL_PARAM_BLD_push_BN(OSSL_PARAM_BLD *bld, const char *key,
const BIGNUM *bn)
{
- return ossl_param_bld_push_BN_pad(bld, key, bn,
+ return OSSL_PARAM_BLD_push_BN_pad(bld, key, bn,
bn == NULL ? 0 : BN_num_bytes(bn));
}
-int ossl_param_bld_push_BN_pad(OSSL_PARAM_BLD *bld, const char *key,
+int OSSL_PARAM_BLD_push_BN_pad(OSSL_PARAM_BLD *bld, const char *key,
const BIGNUM *bn, size_t sz)
{
int n, secure = 0;
return 1;
}
-int ossl_param_bld_push_utf8_string(OSSL_PARAM_BLD *bld, const char *key,
+int OSSL_PARAM_BLD_push_utf8_string(OSSL_PARAM_BLD *bld, const char *key,
const char *buf, size_t bsize)
{
OSSL_PARAM_BLD_DEF *pd;
return 1;
}
-int ossl_param_bld_push_utf8_ptr(OSSL_PARAM_BLD *bld, const char *key,
+int OSSL_PARAM_BLD_push_utf8_ptr(OSSL_PARAM_BLD *bld, const char *key,
char *buf, size_t bsize)
{
OSSL_PARAM_BLD_DEF *pd;
return 1;
}
-int ossl_param_bld_push_octet_string(OSSL_PARAM_BLD *bld, const char *key,
+int OSSL_PARAM_BLD_push_octet_string(OSSL_PARAM_BLD *bld, const char *key,
const void *buf, size_t bsize)
{
OSSL_PARAM_BLD_DEF *pd;
return 1;
}
-int ossl_param_bld_push_octet_ptr(OSSL_PARAM_BLD *bld, const char *key,
+int OSSL_PARAM_BLD_push_octet_ptr(OSSL_PARAM_BLD *bld, const char *key,
void *buf, size_t bsize)
{
OSSL_PARAM_BLD_DEF *pd;
return param + i;
}
-OSSL_PARAM *ossl_param_bld_to_param(OSSL_PARAM_BLD *bld)
+OSSL_PARAM *OSSL_PARAM_BLD_to_param(OSSL_PARAM_BLD *bld)
{
OSSL_PARAM_BLD_BLOCK *blk, *s = NULL;
OSSL_PARAM *params, *last;
return params;
}
-void ossl_param_bld_free(OSSL_PARAM *params)
+void OSSL_PARAM_BLD_free(OSSL_PARAM *params)
{
if (params != NULL) {
OSSL_PARAM *p;
#include <openssl/bn.h>
#include <openssl/cms.h>
#include <openssl/core_names.h>
-#include "internal/param_build.h"
+#include "openssl/param_build.h"
#include "crypto/asn1.h"
#include "crypto/evp.h"
#include "crypto/rsa.h"
if (n == NULL || e == NULL)
goto err;
- ossl_param_bld_init(&tmpl);
+ OSSL_PARAM_BLD_init(&tmpl);
/* |e| and |n| are always present */
- if (!ossl_param_bld_push_BN(&tmpl, OSSL_PKEY_PARAM_RSA_E, e))
+ if (!OSSL_PARAM_BLD_push_BN(&tmpl, OSSL_PKEY_PARAM_RSA_E, e))
goto err;
- if (!ossl_param_bld_push_BN(&tmpl, OSSL_PKEY_PARAM_RSA_N, n))
+ if (!OSSL_PARAM_BLD_push_BN(&tmpl, OSSL_PKEY_PARAM_RSA_N, n))
goto err;
selection |= OSSL_KEYMGMT_SELECT_PUBLIC_KEY;
<= OSSL_PARAM_BLD_MAX))
goto err;
- if (!ossl_param_bld_push_BN(&tmpl, OSSL_PKEY_PARAM_RSA_D, d))
+ if (!OSSL_PARAM_BLD_push_BN(&tmpl, OSSL_PKEY_PARAM_RSA_D, d))
goto err;
selection |= OSSL_KEYMGMT_SELECT_PRIVATE_KEY;
for (i = 0; i < numprimes; i++) {
const BIGNUM *num = sk_BIGNUM_const_value(primes, i);
- if (!ossl_param_bld_push_BN(&tmpl, OSSL_PKEY_PARAM_RSA_FACTOR,
+ if (!OSSL_PARAM_BLD_push_BN(&tmpl, OSSL_PKEY_PARAM_RSA_FACTOR,
num))
goto err;
}
for (i = 0; i < numexps; i++) {
const BIGNUM *num = sk_BIGNUM_const_value(exps, i);
- if (!ossl_param_bld_push_BN(&tmpl, OSSL_PKEY_PARAM_RSA_EXPONENT,
+ if (!OSSL_PARAM_BLD_push_BN(&tmpl, OSSL_PKEY_PARAM_RSA_EXPONENT,
num))
goto err;
}
for (i = 0; i < numcoeffs; i++) {
const BIGNUM *num = sk_BIGNUM_const_value(coeffs, i);
- if (!ossl_param_bld_push_BN(&tmpl, OSSL_PKEY_PARAM_RSA_COEFFICIENT,
+ if (!OSSL_PARAM_BLD_push_BN(&tmpl, OSSL_PKEY_PARAM_RSA_COEFFICIENT,
num))
goto err;
}
}
- if ((params = ossl_param_bld_to_param(&tmpl)) == NULL)
+ if ((params = OSSL_PARAM_BLD_to_param(&tmpl)) == NULL)
goto err;
/* We export, the provider imports */
sk_BIGNUM_const_free(primes);
sk_BIGNUM_const_free(exps);
sk_BIGNUM_const_free(coeffs);
- ossl_param_bld_free(params);
+ OSSL_PARAM_BLD_free(params);
return rv;
}
#include <openssl/evp.h>
#include "internal/cryptlib.h"
#include "internal/refcount.h"
-#include "internal/param_build.h"
+#include "openssl/param_build.h"
#include "crypto/bn.h"
#include "crypto/evp.h"
#include "crypto/rsa.h"
return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_KEYGEN,
EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP, 0, pubexp);
- ossl_param_bld_init(&tmpl);
- if (!ossl_param_bld_push_BN(&tmpl, OSSL_PKEY_PARAM_RSA_E, pubexp)
- || (params = ossl_param_bld_to_param(&tmpl)) == NULL)
+ OSSL_PARAM_BLD_init(&tmpl);
+ if (!OSSL_PARAM_BLD_push_BN(&tmpl, OSSL_PKEY_PARAM_RSA_E, pubexp)
+ || (params = OSSL_PARAM_BLD_to_param(&tmpl)) == NULL)
return 0;
ret = EVP_PKEY_CTX_set_params(ctx, params);
- ossl_param_bld_free(params);
+ OSSL_PARAM_BLD_free(params);
return ret;
}
+++ /dev/null
-=pod
-
-=head1 NAME
-
-ossl_param_bld_init, ossl_param_bld_to_param,
-ossl_param_bld_free, ossl_param_bld_push_int, ossl_param_bld_push_uint,
-ossl_param_bld_push_long, ossl_param_bld_push_ulong,
-ossl_param_bld_push_int32, ossl_param_bld_push_uint32,
-ossl_param_bld_push_int64, ossl_param_bld_push_uint64,
-ossl_param_bld_push_size_t, ossl_param_bld_push_double,
-ossl_param_bld_push_BN, ossl_param_bld_push_BN_pad,
-ossl_param_bld_push_utf8_string, ossl_param_bld_push_utf8_ptr,
-ossl_param_bld_push_octet_string, ossl_param_bld_push_octet_ptr
-- functions to assist in the creation of OSSL_PARAM arrays
-
-=head1 SYNOPSIS
-
-=for openssl generic
-
- #include "internal/params_build.h"
-
- #define OSSL_PARAM_BLD_MAX 10
- typedef struct { ... } OSSL_PARAM_BLD;
-
- void ossl_param_bld_init(OSSL_PARAM_BLD *bld);
- OSSL_PARAM *ossl_param_bld_to_param(OSSL_PARAM_BLD *bld);
- void ossl_param_bld_free(OSSL_PARAM *params);
-
- int ossl_param_bld_push_TYPE(OSSL_PARAM_BLD *bld, const char *key, TYPE val);
-
- int ossl_param_bld_push_BN(OSSL_PARAM_BLD *bld, const char *key,
- const BIGNUM *bn);
- int ossl_param_bld_push_BN_pad(OSSL_PARAM_BLD *bld, const char *key,
- const BIGNUM *bn, size_t sz);
-
- int ossl_param_bld_push_utf8_string(OSSL_PARAM_BLD *bld, const char *key,
- const char *buf, size_t bsize);
- int ossl_param_bld_push_utf8_ptr(OSSL_PARAM_BLD *bld, const char *key,
- char *buf, size_t bsize);
- int ossl_param_bld_push_octet_string(OSSL_PARAM_BLD *bld, const char *key,
- const void *buf, size_t bsize);
- int ossl_param_bld_push_octet_ptr(OSSL_PARAM_BLD *bld, const char *key,
- void *buf, size_t bsize);
-
-
-=head1 DESCRIPTION
-
-A collection of utility functions that simplify the creation of OSSL_PARAM
-arrays. The B<I<TYPE>> names are as per L<OSSL_PARAM_int(3)>.
-
-ossl_param_bld_init() initialises the OSSL_PARAM_BLD structure so that values
-can be added.
-Any existing values are cleared.
-
-ossl_param_bld_to_param() converts a built up OSSL_PARAM_BLD structure
-I<bld> into an allocated OSSL_PARAM array.
-The OSSL_PARAM array and all associated storage must be freed by calling
-ossl_param_bld_free() with the functions return value.
-
-ossl_param_bld_free() deallocates the memory allocated by
-ossl_param_bld_to_param().
-
-=begin comment
-
-POD is pretty good at recognising function names and making them appropriately
-bold... however, when part of the function name is variable, we have to help
-the processor along
-
-=end comment
-
-B<ossl_param_bld_push_I<TYPE>>() are a series of functions which will create
-OSSL_PARAM objects of the specified size and correct type for the I<val>
-argument.
-I<val> is stored by value and an expression or auto variable can be used.
-
-ossl_param_bld_push_BN() is a function that will create an OSSL_PARAM object
-that holds the specified BIGNUM I<bn>.
-If I<bn> is marked as being securely allocated, its OSSL_PARAM representation
-will also be securely allocated.
-The I<bn> argument is stored by reference and the underlying BIGNUM object
-must exist until after ossl_param_bld_to_param() has been called.
-
-ossl_param_bld_push_BN_pad() is a function that will create an OSSL_PARAM object
-that holds the specified BIGNUM I<bn>.
-The object will be padded to occupy exactly I<sz> bytes, if insufficient space
-is specified an error results.
-If I<bn> is marked as being securely allocated, its OSSL_PARAM representation
-will also be securely allocated.
-The I<bn> argument is stored by reference and the underlying BIGNUM object
-must exist until after ossl_param_bld_to_param() has been called.
-
-ossl_param_bld_push_utf8_string() is a function that will create an OSSL_PARAM
-object that references the UTF8 string specified by I<buf>.
-If the length of the string, I<bsize>, is zero then it will be calculated.
-The string that I<buf> points to is stored by reference and must remain in
-scope until after ossl_param_bld_to_param() has been called.
-
-ossl_param_bld_push_octet_string() is a function that will create an OSSL_PARAM
-object that references the octet string specified by I<buf> and <bsize>.
-The memory that I<buf> points to is stored by reference and must remain in
-scope until after ossl_param_bld_to_param() has been called.
-
-ossl_param_bld_push_utf8_ptr() is a function that will create an OSSL_PARAM
-object that references the UTF8 string specified by I<buf>.
-If the length of the string, I<bsize>, is zero then it will be calculated.
-The string I<buf> points to is stored by reference and must remain in
-scope until the OSSL_PARAM array is freed.
-
-ossl_param_bld_push_octet_ptr() is a function that will create an OSSL_PARAM
-object that references the octet string specified by I<buf>.
-The memory I<buf> points to is stored by reference and must remain in
-scope until the OSSL_PARAM array is freed.
-
-=head1 RETURN VALUES
-
-ossl_param_bld_to_param() returns the allocated OSSL_PARAM array, or NULL
-on error.
-
-All of the ossl_param_bld_push_TYPE functions return 1 on success and 0
-on error.
-
-=head1 NOTES
-
-The constant B<OSSL_PARAM_BLD_MAX> specifies the maximum number of parameters
-that can be added.
-Exceeding this will result in the push functions returning errors.
-
-The structure B<OSSL_PARAM_BLD> should be considered opaque and subject to
-change between versions.
-
-=head1 EXAMPLES
-
-Both examples creating an OSSL_PARAM array that contains an RSA key.
-For both, the predefined key variables are:
-
- BIGNUM *p, *q; /* both prime */
- BIGNUM *n; /* = p * q */
- unsigned int e; /* exponent, usually 65537 */
- BIGNUM *d; /* e^-1 */
-
-=head2 Example 1
-
-This example shows how to create an OSSL_PARAM array that contains an RSA
-private key.
-
- OSSL_PARAM_BLD bld;
- OSSL_PARAM *params;
-
- ossl_param_bld_init(&bld, &secure);
- if (!ossl_param_bld_push_BN(&bld, "p", p)
- || !ossl_param_bld_push_BN(&bld, "q", q)
- || !ossl_param_bld_push_uint(&bld, "e", e)
- || !ossl_param_bld_push_BN(&bld, "n", n)
- || !ossl_param_bld_push_BN(&bld, "d", d)
- || (params = ossl_param_bld_to_param(&bld)) == NULL)
- goto err;
- /* Use params */
- ...
- ossl_param_bld_free(params);
-
-=head2 Example 2
-
-This example shows how to create an OSSL_PARAM array that contains an RSA
-public key.
-
- OSSL_PARAM_BLD bld;
- OSSL_PARAM *params;
-
- ossl_param_bld_init(&bld, &secure);
- if (!ossl_param_bld_push_BN(&bld, "n", n)
- || !ossl_param_bld_push_BN(&bld, "d", d)
- || (params = ossl_param_bld_to_param(&bld)) == NULL)
- goto err;
- /* Use params */
- ...
- ossl_param_bld_free(params);
-
-=head1 SEE ALSO
-
-L<OSSL_PARAM_int(3)>, L<OSSL_PARAM(3)>
-
-=head1 HISTORY
-
-The functions described here were all added in OpenSSL 3.0.
-
-=head1 COPYRIGHT
-
-Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
-
-Licensed under the Apache License 2.0 (the "License"). You may not use
-this file except in compliance with the License. You can obtain a copy
-in the file LICENSE in the source distribution or at
-L<https://www.openssl.org/source/license.html>.
-
-=cut
--- /dev/null
+=pod
+
+=head1 NAME
+
+OSSL_PARAM_BLD_init, OSSL_PARAM_BLD_to_param,
+OSSL_PARAM_BLD_free, OSSL_PARAM_BLD_push_int, OSSL_PARAM_BLD_push_uint,
+OSSL_PARAM_BLD_push_long, OSSL_PARAM_BLD_push_ulong,
+OSSL_PARAM_BLD_push_int32, OSSL_PARAM_BLD_push_uint32,
+OSSL_PARAM_BLD_push_int64, OSSL_PARAM_BLD_push_uint64,
+OSSL_PARAM_BLD_push_size_t, OSSL_PARAM_BLD_push_double,
+OSSL_PARAM_BLD_push_BN, OSSL_PARAM_BLD_push_BN_pad,
+OSSL_PARAM_BLD_push_utf8_string, OSSL_PARAM_BLD_push_utf8_ptr,
+OSSL_PARAM_BLD_push_octet_string, OSSL_PARAM_BLD_push_octet_ptr
+- functions to assist in the creation of OSSL_PARAM arrays
+
+=head1 SYNOPSIS
+
+=for openssl generic
+
+ #include "openssl/param_build.h"
+
+ #define OSSL_PARAM_BLD_MAX 10
+ typedef struct { ... } OSSL_PARAM_BLD;
+
+ void OSSL_PARAM_BLD_init(OSSL_PARAM_BLD *bld);
+ OSSL_PARAM *OSSL_PARAM_BLD_to_param(OSSL_PARAM_BLD *bld);
+ void OSSL_PARAM_BLD_free(OSSL_PARAM *params);
+
+ int OSSL_PARAM_BLD_push_TYPE(OSSL_PARAM_BLD *bld, const char *key, TYPE val);
+
+ int OSSL_PARAM_BLD_push_BN(OSSL_PARAM_BLD *bld, const char *key,
+ const BIGNUM *bn);
+ int OSSL_PARAM_BLD_push_BN_pad(OSSL_PARAM_BLD *bld, const char *key,
+ const BIGNUM *bn, size_t sz);
+
+ int OSSL_PARAM_BLD_push_utf8_string(OSSL_PARAM_BLD *bld, const char *key,
+ const char *buf, size_t bsize);
+ int OSSL_PARAM_BLD_push_utf8_ptr(OSSL_PARAM_BLD *bld, const char *key,
+ char *buf, size_t bsize);
+ int OSSL_PARAM_BLD_push_octet_string(OSSL_PARAM_BLD *bld, const char *key,
+ const void *buf, size_t bsize);
+ int OSSL_PARAM_BLD_push_octet_ptr(OSSL_PARAM_BLD *bld, const char *key,
+ void *buf, size_t bsize);
+
+
+=head1 DESCRIPTION
+
+A collection of utility functions that simplify the creation of OSSL_PARAM
+arrays. The B<I<TYPE>> names are as per L<OSSL_PARAM_int(3)>.
+
+OSSL_PARAM_BLD_init() initialises the OSSL_PARAM_BLD structure so that values
+can be added.
+Any existing values are cleared.
+
+OSSL_PARAM_BLD_to_param() converts a built up OSSL_PARAM_BLD structure
+I<bld> into an allocated OSSL_PARAM array.
+The OSSL_PARAM array and all associated storage must be freed by calling
+OSSL_PARAM_BLD_free() with the functions return value.
+
+OSSL_PARAM_BLD_free() deallocates the memory allocated by
+OSSL_PARAM_BLD_to_param().
+
+=begin comment
+
+POD is pretty good at recognising function names and making them appropriately
+bold... however, when part of the function name is variable, we have to help
+the processor along
+
+=end comment
+
+B<OSSL_PARAM_BLD_push_I<TYPE>>() are a series of functions which will create
+OSSL_PARAM objects of the specified size and correct type for the I<val>
+argument.
+I<val> is stored by value and an expression or auto variable can be used.
+
+OSSL_PARAM_BLD_push_BN() is a function that will create an OSSL_PARAM object
+that holds the specified BIGNUM I<bn>.
+If I<bn> is marked as being securely allocated, its OSSL_PARAM representation
+will also be securely allocated.
+The I<bn> argument is stored by reference and the underlying BIGNUM object
+must exist until after OSSL_PARAM_BLD_to_param() has been called.
+
+OSSL_PARAM_BLD_push_BN_pad() is a function that will create an OSSL_PARAM object
+that holds the specified BIGNUM I<bn>.
+The object will be padded to occupy exactly I<sz> bytes, if insufficient space
+is specified an error results.
+If I<bn> is marked as being securely allocated, its OSSL_PARAM representation
+will also be securely allocated.
+The I<bn> argument is stored by reference and the underlying BIGNUM object
+must exist until after OSSL_PARAM_BLD_to_param() has been called.
+
+OSSL_PARAM_BLD_push_utf8_string() is a function that will create an OSSL_PARAM
+object that references the UTF8 string specified by I<buf>.
+If the length of the string, I<bsize>, is zero then it will be calculated.
+The string that I<buf> points to is stored by reference and must remain in
+scope until after OSSL_PARAM_BLD_to_param() has been called.
+
+OSSL_PARAM_BLD_push_octet_string() is a function that will create an OSSL_PARAM
+object that references the octet string specified by I<buf> and <bsize>.
+The memory that I<buf> points to is stored by reference and must remain in
+scope until after OSSL_PARAM_BLD_to_param() has been called.
+
+OSSL_PARAM_BLD_push_utf8_ptr() is a function that will create an OSSL_PARAM
+object that references the UTF8 string specified by I<buf>.
+If the length of the string, I<bsize>, is zero then it will be calculated.
+The string I<buf> points to is stored by reference and must remain in
+scope until the OSSL_PARAM array is freed.
+
+OSSL_PARAM_BLD_push_octet_ptr() is a function that will create an OSSL_PARAM
+object that references the octet string specified by I<buf>.
+The memory I<buf> points to is stored by reference and must remain in
+scope until the OSSL_PARAM array is freed.
+
+=head1 RETURN VALUES
+
+OSSL_PARAM_BLD_to_param() returns the allocated OSSL_PARAM array, or NULL
+on error.
+
+All of the OSSL_PARAM_BLD_push_TYPE functions return 1 on success and 0
+on error.
+
+=head1 NOTES
+
+The constant B<OSSL_PARAM_BLD_MAX> specifies the maximum number of parameters
+that can be added.
+Exceeding this will result in the push functions returning errors.
+The define used for this will always be at least 10 but otherwise no assumption
+should be made about it's specific value.
+
+The structure B<OSSL_PARAM_BLD> should be considered opaque and subject to
+change between versions.
+
+=head1 EXAMPLES
+
+Both examples creating an OSSL_PARAM array that contains an RSA key.
+For both, the predefined key variables are:
+
+ BIGNUM *p, *q; /* both prime */
+ BIGNUM *n; /* = p * q */
+ unsigned int e; /* exponent, usually 65537 */
+ BIGNUM *d; /* e^-1 */
+
+=head2 Example 1
+
+This example shows how to create an OSSL_PARAM array that contains an RSA
+private key.
+
+ OSSL_PARAM_BLD bld;
+ OSSL_PARAM *params;
+
+ OSSL_PARAM_BLD_init(&bld, &secure);
+ if (!OSSL_PARAM_BLD_push_BN(&bld, "p", p)
+ || !OSSL_PARAM_BLD_push_BN(&bld, "q", q)
+ || !OSSL_PARAM_BLD_push_uint(&bld, "e", e)
+ || !OSSL_PARAM_BLD_push_BN(&bld, "n", n)
+ || !OSSL_PARAM_BLD_push_BN(&bld, "d", d)
+ || (params = OSSL_PARAM_BLD_to_param(&bld)) == NULL)
+ goto err;
+ /* Use params */
+ ...
+ OSSL_PARAM_BLD_free(params);
+
+=head2 Example 2
+
+This example shows how to create an OSSL_PARAM array that contains an RSA
+public key.
+
+ OSSL_PARAM_BLD bld;
+ OSSL_PARAM *params;
+
+ OSSL_PARAM_BLD_init(&bld, &secure);
+ if (!OSSL_PARAM_BLD_push_BN(&bld, "n", n)
+ || !OSSL_PARAM_BLD_push_BN(&bld, "d", d)
+ || (params = OSSL_PARAM_BLD_to_param(&bld)) == NULL)
+ goto err;
+ /* Use params */
+ ...
+ OSSL_PARAM_BLD_free(params);
+
+=head1 SEE ALSO
+
+L<OSSL_PARAM_int(3)>, L<OSSL_PARAM(3)>
+
+=head1 HISTORY
+
+The functions described here were all added in OpenSSL 3.0.
+
+=head1 COPYRIGHT
+
+Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
+
+Licensed under the Apache License 2.0 (the "License"). You may not use
+this file except in compliance with the License. You can obtain a copy
+in the file LICENSE in the source distribution or at
+L<https://www.openssl.org/source/license.html>.
+
+=cut
+++ /dev/null
-/*
- * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <openssl/params.h>
-#include <openssl/types.h>
-
-#define OSSL_PARAM_BLD_MAX 25
-
-typedef struct {
- const char *key;
- int type;
- int secure;
- size_t size;
- size_t alloc_blocks;
- const BIGNUM *bn;
- const void *string;
- union {
- /*
- * These fields are never directly addressed, but their sizes are
- * imporant so that all native types can be copied here without overrun.
- */
- ossl_intmax_t i;
- ossl_uintmax_t u;
- double d;
- } num;
-} OSSL_PARAM_BLD_DEF;
-
-typedef struct {
- size_t curr;
- size_t total_blocks;
- size_t secure_blocks;
- OSSL_PARAM_BLD_DEF params[OSSL_PARAM_BLD_MAX];
-} OSSL_PARAM_BLD;
-
-void ossl_param_bld_init(OSSL_PARAM_BLD *bld);
-OSSL_PARAM *ossl_param_bld_to_param(OSSL_PARAM_BLD *bld);
-void ossl_param_bld_free(OSSL_PARAM *params);
-
-int ossl_param_bld_push_int(OSSL_PARAM_BLD *bld, const char *key, int val);
-int ossl_param_bld_push_uint(OSSL_PARAM_BLD *bld, const char *key,
- unsigned int val);
-int ossl_param_bld_push_long(OSSL_PARAM_BLD *bld, const char *key,
- long int val);
-int ossl_param_bld_push_ulong(OSSL_PARAM_BLD *bld, const char *key,
- unsigned long int val);
-int ossl_param_bld_push_int32(OSSL_PARAM_BLD *bld, const char *key,
- int32_t val);
-int ossl_param_bld_push_uint32(OSSL_PARAM_BLD *bld, const char *key,
- uint32_t val);
-int ossl_param_bld_push_int64(OSSL_PARAM_BLD *bld, const char *key,
- int64_t val);
-int ossl_param_bld_push_uint64(OSSL_PARAM_BLD *bld, const char *key,
- uint64_t val);
-int ossl_param_bld_push_size_t(OSSL_PARAM_BLD *bld, const char *key,
- size_t val);
-int ossl_param_bld_push_double(OSSL_PARAM_BLD *bld, const char *key,
- double val);
-int ossl_param_bld_push_BN(OSSL_PARAM_BLD *bld, const char *key,
- const BIGNUM *bn);
-int ossl_param_bld_push_BN_pad(OSSL_PARAM_BLD *bld, const char *key,
- const BIGNUM *bn, size_t sz);
-int ossl_param_bld_push_utf8_string(OSSL_PARAM_BLD *bld, const char *key,
- const char *buf, size_t bsize);
-int ossl_param_bld_push_utf8_ptr(OSSL_PARAM_BLD *bld, const char *key,
- char *buf, size_t bsize);
-int ossl_param_bld_push_octet_string(OSSL_PARAM_BLD *bld, const char *key,
- const void *buf, size_t bsize);
-int ossl_param_bld_push_octet_ptr(OSSL_PARAM_BLD *bld, const char *key,
- void *buf, size_t bsize);
--- /dev/null
+/*
+ * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <openssl/params.h>
+#include <openssl/types.h>
+
+#define OSSL_PARAM_BLD_MAX 25
+
+typedef struct {
+ const char *key;
+ int type;
+ int secure;
+ size_t size;
+ size_t alloc_blocks;
+ const BIGNUM *bn;
+ const void *string;
+ union {
+ /*
+ * These fields are never directly addressed, but their sizes are
+ * imporant so that all native types can be copied here without overrun.
+ */
+ ossl_intmax_t i;
+ ossl_uintmax_t u;
+ double d;
+ } num;
+} OSSL_PARAM_BLD_DEF;
+
+typedef struct {
+ size_t curr;
+ size_t total_blocks;
+ size_t secure_blocks;
+ OSSL_PARAM_BLD_DEF params[OSSL_PARAM_BLD_MAX];
+} OSSL_PARAM_BLD;
+
+void OSSL_PARAM_BLD_init(OSSL_PARAM_BLD *bld);
+OSSL_PARAM *OSSL_PARAM_BLD_to_param(OSSL_PARAM_BLD *bld);
+void OSSL_PARAM_BLD_free(OSSL_PARAM *params);
+
+int OSSL_PARAM_BLD_push_int(OSSL_PARAM_BLD *bld, const char *key, int val);
+int OSSL_PARAM_BLD_push_uint(OSSL_PARAM_BLD *bld, const char *key,
+ unsigned int val);
+int OSSL_PARAM_BLD_push_long(OSSL_PARAM_BLD *bld, const char *key,
+ long int val);
+int OSSL_PARAM_BLD_push_ulong(OSSL_PARAM_BLD *bld, const char *key,
+ unsigned long int val);
+int OSSL_PARAM_BLD_push_int32(OSSL_PARAM_BLD *bld, const char *key,
+ int32_t val);
+int OSSL_PARAM_BLD_push_uint32(OSSL_PARAM_BLD *bld, const char *key,
+ uint32_t val);
+int OSSL_PARAM_BLD_push_int64(OSSL_PARAM_BLD *bld, const char *key,
+ int64_t val);
+int OSSL_PARAM_BLD_push_uint64(OSSL_PARAM_BLD *bld, const char *key,
+ uint64_t val);
+int OSSL_PARAM_BLD_push_size_t(OSSL_PARAM_BLD *bld, const char *key,
+ size_t val);
+int OSSL_PARAM_BLD_push_double(OSSL_PARAM_BLD *bld, const char *key,
+ double val);
+int OSSL_PARAM_BLD_push_BN(OSSL_PARAM_BLD *bld, const char *key,
+ const BIGNUM *bn);
+int OSSL_PARAM_BLD_push_BN_pad(OSSL_PARAM_BLD *bld, const char *key,
+ const BIGNUM *bn, size_t sz);
+int OSSL_PARAM_BLD_push_utf8_string(OSSL_PARAM_BLD *bld, const char *key,
+ const char *buf, size_t bsize);
+int OSSL_PARAM_BLD_push_utf8_ptr(OSSL_PARAM_BLD *bld, const char *key,
+ char *buf, size_t bsize);
+int OSSL_PARAM_BLD_push_octet_string(OSSL_PARAM_BLD *bld, const char *key,
+ const void *buf, size_t bsize);
+int OSSL_PARAM_BLD_push_octet_ptr(OSSL_PARAM_BLD *bld, const char *key,
+ void *buf, size_t bsize);
#include "internal/cryptlib.h"
#include "internal/property.h"
#include "internal/nelem.h"
-#include "internal/param_build.h"
+#include "openssl/param_build.h"
#include "crypto/evp.h"
#include "prov/implementations.h"
#include "prov/provider_ctx.h"
|| !hextobn(dsa_priv_hex, &priv))
goto err;
- ossl_param_bld_init(&bld);
- if (!ossl_param_bld_push_BN(&bld, OSSL_PKEY_PARAM_FFC_P, p)
- || !ossl_param_bld_push_BN(&bld, OSSL_PKEY_PARAM_FFC_Q, q)
- || !ossl_param_bld_push_BN(&bld, OSSL_PKEY_PARAM_FFC_G, g)
- || !ossl_param_bld_push_BN(&bld, OSSL_PKEY_PARAM_PUB_KEY, pub)
- || !ossl_param_bld_push_BN(&bld, OSSL_PKEY_PARAM_PRIV_KEY, priv))
+ OSSL_PARAM_BLD_init(&bld);
+ if (!OSSL_PARAM_BLD_push_BN(&bld, OSSL_PKEY_PARAM_FFC_P, p)
+ || !OSSL_PARAM_BLD_push_BN(&bld, OSSL_PKEY_PARAM_FFC_Q, q)
+ || !OSSL_PARAM_BLD_push_BN(&bld, OSSL_PKEY_PARAM_FFC_G, g)
+ || !OSSL_PARAM_BLD_push_BN(&bld, OSSL_PKEY_PARAM_PUB_KEY, pub)
+ || !OSSL_PARAM_BLD_push_BN(&bld, OSSL_PKEY_PARAM_PRIV_KEY, priv))
goto err;
- params = ossl_param_bld_to_param(&bld);
+ params = OSSL_PARAM_BLD_to_param(&bld);
/* Create a EVP_PKEY_CTX to load the DSA key into */
kctx = EVP_PKEY_CTX_new_from_name(libctx, SN_dsa, "");
goto err;
/* set signature parameters */
- ossl_param_bld_init(&bld);
- if (!ossl_param_bld_push_utf8_string(&bld, OSSL_SIGNATURE_PARAM_DIGEST,
+ OSSL_PARAM_BLD_init(&bld);
+ if (!OSSL_PARAM_BLD_push_utf8_string(&bld, OSSL_SIGNATURE_PARAM_DIGEST,
SN_sha256,strlen(SN_sha256) + 1))
goto err;
- params_sig = ossl_param_bld_to_param(&bld);
+ params_sig = OSSL_PARAM_BLD_to_param(&bld);
if (EVP_PKEY_CTX_set_params(sctx, params_sig) <= 0)
goto err;
goto err;
ret = 1;
err:
- ossl_param_bld_free(params);
- ossl_param_bld_free(params_sig);
+ OSSL_PARAM_BLD_free(params);
+ OSSL_PARAM_BLD_free(params_sig);
BN_free(p);
BN_free(q);
BN_free(g);
|| !hextobin(dh_secret_exptd_hex, &kat_secret, &kat_secret_len))
goto err;
- ossl_param_bld_init(&bld);
- if (!ossl_param_bld_push_BN(&bld, OSSL_PKEY_PARAM_FFC_P, p)
- || !ossl_param_bld_push_BN(&bld, OSSL_PKEY_PARAM_FFC_Q, q)
- || !ossl_param_bld_push_BN(&bld, OSSL_PKEY_PARAM_FFC_G, g)
- || !ossl_param_bld_push_BN(&bld, OSSL_PKEY_PARAM_PUB_KEY, pub)
- || !ossl_param_bld_push_BN(&bld, OSSL_PKEY_PARAM_PRIV_KEY, priv))
+ OSSL_PARAM_BLD_init(&bld);
+ if (!OSSL_PARAM_BLD_push_BN(&bld, OSSL_PKEY_PARAM_FFC_P, p)
+ || !OSSL_PARAM_BLD_push_BN(&bld, OSSL_PKEY_PARAM_FFC_Q, q)
+ || !OSSL_PARAM_BLD_push_BN(&bld, OSSL_PKEY_PARAM_FFC_G, g)
+ || !OSSL_PARAM_BLD_push_BN(&bld, OSSL_PKEY_PARAM_PUB_KEY, pub)
+ || !OSSL_PARAM_BLD_push_BN(&bld, OSSL_PKEY_PARAM_PRIV_KEY, priv))
goto err;
- params = ossl_param_bld_to_param(&bld);
+ params = OSSL_PARAM_BLD_to_param(&bld);
- ossl_param_bld_init(&bld);
- if (!ossl_param_bld_push_BN(&bld, OSSL_PKEY_PARAM_FFC_P, p)
- || !ossl_param_bld_push_BN(&bld, OSSL_PKEY_PARAM_FFC_Q, q)
- || !ossl_param_bld_push_BN(&bld, OSSL_PKEY_PARAM_FFC_G, g)
- || !ossl_param_bld_push_BN(&bld, OSSL_PKEY_PARAM_PUB_KEY, pub_peer))
+ OSSL_PARAM_BLD_init(&bld);
+ if (!OSSL_PARAM_BLD_push_BN(&bld, OSSL_PKEY_PARAM_FFC_P, p)
+ || !OSSL_PARAM_BLD_push_BN(&bld, OSSL_PKEY_PARAM_FFC_Q, q)
+ || !OSSL_PARAM_BLD_push_BN(&bld, OSSL_PKEY_PARAM_FFC_G, g)
+ || !OSSL_PARAM_BLD_push_BN(&bld, OSSL_PKEY_PARAM_PUB_KEY, pub_peer))
goto err;
- params_peer = ossl_param_bld_to_param(&bld);
+ params_peer = OSSL_PARAM_BLD_to_param(&bld);
if (params == NULL || params_peer == NULL)
goto err;
goto err;
ret = 1;
err:
- ossl_param_bld_free(params_peer);
- ossl_param_bld_free(params);
+ OSSL_PARAM_BLD_free(params_peer);
+ OSSL_PARAM_BLD_free(params);
BN_free(p);
BN_free(q);
BN_free(g);
#include "prov/providercommon.h"
#include "prov/provider_ctx.h"
#include "crypto/dh.h"
-#include "internal/param_build.h"
+#include "openssl/param_build.h"
static OSSL_OP_keymgmt_new_fn dh_newdata;
static OSSL_OP_keymgmt_free_fn dh_freedata;
DH_get0_pqg(dh, &dh_p, NULL, &dh_g);
if (dh_p != NULL
- && !ossl_param_bld_push_BN(tmpl, OSSL_PKEY_PARAM_FFC_P, dh_p))
+ && !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_FFC_P, dh_p))
return 0;
if (dh_g != NULL
- && !ossl_param_bld_push_BN(tmpl, OSSL_PKEY_PARAM_FFC_G, dh_g))
+ && !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_FFC_G, dh_g))
return 0;
return 1;
DH_get0_key(dh, &pub_key, &priv_key);
if (priv_key != NULL
- && !ossl_param_bld_push_BN(tmpl, OSSL_PKEY_PARAM_PRIV_KEY, priv_key))
+ && !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_PRIV_KEY, priv_key))
return 0;
if (pub_key != NULL
- && !ossl_param_bld_push_BN(tmpl, OSSL_PKEY_PARAM_PUB_KEY, pub_key))
+ && !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_PUB_KEY, pub_key))
return 0;
return 1;
if (dh == NULL)
return 0;
- ossl_param_bld_init(&tmpl);
+ OSSL_PARAM_BLD_init(&tmpl);
if ((selection & OSSL_KEYMGMT_SELECT_ALL_PARAMETERS) != 0)
ok = ok && domparams_to_params(dh, &tmpl);
ok = ok && key_to_params(dh, &tmpl);
if (!ok
- || (params = ossl_param_bld_to_param(&tmpl)) == NULL)
+ || (params = OSSL_PARAM_BLD_to_param(&tmpl)) == NULL)
return 0;
ok = param_cb(params, cbarg);
- ossl_param_bld_free(params);
+ OSSL_PARAM_BLD_free(params);
return ok;
}
#include "prov/providercommon.h"
#include "prov/provider_ctx.h"
#include "crypto/dsa.h"
-#include "internal/param_build.h"
+#include "openssl/param_build.h"
static OSSL_OP_keymgmt_new_fn dsa_newdata;
static OSSL_OP_keymgmt_free_fn dsa_freedata;
DSA_get0_pqg(dsa, &dsa_p, &dsa_q, &dsa_g);
if (dsa_p != NULL
- && !ossl_param_bld_push_BN(tmpl, OSSL_PKEY_PARAM_FFC_P, dsa_p))
+ && !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_FFC_P, dsa_p))
return 0;
if (dsa_q != NULL
- && !ossl_param_bld_push_BN(tmpl, OSSL_PKEY_PARAM_FFC_Q, dsa_q))
+ && !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_FFC_Q, dsa_q))
return 0;
if (dsa_g != NULL
- && !ossl_param_bld_push_BN(tmpl, OSSL_PKEY_PARAM_FFC_G, dsa_g))
+ && !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_FFC_G, dsa_g))
return 0;
return 1;
DSA_get0_key(dsa, &pub_key, &priv_key);
if (priv_key != NULL
- && !ossl_param_bld_push_BN(tmpl, OSSL_PKEY_PARAM_PRIV_KEY, priv_key))
+ && !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_PRIV_KEY, priv_key))
return 0;
if (pub_key != NULL
- && !ossl_param_bld_push_BN(tmpl, OSSL_PKEY_PARAM_PUB_KEY, pub_key))
+ && !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_PUB_KEY, pub_key))
return 0;
return 1;
if (dsa == NULL)
return 0;
- ossl_param_bld_init(&tmpl);
+ OSSL_PARAM_BLD_init(&tmpl);
if ((selection & OSSL_KEYMGMT_SELECT_ALL_PARAMETERS) != 0)
ok = ok && domparams_to_params(dsa, &tmpl);
ok = ok && key_to_params(dsa, &tmpl);
if (!ok
- || (params = ossl_param_bld_to_param(&tmpl)) == NULL)
+ || (params = OSSL_PARAM_BLD_to_param(&tmpl)) == NULL)
return 0;
ok = param_cb(params, cbarg);
- ossl_param_bld_free(params);
+ OSSL_PARAM_BLD_free(params);
return ok;
}
#include <openssl/params.h>
#include "crypto/bn.h"
#include "crypto/ec.h"
-#include "internal/param_build.h"
+#include "openssl/param_build.h"
#include "prov/implementations.h"
#include "prov/providercommon.h"
#include "prov/provider_ctx.h"
if ((curve_name = ec_curve_nid2name(curve_nid)) == NULL)
return 0;
- if (!ossl_param_bld_push_utf8_string(tmpl, OSSL_PKEY_PARAM_EC_NAME,
+ if (!OSSL_PARAM_BLD_push_utf8_string(tmpl, OSSL_PKEY_PARAM_EC_NAME,
curve_name, 0))
return 0;
}
if ((pub_key_len = EC_POINT_point2buf(ecg, pub_point,
POINT_CONVERSION_COMPRESSED,
&pub_key, NULL)) == 0
- || !ossl_param_bld_push_octet_string(tmpl,
+ || !OSSL_PARAM_BLD_push_octet_string(tmpl,
OSSL_PKEY_PARAM_PUB_KEY,
pub_key, pub_key_len))
goto err;
if (ecbits <= 0)
goto err;
sz = (ecbits + 7 ) / 8;
- if (!ossl_param_bld_push_BN_pad(tmpl,
+ if (!OSSL_PARAM_BLD_push_BN_pad(tmpl,
OSSL_PKEY_PARAM_PRIV_KEY,
priv_key, sz))
goto err;
ecdh_cofactor_mode =
(EC_KEY_get_flags(ec) & EC_FLAG_COFACTOR_ECDH) ? 1 : 0;
- if (!ossl_param_bld_push_int(tmpl,
+ if (!OSSL_PARAM_BLD_push_int(tmpl,
OSSL_PKEY_PARAM_USE_COFACTOR_ECDH,
ecdh_cofactor_mode))
return 0;
&& (selection & OSSL_KEYMGMT_SELECT_KEYPAIR) == 0)
return 0;
- ossl_param_bld_init(&tmpl);
+ OSSL_PARAM_BLD_init(&tmpl);
if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0)
ok = ok && domparams_to_params(ec, &tmpl);
ok = ok && otherparams_to_params(ec, &tmpl);
if (!ok
- || (params = ossl_param_bld_to_param(&tmpl)) == NULL)
+ || (params = OSSL_PARAM_BLD_to_param(&tmpl)) == NULL)
return 0;
ok = param_cb(params, cbarg);
- ossl_param_bld_free(params);
+ OSSL_PARAM_BLD_free(params);
return ok;
}
#include <openssl/core_numbers.h>
#include <openssl/core_names.h>
#include <openssl/params.h>
-#include "internal/param_build.h"
+#include "openssl/param_build.h"
#include "crypto/ecx.h"
#include "prov/implementations.h"
#include "prov/providercommon.h"
if (key == NULL)
return 0;
- if (!ossl_param_bld_push_octet_string(tmpl, OSSL_PKEY_PARAM_PUB_KEY,
+ if (!OSSL_PARAM_BLD_push_octet_string(tmpl, OSSL_PKEY_PARAM_PUB_KEY,
key->pubkey, key->keylen))
return 0;
if (key->privkey != NULL
- && !ossl_param_bld_push_octet_string(tmpl, OSSL_PKEY_PARAM_PRIV_KEY,
+ && !OSSL_PARAM_BLD_push_octet_string(tmpl, OSSL_PKEY_PARAM_PRIV_KEY,
key->privkey, key->keylen))
return 0;
&& !key_to_params(key, &tmpl))
return 0;
- ossl_param_bld_init(&tmpl);
- params = ossl_param_bld_to_param(&tmpl);
+ OSSL_PARAM_BLD_init(&tmpl);
+ params = OSSL_PARAM_BLD_to_param(&tmpl);
if (params == NULL) {
- ossl_param_bld_free(params);
+ OSSL_PARAM_BLD_free(params);
return 0;
}
ret = param_cb(params, cbarg);
- ossl_param_bld_free(params);
+ OSSL_PARAM_BLD_free(params);
return ret;
}
#include <openssl/evp.h>
#include <openssl/params.h>
#include <openssl/types.h>
-#include "internal/param_build.h"
+#include "openssl/param_build.h"
#include "prov/implementations.h"
#include "prov/providercommon.h"
#include "prov/provider_ctx.h"
nnum = sk_BIGNUM_const_num(numbers);
for (i = 0; i < nnum; i++) {
- if (!ossl_param_bld_push_BN(tmpl, key,
+ if (!OSSL_PARAM_BLD_push_BN(tmpl, key,
sk_BIGNUM_const_value(numbers, i)))
return 0;
}
rsa_get0_all_params(rsa, factors, exps, coeffs);
if (rsa_n != NULL
- && !ossl_param_bld_push_BN(tmpl, OSSL_PKEY_PARAM_RSA_N, rsa_n))
+ && !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_RSA_N, rsa_n))
goto err;
if (rsa_e != NULL
- && !ossl_param_bld_push_BN(tmpl, OSSL_PKEY_PARAM_RSA_E, rsa_e))
+ && !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_RSA_E, rsa_e))
goto err;
if (rsa_d != NULL
- && !ossl_param_bld_push_BN(tmpl, OSSL_PKEY_PARAM_RSA_D, rsa_d))
+ && !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_RSA_D, rsa_d))
goto err;
if (!export_numbers(tmpl, OSSL_PKEY_PARAM_RSA_FACTOR, factors)
/* TODO(3.0) PSS and OAEP should bring on parameters */
- ossl_param_bld_init(&tmpl);
+ OSSL_PARAM_BLD_init(&tmpl);
if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0)
ok = ok && key_to_params(rsa, &tmpl);
if (!ok
- || (params = ossl_param_bld_to_param(&tmpl)) == NULL)
+ || (params = OSSL_PARAM_BLD_to_param(&tmpl)) == NULL)
return 0;
ok = param_callback(params, cbarg);
- ossl_param_bld_free(params);
+ OSSL_PARAM_BLD_free(params);
return ok;
}
#include <openssl/core_names.h>
#include "crypto/ecx.h"
#include "internal/nelem.h"
-#include "internal/param_build.h"
+#include "openssl/param_build.h"
#include "crypto/evp.h" /* For the internal API */
#include "testutil.h"
0xdc, 0x4b, 0x4d, 0x35, 0x43, 0xe1, 0x1b, 0xad
};
- ossl_param_bld_init(&bld);
+ OSSL_PARAM_BLD_init(&bld);
if (!TEST_ptr(ec_priv_bn = BN_bin2bn(ec_priv_keydata,
sizeof(ec_priv_keydata), NULL)))
goto err;
- if (ossl_param_bld_push_utf8_string(&bld, OSSL_PKEY_PARAM_EC_NAME,
+ if (OSSL_PARAM_BLD_push_utf8_string(&bld, OSSL_PKEY_PARAM_EC_NAME,
"prime256v1", 0) <= 0)
goto err;
- if (ossl_param_bld_push_octet_string(&bld, OSSL_PKEY_PARAM_PUB_KEY,
+ if (OSSL_PARAM_BLD_push_octet_string(&bld, OSSL_PKEY_PARAM_PUB_KEY,
ec_pub_keydata,
sizeof(ec_pub_keydata)) <= 0)
goto err;
- if (ossl_param_bld_push_BN(&bld, OSSL_PKEY_PARAM_PRIV_KEY, ec_priv_bn) <= 0)
+ if (OSSL_PARAM_BLD_push_BN(&bld, OSSL_PKEY_PARAM_PRIV_KEY, ec_priv_bn) <= 0)
goto err;
- if (!TEST_ptr(fromdata_params = ossl_param_bld_to_param(&bld)))
+ if (!TEST_ptr(fromdata_params = OSSL_PARAM_BLD_to_param(&bld)))
goto err;
ctx = EVP_PKEY_CTX_new_from_name(NULL, alg, NULL);
if (!TEST_ptr(ctx))
&& test_print_key_using_serializer(alg, pk);
err:
BN_free(ec_priv_bn);
- ossl_param_bld_free(fromdata_params);
+ OSSL_PARAM_BLD_free(fromdata_params);
EVP_PKEY_free(pk);
EVP_PKEY_free(copy_pk);
EVP_PKEY_CTX_free(ctx);
#include <string.h>
#include <openssl/params.h>
-#include "internal/param_build.h"
+#include "openssl/param_build.h"
#include "internal/nelem.h"
#include "testutil.h"
const char *cutf;
int res = 0;
- ossl_param_bld_init(&bld);
- if (!TEST_true(ossl_param_bld_push_int(&bld, "i", -6))
- || !TEST_true(ossl_param_bld_push_long(&bld, "l", 42))
- || !TEST_true(ossl_param_bld_push_int32(&bld, "i32", 1532))
- || !TEST_true(ossl_param_bld_push_int64(&bld, "i64", -9999999))
- || !TEST_true(ossl_param_bld_push_double(&bld, "d", 1.61803398875))
+ OSSL_PARAM_BLD_init(&bld);
+ if (!TEST_true(OSSL_PARAM_BLD_push_int(&bld, "i", -6))
+ || !TEST_true(OSSL_PARAM_BLD_push_long(&bld, "l", 42))
+ || !TEST_true(OSSL_PARAM_BLD_push_int32(&bld, "i32", 1532))
+ || !TEST_true(OSSL_PARAM_BLD_push_int64(&bld, "i64", -9999999))
+ || !TEST_true(OSSL_PARAM_BLD_push_double(&bld, "d", 1.61803398875))
|| !TEST_ptr(bn = BN_new())
|| !TEST_true(BN_set_word(bn, 1729))
- || !TEST_true(ossl_param_bld_push_BN(&bld, "bignumber", bn))
- || !TEST_true(ossl_param_bld_push_utf8_string(&bld, "utf8_s", "foo",
+ || !TEST_true(OSSL_PARAM_BLD_push_BN(&bld, "bignumber", bn))
+ || !TEST_true(OSSL_PARAM_BLD_push_utf8_string(&bld, "utf8_s", "foo",
sizeof("foo")))
- || !TEST_true(ossl_param_bld_push_utf8_ptr(&bld, "utf8_p", "bar-boom",
+ || !TEST_true(OSSL_PARAM_BLD_push_utf8_ptr(&bld, "utf8_p", "bar-boom",
0))
- || !TEST_ptr(params = ossl_param_bld_to_param(&bld))
+ || !TEST_ptr(params = OSSL_PARAM_BLD_to_param(&bld))
/* Check int */
|| !TEST_ptr(p = OSSL_PARAM_locate(params, "i"))
|| !TEST_true(OSSL_PARAM_get_int(p, &i))
goto err;
res = 1;
err:
- ossl_param_bld_free(params);
+ OSSL_PARAM_BLD_free(params);
OPENSSL_free(utf);
BN_free(bn);
BN_free(bn_res);
BIGNUM *bn = NULL, *bn_res = NULL;
int res = 0;
- ossl_param_bld_init(&bld);
- if (!TEST_true(ossl_param_bld_push_uint(&bld, "i", 6))
- || !TEST_true(ossl_param_bld_push_ulong(&bld, "l", 42))
- || !TEST_true(ossl_param_bld_push_uint32(&bld, "i32", 1532))
- || !TEST_true(ossl_param_bld_push_uint64(&bld, "i64", 9999999))
- || !TEST_true(ossl_param_bld_push_size_t(&bld, "st", 65537))
+ OSSL_PARAM_BLD_init(&bld);
+ if (!TEST_true(OSSL_PARAM_BLD_push_uint(&bld, "i", 6))
+ || !TEST_true(OSSL_PARAM_BLD_push_ulong(&bld, "l", 42))
+ || !TEST_true(OSSL_PARAM_BLD_push_uint32(&bld, "i32", 1532))
+ || !TEST_true(OSSL_PARAM_BLD_push_uint64(&bld, "i64", 9999999))
+ || !TEST_true(OSSL_PARAM_BLD_push_size_t(&bld, "st", 65537))
|| !TEST_ptr(bn = BN_secure_new())
|| !TEST_true(BN_set_word(bn, 1729))
- || !TEST_true(ossl_param_bld_push_BN(&bld, "bignumber", bn))
- || !TEST_true(ossl_param_bld_push_octet_string(&bld, "oct_s", data1,
+ || !TEST_true(OSSL_PARAM_BLD_push_BN(&bld, "bignumber", bn))
+ || !TEST_true(OSSL_PARAM_BLD_push_octet_string(&bld, "oct_s", data1,
sizeof(data1)))
- || !TEST_true(ossl_param_bld_push_octet_ptr(&bld, "oct_p", data2,
+ || !TEST_true(OSSL_PARAM_BLD_push_octet_ptr(&bld, "oct_p", data2,
sizeof(data2)))
- || !TEST_ptr(params = ossl_param_bld_to_param(&bld))
+ || !TEST_ptr(params = OSSL_PARAM_BLD_to_param(&bld))
/* Check unsigned int */
|| !TEST_ptr(p = OSSL_PARAM_locate(params, "i"))
|| !TEST_true(OSSL_PARAM_get_uint(p, &i))
goto err;
res = 1;
err:
- ossl_param_bld_free(params);
+ OSSL_PARAM_BLD_free(params);
BN_free(bn);
BN_free(bn_res);
return res;