]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/params.h
Params: add argument to the _from_text calls to indicate if the param exists.
[thirdparty/openssl.git] / include / openssl / params.h
CommitLineData
7ffbd7ca
P
1/*
2 * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
3 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
4 *
5 * Licensed under the Apache License 2.0 (the "License"). You may not use
6 * this file except in compliance with the License. You can obtain a copy
7 * in the file LICENSE in the source distribution or at
8 * https://www.openssl.org/source/license.html
9 */
10
ae4186b0
DMSP
11#ifndef OPENSSL_PARAMS_H
12# define OPENSSL_PARAMS_H
7ffbd7ca
P
13
14# include <openssl/core.h>
15# include <openssl/bn.h>
16
17# ifdef __cplusplus
18extern "C" {
19# endif
20
21# define OSSL_PARAM_END \
4e7991b4 22 { NULL, 0, NULL, 0, 0 }
7ffbd7ca 23
4e7991b4
P
24# define OSSL_PARAM_DEFN(key, type, addr, sz) \
25 { (key), (type), (addr), (sz), 0 }
7ffbd7ca
P
26
27/* Basic parameter types without return sizes */
28# define OSSL_PARAM_int(key, addr) \
4e7991b4 29 OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int))
7ffbd7ca
P
30# define OSSL_PARAM_uint(key, addr) \
31 OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \
4e7991b4 32 sizeof(unsigned int))
7ffbd7ca 33# define OSSL_PARAM_long(key, addr) \
4e7991b4 34 OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(long int))
7ffbd7ca
P
35# define OSSL_PARAM_ulong(key, addr) \
36 OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \
4e7991b4 37 sizeof(unsigned long int))
7ffbd7ca 38# define OSSL_PARAM_int32(key, addr) \
4e7991b4 39 OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int32_t))
7ffbd7ca
P
40# define OSSL_PARAM_uint32(key, addr) \
41 OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \
4e7991b4 42 sizeof(uint32_t))
7ffbd7ca 43# define OSSL_PARAM_int64(key, addr) \
4e7991b4 44 OSSL_PARAM_DEFN((key), OSSL_PARAM_INTEGER, (addr), sizeof(int64_t))
7ffbd7ca
P
45# define OSSL_PARAM_uint64(key, addr) \
46 OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), \
4e7991b4 47 sizeof(uint64_t))
7ffbd7ca 48# define OSSL_PARAM_size_t(key, addr) \
4e7991b4 49 OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (addr), sizeof(size_t))
7ffbd7ca 50# define OSSL_PARAM_double(key, addr) \
4e7991b4 51 OSSL_PARAM_DEFN((key), OSSL_PARAM_REAL, (addr), sizeof(double))
7ffbd7ca 52
4e7991b4
P
53# define OSSL_PARAM_BN(key, bn, sz) \
54 OSSL_PARAM_DEFN((key), OSSL_PARAM_UNSIGNED_INTEGER, (bn), (sz))
7ffbd7ca 55# define OSSL_PARAM_utf8_string(key, addr, sz) \
4e7991b4 56 OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_STRING, (addr), sz)
7ffbd7ca 57# define OSSL_PARAM_octet_string(key, addr, sz) \
4e7991b4 58 OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_STRING, (addr), sz)
7ffbd7ca
P
59
60# define OSSL_PARAM_utf8_ptr(key, addr, sz) \
4e7991b4 61 OSSL_PARAM_DEFN((key), OSSL_PARAM_UTF8_PTR, &(addr), sz)
7ffbd7ca 62# define OSSL_PARAM_octet_ptr(key, addr, sz) \
4e7991b4 63 OSSL_PARAM_DEFN((key), OSSL_PARAM_OCTET_PTR, &(addr), sz)
7ffbd7ca
P
64
65/* Search an OSSL_PARAM array for a matching name */
4e7991b4
P
66OSSL_PARAM *OSSL_PARAM_locate(OSSL_PARAM *p, const char *key);
67const OSSL_PARAM *OSSL_PARAM_locate_const(const OSSL_PARAM *p, const char *key);
7ffbd7ca
P
68
69/* Basic parameter type run-time construction */
4e7991b4
P
70OSSL_PARAM OSSL_PARAM_construct_int(const char *key, int *buf);
71OSSL_PARAM OSSL_PARAM_construct_uint(const char *key, unsigned int *buf);
72OSSL_PARAM OSSL_PARAM_construct_long(const char *key, long int *buf);
73OSSL_PARAM OSSL_PARAM_construct_ulong(const char *key, unsigned long int *buf);
74OSSL_PARAM OSSL_PARAM_construct_int32(const char *key, int32_t *buf);
75OSSL_PARAM OSSL_PARAM_construct_uint32(const char *key, uint32_t *buf);
76OSSL_PARAM OSSL_PARAM_construct_int64(const char *key, int64_t *buf);
77OSSL_PARAM OSSL_PARAM_construct_uint64(const char *key, uint64_t *buf);
78OSSL_PARAM OSSL_PARAM_construct_size_t(const char *key, size_t *buf);
7ffbd7ca 79OSSL_PARAM OSSL_PARAM_construct_BN(const char *key, unsigned char *buf,
4e7991b4
P
80 size_t bsize);
81OSSL_PARAM OSSL_PARAM_construct_double(const char *key, double *buf);
7ffbd7ca 82OSSL_PARAM OSSL_PARAM_construct_utf8_string(const char *key, char *buf,
4e7991b4 83 size_t bsize);
7ffbd7ca 84OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf,
4e7991b4 85 size_t bsize);
7ffbd7ca 86OSSL_PARAM OSSL_PARAM_construct_octet_string(const char *key, void *buf,
4e7991b4 87 size_t bsize);
7ffbd7ca 88OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf,
4e7991b4 89 size_t bsize);
195852fe 90OSSL_PARAM OSSL_PARAM_construct_end(void);
7ffbd7ca 91
246a1f3d
RL
92int OSSL_PARAM_allocate_from_text(OSSL_PARAM *to,
93 const OSSL_PARAM *paramdefs,
94 const char *key, const char *value,
2ee0dfa6 95 size_t value_n, int *found);
246a1f3d 96
7ffbd7ca
P
97int OSSL_PARAM_get_int(const OSSL_PARAM *p, int *val);
98int OSSL_PARAM_get_uint(const OSSL_PARAM *p, unsigned int *val);
99int OSSL_PARAM_get_long(const OSSL_PARAM *p, long int *val);
100int OSSL_PARAM_get_ulong(const OSSL_PARAM *p, unsigned long int *val);
101int OSSL_PARAM_get_int32(const OSSL_PARAM *p, int32_t *val);
102int OSSL_PARAM_get_uint32(const OSSL_PARAM *p, uint32_t *val);
103int OSSL_PARAM_get_int64(const OSSL_PARAM *p, int64_t *val);
104int OSSL_PARAM_get_uint64(const OSSL_PARAM *p, uint64_t *val);
105int OSSL_PARAM_get_size_t(const OSSL_PARAM *p, size_t *val);
106
4e7991b4
P
107int OSSL_PARAM_set_int(OSSL_PARAM *p, int val);
108int OSSL_PARAM_set_uint(OSSL_PARAM *p, unsigned int val);
109int OSSL_PARAM_set_long(OSSL_PARAM *p, long int val);
110int OSSL_PARAM_set_ulong(OSSL_PARAM *p, unsigned long int val);
111int OSSL_PARAM_set_int32(OSSL_PARAM *p, int32_t val);
112int OSSL_PARAM_set_uint32(OSSL_PARAM *p, uint32_t val);
113int OSSL_PARAM_set_int64(OSSL_PARAM *p, int64_t val);
114int OSSL_PARAM_set_uint64(OSSL_PARAM *p, uint64_t val);
115int OSSL_PARAM_set_size_t(OSSL_PARAM *p, size_t val);
7ffbd7ca
P
116
117int OSSL_PARAM_get_double(const OSSL_PARAM *p, double *val);
4e7991b4 118int OSSL_PARAM_set_double(OSSL_PARAM *p, double val);
7ffbd7ca
P
119
120int OSSL_PARAM_get_BN(const OSSL_PARAM *p, BIGNUM **val);
4e7991b4 121int OSSL_PARAM_set_BN(OSSL_PARAM *p, const BIGNUM *val);
7ffbd7ca
P
122
123int OSSL_PARAM_get_utf8_string(const OSSL_PARAM *p, char **val, size_t max_len);
4e7991b4 124int OSSL_PARAM_set_utf8_string(OSSL_PARAM *p, const char *val);
7ffbd7ca
P
125
126int OSSL_PARAM_get_octet_string(const OSSL_PARAM *p, void **val, size_t max_len,
127 size_t *used_len);
4e7991b4 128int OSSL_PARAM_set_octet_string(OSSL_PARAM *p, const void *val, size_t len);
7ffbd7ca
P
129
130int OSSL_PARAM_get_utf8_ptr(const OSSL_PARAM *p, const char **val);
4e7991b4 131int OSSL_PARAM_set_utf8_ptr(OSSL_PARAM *p, const char *val);
7ffbd7ca
P
132
133int OSSL_PARAM_get_octet_ptr(const OSSL_PARAM *p, const void **val,
134 size_t *used_len);
4e7991b4 135int OSSL_PARAM_set_octet_ptr(OSSL_PARAM *p, const void *val,
7ffbd7ca
P
136 size_t used_len);
137
138# ifdef __cplusplus
139}
140# endif
141#endif