diff options
author | Pauli <paul.dale@oracle.com> | 2020-05-11 09:37:45 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2020-06-24 20:05:41 +1000 |
commit | 5fdaa38febb7463dbd44f849b2930edcbd5f6bae (patch) | |
tree | 3763d73fb1ec5ae8d08de03e9107973e94ff8b5a /crypto | |
parent | f3a2570794b45f7f6391cb7f447b27c1ee758441 (diff) |
params: add OSSL_PARAM helpers for time_t.
POSIX mandates that time_t is a signed integer but it doesn't specify the
lenght. Having wrappers lets uses ignore this.
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/11682)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/param_build.c | 7 | ||||
-rw-r--r-- | crypto/params.c | 27 |
2 files changed, 34 insertions, 0 deletions
diff --git a/crypto/param_build.c b/crypto/param_build.c index 76522cd377..de829d354f 100644 --- a/crypto/param_build.c +++ b/crypto/param_build.c @@ -190,6 +190,13 @@ int OSSL_PARAM_BLD_push_size_t(OSSL_PARAM_BLD *bld, const char *key, OSSL_PARAM_UNSIGNED_INTEGER); } +int OSSL_PARAM_BLD_push_time_t(OSSL_PARAM_BLD *bld, const char *key, + time_t num) +{ + return param_push_num(bld, key, &num, sizeof(num), + OSSL_PARAM_INTEGER); +} + int OSSL_PARAM_BLD_push_double(OSSL_PARAM_BLD *bld, const char *key, double num) { diff --git a/crypto/params.c b/crypto/params.c index 9bccc51760..67ca4f0c83 100644 --- a/crypto/params.c +++ b/crypto/params.c @@ -617,6 +617,33 @@ OSSL_PARAM OSSL_PARAM_construct_size_t(const char *key, size_t *buf) sizeof(size_t)); } +int OSSL_PARAM_get_time_t(const OSSL_PARAM *p, time_t *val) +{ + switch (sizeof(time_t)) { + case sizeof(int32_t): + return OSSL_PARAM_get_int32(p, (int32_t *)val); + case sizeof(int64_t): + return OSSL_PARAM_get_int64(p, (int64_t *)val); + } + return 0; +} + +int OSSL_PARAM_set_time_t(OSSL_PARAM *p, time_t val) +{ + switch (sizeof(time_t)) { + case sizeof(int32_t): + return OSSL_PARAM_set_int32(p, (int32_t)val); + case sizeof(int64_t): + return OSSL_PARAM_set_int64(p, (int64_t)val); + } + return 0; +} + +OSSL_PARAM OSSL_PARAM_construct_time_t(const char *key, time_t *buf) +{ + return ossl_param_construct(key, OSSL_PARAM_INTEGER, buf, sizeof(time_t)); +} + int OSSL_PARAM_get_BN(const OSSL_PARAM *p, BIGNUM **val) { BIGNUM *b; |