diff options
author | tb <> | 2018-03-17 15:19:12 +0000 |
---|---|---|
committer | tb <> | 2018-03-17 15:19:12 +0000 |
commit | ff154a0391cfcee220c90f520739c6f08f97c2aa (patch) | |
tree | b098ccdac17cb9ccf01e46859b80d5ce671af779 /src | |
parent | 47bd2696f108ed72a37c309a2c1d049aeee2c89d (diff) | |
download | openbsd-ff154a0391cfcee220c90f520739c6f08f97c2aa.tar.gz openbsd-ff154a0391cfcee220c90f520739c6f08f97c2aa.tar.bz2 openbsd-ff154a0391cfcee220c90f520739c6f08f97c2aa.zip |
Add DSA_meth_{dup,free,new,set_{finish,sign}}()
As in RSA_meth_*, note that these functions return NULL in
out-of-memory situations, but they do not set an error explicitly.
ok jsing
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/Makefile | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/Symbols.list | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa.h | 9 | ||||
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_meth.c | 78 |
4 files changed, 93 insertions, 2 deletions
diff --git a/src/lib/libcrypto/Makefile b/src/lib/libcrypto/Makefile index 18c7c0608a..4817a4c260 100644 --- a/src/lib/libcrypto/Makefile +++ b/src/lib/libcrypto/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile,v 1.25 2018/03/17 15:12:56 tb Exp $ | 1 | # $OpenBSD: Makefile,v 1.26 2018/03/17 15:19:12 tb Exp $ |
2 | 2 | ||
3 | LIB= crypto | 3 | LIB= crypto |
4 | LIBREBUILD=y | 4 | LIBREBUILD=y |
@@ -117,6 +117,7 @@ SRCS+= dh_ameth.c dh_pmeth.c dh_prn.c | |||
117 | # dsa/ | 117 | # dsa/ |
118 | SRCS+= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c | 118 | SRCS+= dsa_gen.c dsa_key.c dsa_lib.c dsa_asn1.c dsa_vrf.c dsa_sign.c |
119 | SRCS+= dsa_err.c dsa_ossl.c dsa_depr.c dsa_ameth.c dsa_pmeth.c dsa_prn.c | 119 | SRCS+= dsa_err.c dsa_ossl.c dsa_depr.c dsa_ameth.c dsa_pmeth.c dsa_prn.c |
120 | SRCS+= dsa_meth.c | ||
120 | 121 | ||
121 | # dso/ | 122 | # dso/ |
122 | SRCS+= dso_dlfcn.c dso_err.c dso_lib.c dso_null.c | 123 | SRCS+= dso_dlfcn.c dso_err.c dso_lib.c dso_null.c |
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list index 7cb78c4daf..6777e8cc13 100644 --- a/src/lib/libcrypto/Symbols.list +++ b/src/lib/libcrypto/Symbols.list | |||
@@ -831,6 +831,11 @@ DSA_get0_pqg | |||
831 | DSA_get_default_method | 831 | DSA_get_default_method |
832 | DSA_get_ex_data | 832 | DSA_get_ex_data |
833 | DSA_get_ex_new_index | 833 | DSA_get_ex_new_index |
834 | DSA_meth_dup | ||
835 | DSA_meth_free | ||
836 | DSA_meth_new | ||
837 | DSA_meth_set_finish | ||
838 | DSA_meth_set_sign | ||
834 | DSA_new | 839 | DSA_new |
835 | DSA_new_method | 840 | DSA_new_method |
836 | DSA_print | 841 | DSA_print |
diff --git a/src/lib/libcrypto/dsa/dsa.h b/src/lib/libcrypto/dsa/dsa.h index 8fe7c668b2..61bfc2b466 100644 --- a/src/lib/libcrypto/dsa/dsa.h +++ b/src/lib/libcrypto/dsa/dsa.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dsa.h,v 1.29 2018/02/20 17:52:27 tb Exp $ */ | 1 | /* $OpenBSD: dsa.h,v 1.30 2018/03/17 15:19:12 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -269,6 +269,13 @@ int DSA_test_flags(const DSA *d, int flags); | |||
269 | void DSA_set_flags(DSA *d, int flags); | 269 | void DSA_set_flags(DSA *d, int flags); |
270 | ENGINE *DSA_get0_engine(DSA *d); | 270 | ENGINE *DSA_get0_engine(DSA *d); |
271 | 271 | ||
272 | DSA_METHOD *DSA_meth_new(const char *name, int flags); | ||
273 | void DSA_meth_free(DSA_METHOD *meth); | ||
274 | DSA_METHOD *DSA_meth_dup(const DSA_METHOD *meth); | ||
275 | int DSA_meth_set_sign(DSA_METHOD *meth, | ||
276 | DSA_SIG *(*sign)(const unsigned char *, int, DSA *)); | ||
277 | int DSA_meth_set_finish(DSA_METHOD *meth, int (*finish)(DSA *)); | ||
278 | |||
272 | #define EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits) \ | 279 | #define EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits) \ |
273 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \ | 280 | EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \ |
274 | EVP_PKEY_CTRL_DSA_PARAMGEN_BITS, nbits, NULL) | 281 | EVP_PKEY_CTRL_DSA_PARAMGEN_BITS, nbits, NULL) |
diff --git a/src/lib/libcrypto/dsa/dsa_meth.c b/src/lib/libcrypto/dsa/dsa_meth.c new file mode 100644 index 0000000000..e6f043f830 --- /dev/null +++ b/src/lib/libcrypto/dsa/dsa_meth.c | |||
@@ -0,0 +1,78 @@ | |||
1 | /* $OpenBSD: dsa_meth.c,v 1.1 2018/03/17 15:19:12 tb Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> | ||
4 | * | ||
5 | * Permission to use, copy, modify, and distribute this software for any | ||
6 | * purpose with or without fee is hereby granted, provided that the above | ||
7 | * copyright notice and this permission notice appear in all copies. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | */ | ||
17 | |||
18 | #include <stdlib.h> | ||
19 | #include <string.h> | ||
20 | |||
21 | #include <openssl/dsa.h> | ||
22 | #include <openssl/err.h> | ||
23 | |||
24 | DSA_METHOD * | ||
25 | DSA_meth_new(const char *name, int flags) | ||
26 | { | ||
27 | DSA_METHOD *meth; | ||
28 | |||
29 | if ((meth = calloc(1, sizeof(*meth))) == NULL) | ||
30 | return NULL; | ||
31 | if ((meth->name = strdup(name)) == NULL) { | ||
32 | free(meth); | ||
33 | return NULL; | ||
34 | } | ||
35 | meth->flags = flags; | ||
36 | |||
37 | return meth; | ||
38 | } | ||
39 | |||
40 | void | ||
41 | DSA_meth_free(DSA_METHOD *meth) | ||
42 | { | ||
43 | if (meth != NULL) { | ||
44 | free((char *)meth->name); | ||
45 | free(meth); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | DSA_METHOD * | ||
50 | DSA_meth_dup(const DSA_METHOD *meth) | ||
51 | { | ||
52 | DSA_METHOD *copy; | ||
53 | |||
54 | if ((copy = calloc(1, sizeof(*copy))) == NULL) | ||
55 | return NULL; | ||
56 | memcpy(copy, meth, sizeof(*copy)); | ||
57 | if ((copy->name = strdup(meth->name)) == NULL) { | ||
58 | free(copy); | ||
59 | return NULL; | ||
60 | } | ||
61 | |||
62 | return copy; | ||
63 | } | ||
64 | |||
65 | int | ||
66 | DSA_meth_set_sign(DSA_METHOD *meth, | ||
67 | DSA_SIG *(*sign)(const unsigned char *, int, DSA *)) | ||
68 | { | ||
69 | meth->dsa_do_sign = sign; | ||
70 | return 1; | ||
71 | } | ||
72 | |||
73 | int | ||
74 | DSA_meth_set_finish(DSA_METHOD *meth, int (*finish)(DSA *)) | ||
75 | { | ||
76 | meth->finish = finish; | ||
77 | return 1; | ||
78 | } | ||