summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/pmeth_lib.c
diff options
context:
space:
mode:
authortb <>2022-05-05 08:42:27 +0000
committertb <>2022-05-05 08:42:27 +0000
commitc485c355419bb3824cfc318d95ba44ef5a50a698 (patch)
tree5132514a9eec791b42c62a94133cef94a4e9ff68 /src/lib/libcrypto/evp/pmeth_lib.c
parenteb43e4435b3934080b19c4dd3638c2bc22395d02 (diff)
downloadopenbsd-c485c355419bb3824cfc318d95ba44ef5a50a698.tar.gz
openbsd-c485c355419bb3824cfc318d95ba44ef5a50a698.tar.bz2
openbsd-c485c355419bb3824cfc318d95ba44ef5a50a698.zip
Provide versions of EVP_PKEY_CTX_{str,hex}2ctrl() for internal use.
ok beck jsing
Diffstat (limited to 'src/lib/libcrypto/evp/pmeth_lib.c')
-rw-r--r--src/lib/libcrypto/evp/pmeth_lib.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/lib/libcrypto/evp/pmeth_lib.c b/src/lib/libcrypto/evp/pmeth_lib.c
index d265e2aced..ef28ba09d8 100644
--- a/src/lib/libcrypto/evp/pmeth_lib.c
+++ b/src/lib/libcrypto/evp/pmeth_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pmeth_lib.c,v 1.20 2022/01/10 12:10:26 tb Exp $ */ 1/* $OpenBSD: pmeth_lib.c,v 1.21 2022/05/05 08:42:27 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2006. 3 * project 2006.
4 */ 4 */
@@ -56,6 +56,7 @@
56 * 56 *
57 */ 57 */
58 58
59#include <limits.h>
59#include <stdio.h> 60#include <stdio.h>
60#include <stdlib.h> 61#include <stdlib.h>
61#include <string.h> 62#include <string.h>
@@ -65,6 +66,7 @@
65#include <openssl/err.h> 66#include <openssl/err.h>
66#include <openssl/evp.h> 67#include <openssl/evp.h>
67#include <openssl/objects.h> 68#include <openssl/objects.h>
69#include <openssl/x509v3.h>
68 70
69#ifndef OPENSSL_NO_ENGINE 71#ifndef OPENSSL_NO_ENGINE
70#include <openssl/engine.h> 72#include <openssl/engine.h>
@@ -395,6 +397,38 @@ EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *name, const char *value)
395} 397}
396 398
397int 399int
400EVP_PKEY_CTX_str2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *str)
401{
402 size_t len;
403
404 if ((len = strlen(str)) > INT_MAX)
405 return -1;
406
407 return ctx->pmeth->ctrl(ctx, cmd, len, (void *)str);
408}
409
410int
411EVP_PKEY_CTX_hex2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *hexstr)
412{
413 unsigned char *hex = NULL;
414 long length;
415 int ret = 0;
416
417 if ((hex = string_to_hex(hexstr, &length)) == NULL)
418 goto err;
419 if (length < 0 || length > INT_MAX) {
420 ret = -1;
421 goto err;
422 }
423
424 ret = ctx->pmeth->ctrl(ctx, cmd, length, hex);
425
426 err:
427 free(hex);
428 return ret;
429}
430
431int
398EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md_name) 432EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md_name)
399{ 433{
400 const EVP_MD *md; 434 const EVP_MD *md;