blob: 5945507bf1fd590f4ae2d88dd6ec8bc561c575e8 [file] [log] [blame]
Brad Bishop316dfdd2018-06-25 12:45:53 -04001From 9f97479373f3fceedc471074b81486d77a49618d Mon Sep 17 00:00:00 2001
2From: "Roy.Li" <rongqing.li@windriver.com>
3Date: Tue, 4 Mar 2014 14:38:42 +0800
4Subject: [PATCH] fix the function parameter
Patrick Williamsb48b7b42016-08-17 15:04:38 -05005
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08006Upstream-Status: Pending
Patrick Williamsb48b7b42016-08-17 15:04:38 -05007
8Original openssl_diffie_hellman_create has three parameters, but
9it is reassigned a function pointer which has one parameter, and
10is called with one parameter, which will lead to segment fault
11on PPC, Now we simply correct the number of parameters.
12
13 #0 0x484d4aa0 in __GI_raise (sig=6)
14 at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
15 #1 0x484d9930 in __GI_abort () at abort.c:91
16 #2 0x10002064 in segv_handler (signal=11) at charon.c:224
17 #3 <signal handler called>
18 #4 0x48d89630 in openssl_diffie_hellman_create (group=MODP_1024_BIT, g=...,
19 p=<error reading variable: Cannot access memory at address 0x0>)
20 at openssl_diffie_hellman.c:143
21 #5 0x482c54f8 in create_dh (this=0x11ac6e68, group=MODP_1024_BIT)
22 at crypto/crypto_factory.c:358
23 #6 0x48375884 in create_dh (this=<optimized out>, group=<optimized out>)
24 at sa/keymat.c:132
25 #7 0x483843b8 in process_payloads (this=0x51400a78, message=<optimized
26 out>)
27 at sa/tasks/ike_init.c:200
28 #8 0x483844d0 in process_r (this=0x51400a78, message=0x51500778)
29 at sa/tasks/ike_init.c:319
30 #9 0x48374c9c in process_request (message=0x51500778, this=0x51400d20)
31 at sa/task_manager.c:870
32 #10 process_message (this=0x51400d20, msg=0x51500778) at
33 sa/task_manager.c:925
34 #11 0x4836c378 in process_message (this=0x514005f0, message=0x51500778)
35 at sa/ike_sa.c:1317
36 #12 0x48362270 in execute (this=0x515008d0)
Brad Bishop316dfdd2018-06-25 12:45:53 -040037 at processing/jobs/process_message_job.c:74
Patrick Williamsb48b7b42016-08-17 15:04:38 -050038
39Signed-off-by: Roy.Li <rongqing.li@windriver.com>
Brad Bishop316dfdd2018-06-25 12:45:53 -040040
Patrick Williamsb48b7b42016-08-17 15:04:38 -050041---
42 src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c | 8 +++++++-
43 src/libstrongswan/plugins/openssl/openssl_diffie_hellman.h | 4 +++-
44 src/libstrongswan/plugins/openssl/openssl_plugin.c | 1 +
45 3 files changed, 11 insertions(+), 2 deletions(-)
46
47diff --git a/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c b/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c
Brad Bishop316dfdd2018-06-25 12:45:53 -040048index 8e9c118..a73b038 100644
Patrick Williamsb48b7b42016-08-17 15:04:38 -050049--- a/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c
50+++ b/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.c
Brad Bishop316dfdd2018-06-25 12:45:53 -040051@@ -192,7 +192,7 @@ METHOD(diffie_hellman_t, destroy, void,
Patrick Williamsb48b7b42016-08-17 15:04:38 -050052 /*
53 * Described in header.
54 */
55-openssl_diffie_hellman_t *openssl_diffie_hellman_create(
56+openssl_diffie_hellman_t *openssl_diffie_hellman_create_custom(
Brad Bishop316dfdd2018-06-25 12:45:53 -040057 diffie_hellman_group_t group, ...)
Patrick Williamsb48b7b42016-08-17 15:04:38 -050058 {
59 private_openssl_diffie_hellman_t *this;
Brad Bishop316dfdd2018-06-25 12:45:53 -040060@@ -255,5 +255,11 @@ openssl_diffie_hellman_t *openssl_diffie_hellman_create(
61 DBG2(DBG_LIB, "size of DH secret exponent: %d bits", BN_num_bits(privkey));
Patrick Williamsb48b7b42016-08-17 15:04:38 -050062 return &this->public;
63 }
64+openssl_diffie_hellman_t *openssl_diffie_hellman_create( diffie_hellman_group_t group)
65+{
66+ chunk_t g;
67+ chunk_t p;
68+ openssl_diffie_hellman_create_custom(group, g, p);
69+}
70
71 #endif /* OPENSSL_NO_DH */
72diff --git a/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.h b/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.h
Brad Bishop316dfdd2018-06-25 12:45:53 -040073index 5de5520..22586e0 100644
Patrick Williamsb48b7b42016-08-17 15:04:38 -050074--- a/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.h
75+++ b/src/libstrongswan/plugins/openssl/openssl_diffie_hellman.h
Brad Bishop316dfdd2018-06-25 12:45:53 -040076@@ -43,8 +43,10 @@ struct openssl_diffie_hellman_t {
77 * @param ... expects generator and prime as chunk_t if MODP_CUSTOM
Patrick Williamsb48b7b42016-08-17 15:04:38 -050078 * @return openssl_diffie_hellman_t object, NULL if not supported
79 */
80-openssl_diffie_hellman_t *openssl_diffie_hellman_create(
81+openssl_diffie_hellman_t *openssl_diffie_hellman_create_custom(
Brad Bishop316dfdd2018-06-25 12:45:53 -040082 diffie_hellman_group_t group, ...);
Patrick Williamsb48b7b42016-08-17 15:04:38 -050083+openssl_diffie_hellman_t *openssl_diffie_hellman_create(
84+ diffie_hellman_group_t group);
85
86 #endif /** OPENSSL_DIFFIE_HELLMAN_H_ @}*/
87
88diff --git a/src/libstrongswan/plugins/openssl/openssl_plugin.c b/src/libstrongswan/plugins/openssl/openssl_plugin.c
Brad Bishop316dfdd2018-06-25 12:45:53 -040089index 8b0a7c5..114d575 100644
Patrick Williamsb48b7b42016-08-17 15:04:38 -050090--- a/src/libstrongswan/plugins/openssl/openssl_plugin.c
91+++ b/src/libstrongswan/plugins/openssl/openssl_plugin.c
Brad Bishop316dfdd2018-06-25 12:45:53 -040092@@ -609,6 +609,7 @@ METHOD(plugin_t, get_features, int,
Patrick Williamsb48b7b42016-08-17 15:04:38 -050093 PLUGIN_PROVIDE(DH, MODP_1024_BIT),
94 PLUGIN_PROVIDE(DH, MODP_1024_160),
95 PLUGIN_PROVIDE(DH, MODP_768_BIT),
96+ PLUGIN_REGISTER(DH, openssl_diffie_hellman_create_custom),
97 PLUGIN_PROVIDE(DH, MODP_CUSTOM),
98 #endif
99 #ifndef OPENSSL_NO_RSA