]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/dh/dh_meth.c
2 * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 * DH low level APIs are deprecated for public use, but still ok for
14 #include "internal/deprecated.h"
18 #include <openssl/err.h>
20 DH_METHOD
*DH_meth_new(const char *name
, int flags
)
22 DH_METHOD
*dhm
= OPENSSL_zalloc(sizeof(*dhm
));
27 dhm
->name
= OPENSSL_strdup(name
);
28 if (dhm
->name
!= NULL
)
37 void DH_meth_free(DH_METHOD
*dhm
)
40 OPENSSL_free(dhm
->name
);
45 DH_METHOD
*DH_meth_dup(const DH_METHOD
*dhm
)
47 DH_METHOD
*ret
= OPENSSL_malloc(sizeof(*ret
));
50 memcpy(ret
, dhm
, sizeof(*dhm
));
52 ret
->name
= OPENSSL_strdup(dhm
->name
);
53 if (ret
->name
!= NULL
)
62 const char *DH_meth_get0_name(const DH_METHOD
*dhm
)
67 int DH_meth_set1_name(DH_METHOD
*dhm
, const char *name
)
69 char *tmpname
= OPENSSL_strdup(name
);
74 OPENSSL_free(dhm
->name
);
80 int DH_meth_get_flags(const DH_METHOD
*dhm
)
85 int DH_meth_set_flags(DH_METHOD
*dhm
, int flags
)
91 void *DH_meth_get0_app_data(const DH_METHOD
*dhm
)
96 int DH_meth_set0_app_data(DH_METHOD
*dhm
, void *app_data
)
98 dhm
->app_data
= app_data
;
102 int (*DH_meth_get_generate_key(const DH_METHOD
*dhm
)) (DH
*)
104 return dhm
->generate_key
;
107 int DH_meth_set_generate_key(DH_METHOD
*dhm
, int (*generate_key
) (DH
*))
109 dhm
->generate_key
= generate_key
;
113 int (*DH_meth_get_compute_key(const DH_METHOD
*dhm
))
114 (unsigned char *key
, const BIGNUM
*pub_key
, DH
*dh
)
116 return dhm
->compute_key
;
119 int DH_meth_set_compute_key(DH_METHOD
*dhm
,
120 int (*compute_key
) (unsigned char *key
, const BIGNUM
*pub_key
, DH
*dh
))
122 dhm
->compute_key
= compute_key
;
127 int (*DH_meth_get_bn_mod_exp(const DH_METHOD
*dhm
))
128 (const DH
*, BIGNUM
*, const BIGNUM
*, const BIGNUM
*, const BIGNUM
*,
129 BN_CTX
*, BN_MONT_CTX
*)
131 return dhm
->bn_mod_exp
;
134 int DH_meth_set_bn_mod_exp(DH_METHOD
*dhm
,
135 int (*bn_mod_exp
) (const DH
*, BIGNUM
*, const BIGNUM
*, const BIGNUM
*,
136 const BIGNUM
*, BN_CTX
*, BN_MONT_CTX
*))
138 dhm
->bn_mod_exp
= bn_mod_exp
;
142 int (*DH_meth_get_init(const DH_METHOD
*dhm
))(DH
*)
147 int DH_meth_set_init(DH_METHOD
*dhm
, int (*init
)(DH
*))
153 int (*DH_meth_get_finish(const DH_METHOD
*dhm
)) (DH
*)
158 int DH_meth_set_finish(DH_METHOD
*dhm
, int (*finish
) (DH
*))
160 dhm
->finish
= finish
;
164 int (*DH_meth_get_generate_params(const DH_METHOD
*dhm
))
165 (DH
*, int, int, BN_GENCB
*)
167 return dhm
->generate_params
;
170 int DH_meth_set_generate_params(DH_METHOD
*dhm
,
171 int (*generate_params
) (DH
*, int, int, BN_GENCB
*))
173 dhm
->generate_params
= generate_params
;