diff options
author | tb <> | 2022-07-04 12:22:32 +0000 |
---|---|---|
committer | tb <> | 2022-07-04 12:22:32 +0000 |
commit | 00e824726e67ac60f4500af3e2eb04bc6165190b (patch) | |
tree | 9e35a209080134fc201402fc0940a82725121512 /src/lib/libcrypto/dsa/dsa_meth.c | |
parent | 7869bf01c6d0b61d5bf56605b35b2ee60ee72e3c (diff) | |
download | openbsd-00e824726e67ac60f4500af3e2eb04bc6165190b.tar.gz openbsd-00e824726e67ac60f4500af3e2eb04bc6165190b.tar.bz2 openbsd-00e824726e67ac60f4500af3e2eb04bc6165190b.zip |
Prepare to provide DSA_meth_{get0,set1}_name()
Also follow OpenSSL by making the name non-const to avoid ugly casting.
Used by OpenSC's pkcs11-helper, as reported by Fabrice Fontaine in
https://github.com/libressl-portable/openbsd/issues/130
ok jsing sthen
Diffstat (limited to 'src/lib/libcrypto/dsa/dsa_meth.c')
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_meth.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_meth.c b/src/lib/libcrypto/dsa/dsa_meth.c index cd232835eb..2cb0426d43 100644 --- a/src/lib/libcrypto/dsa/dsa_meth.c +++ b/src/lib/libcrypto/dsa/dsa_meth.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dsa_meth.c,v 1.3 2022/05/07 10:31:54 tb Exp $ */ | 1 | /* $OpenBSD: dsa_meth.c,v 1.4 2022/07/04 12:22:32 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> | 3 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> |
4 | * | 4 | * |
@@ -42,10 +42,11 @@ DSA_meth_new(const char *name, int flags) | |||
42 | void | 42 | void |
43 | DSA_meth_free(DSA_METHOD *meth) | 43 | DSA_meth_free(DSA_METHOD *meth) |
44 | { | 44 | { |
45 | if (meth != NULL) { | 45 | if (meth == NULL) |
46 | free((char *)meth->name); | 46 | return |
47 | free(meth); | 47 | |
48 | } | 48 | free(meth->name); |
49 | free(meth); | ||
49 | } | 50 | } |
50 | 51 | ||
51 | DSA_METHOD * | 52 | DSA_METHOD * |
@@ -64,6 +65,28 @@ DSA_meth_dup(const DSA_METHOD *meth) | |||
64 | return copy; | 65 | return copy; |
65 | } | 66 | } |
66 | 67 | ||
68 | const char * | ||
69 | DSA_meth_get0_name(const DSA_METHOD *meth) | ||
70 | { | ||
71 | return meth->name; | ||
72 | } | ||
73 | |||
74 | int | ||
75 | DSA_meth_set1_name(DSA_METHOD *meth, const char *name) | ||
76 | { | ||
77 | char *new_name; | ||
78 | |||
79 | if ((new_name = strdup(name)) == NULL) { | ||
80 | DSAerror(ERR_R_MALLOC_FAILURE); | ||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | free(meth->name); | ||
85 | meth->name = new_name; | ||
86 | |||
87 | return 1; | ||
88 | } | ||
89 | |||
67 | int | 90 | int |
68 | DSA_meth_set_sign(DSA_METHOD *meth, | 91 | DSA_meth_set_sign(DSA_METHOD *meth, |
69 | DSA_SIG *(*sign)(const unsigned char *, int, DSA *)) | 92 | DSA_SIG *(*sign)(const unsigned char *, int, DSA *)) |