* *out and *out_len are guaranteed to be untouched if this function
* doesn't return success.
*/
-int ossl_param_get1_octet_string(const OSSL_PARAM *params, const char *name,
- unsigned char **out, size_t *out_len)
+int ossl_param_get1_octet_string_from_param(const OSSL_PARAM *p,
+ unsigned char **out,
+ size_t *out_len)
{
- const OSSL_PARAM *p = OSSL_PARAM_locate_const(params, name);
void *buf = NULL;
size_t len = 0;
return 1;
}
-static int setbuf_fromparams(const OSSL_PARAM *p, const char *name,
+int ossl_param_get1_octet_string(const OSSL_PARAM *params, const char *name,
+ unsigned char **out, size_t *out_len)
+{
+ const OSSL_PARAM *p = OSSL_PARAM_locate_const(params, name);
+
+ return ossl_param_get1_octet_string_from_param(p, out, out_len);
+}
+
+static int setbuf_fromparams(size_t n, OSSL_PARAM *p[],
unsigned char *out, size_t *outlen)
{
int ret = 0;
WPACKET pkt;
+ size_t i;
if (out == NULL) {
if (!WPACKET_init_null(&pkt, 0))
return 0;
}
- for (; p != NULL; p = OSSL_PARAM_locate_const(p + 1, name)) {
- if (p->data_type != OSSL_PARAM_OCTET_STRING)
+ for (i = 0; i < n; i++) {
+ if (p[i]->data_type != OSSL_PARAM_OCTET_STRING)
goto err;
- if (p->data != NULL
- && p->data_size != 0
- && !WPACKET_memcpy(&pkt, p->data, p->data_size))
+ if (p[i]->data != NULL
+ && p[i]->data_size != 0
+ && !WPACKET_memcpy(&pkt, p[i]->data, p[i]->data_size))
goto err;
}
if (!WPACKET_get_total_written(&pkt, outlen)
return ret;
}
-int ossl_param_get1_concat_octet_string(const OSSL_PARAM *params, const char *name,
+int ossl_param_get1_concat_octet_string(size_t n, OSSL_PARAM *params[],
unsigned char **out,
size_t *out_len, size_t maxsize)
{
- const OSSL_PARAM *p = OSSL_PARAM_locate_const(params, name);
unsigned char *res;
size_t sz = 0;
- if (p == NULL)
- return -1;
+ if (n == 0)
+ return 1;
/* Calculate the total size */
- if (!setbuf_fromparams(p, name, NULL, &sz))
+ if (!setbuf_fromparams(n, params, NULL, &sz))
return 0;
/* Check that it's not oversized */
return 0;
/* Concat one or more OSSL_KDF_PARAM_INFO fields */
- if (!setbuf_fromparams(p, name, res, &sz)) {
+ if (!setbuf_fromparams(n, params, res, &sz)) {
OPENSSL_clear_free(res, sz);
return 0;
}
* *out and *out_len are guaranteed to be untouched if this function
* doesn't return success.
*/
+int ossl_param_get1_octet_string_from_param(const OSSL_PARAM *p,
+ unsigned char **out,
+ size_t *out_len);
int ossl_param_get1_octet_string(const OSSL_PARAM *params, const char *name,
unsigned char **out, size_t *out_len);
+
/*
* Concatenate all of the matching params together.
* *out will point to an allocated buffer on successful return.
*
* Passing 0 for maxsize means unlimited size output.
*
- * Returns 1 on success, 0 on failure and -1 if there are no matching params.
+ * Returns 1 on success and 0 on failure.
*
* *out and *out_len are guaranteed to be untouched if this function
* doesn't return success.
*/
-int ossl_param_get1_concat_octet_string(const OSSL_PARAM *params, const char *name,
- unsigned char **out, size_t *out_len,
- size_t maxsize);
+int ossl_param_get1_concat_octet_string(size_t n, OSSL_PARAM *params[],
+ unsigned char **out,
+ size_t *out_len, size_t maxsize);