summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/evp/evp_locl.h4
-rw-r--r--src/lib/libcrypto/evp/pmeth_lib.c36
2 files changed, 38 insertions, 2 deletions
diff --git a/src/lib/libcrypto/evp/evp_locl.h b/src/lib/libcrypto/evp/evp_locl.h
index c3d9a6a718..43e0ac333d 100644
--- a/src/lib/libcrypto/evp/evp_locl.h
+++ b/src/lib/libcrypto/evp/evp_locl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_locl.h,v 1.22 2022/01/14 08:38:05 tb Exp $ */ 1/* $OpenBSD: evp_locl.h,v 1.23 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 2000. 3 * project 2000.
4 */ 4 */
@@ -505,6 +505,8 @@ struct evp_aead_ctx_st {
505 void *aead_state; 505 void *aead_state;
506}; 506};
507 507
508int EVP_PKEY_CTX_str2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *str);
509int EVP_PKEY_CTX_hex2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *hex);
508int EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md_name); 510int EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md_name);
509 511
510__END_HIDDEN_DECLS 512__END_HIDDEN_DECLS
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;