OpenVPN
openssl_compat.h
Go to the documentation of this file.
1 /*
2  * OpenVPN -- An application to securely tunnel IP networks
3  * over a single TCP/UDP port, with support for SSL/TLS-based
4  * session authentication and key exchange,
5  * packet encryption, packet authentication, and
6  * packet compression.
7  *
8  * Copyright (C) 2002-2023 OpenVPN Inc <sales@openvpn.net>
9  * Copyright (C) 2010-2021 Fox Crypto B.V. <openvpn@foxcrypto.com>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License version 2
13  * as published by the Free Software Foundation.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24 
34 #ifndef OPENSSL_COMPAT_H_
35 #define OPENSSL_COMPAT_H_
36 
37 #ifdef HAVE_CONFIG_H
38 #include "config.h"
39 #endif
40 
41 #include "buffer.h"
42 
43 #include <openssl/rsa.h>
44 #include <openssl/ssl.h>
45 #include <openssl/x509.h>
46 #include <openssl/err.h>
47 
48 /* Functionality missing in 1.1.0 */
49 #if OPENSSL_VERSION_NUMBER < 0x10101000L && !defined(ENABLE_CRYPTO_WOLFSSL)
50 #define SSL_CTX_set1_groups SSL_CTX_set1_curves
51 #endif
52 
53 /* Functionality missing in LibreSSL before 3.5 and OpenSSL 1.0.2 */
54 #if (OPENSSL_VERSION_NUMBER < 0x10100000L || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x3050000fL)) && !defined(ENABLE_CRYPTO_WOLFSSL)
55 
60 static inline void
61 X509_OBJECT_free(X509_OBJECT *obj)
62 {
63  if (obj)
64  {
65  X509_OBJECT_free_contents(obj);
66  OPENSSL_free(obj);
67  }
68 }
69 
70 #define EVP_CTRL_AEAD_SET_TAG EVP_CTRL_GCM_SET_TAG
71 #define EVP_CTRL_AEAD_GET_TAG EVP_CTRL_GCM_GET_TAG
72 #endif
73 
74 #if (OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)) && !defined(ENABLE_CRYPTO_WOLFSSL)
75 #define RSA_F_RSA_OSSL_PRIVATE_ENCRYPT RSA_F_RSA_EAY_PRIVATE_ENCRYPT
76 #endif
77 
78 #if (OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(ENABLE_CRYPTO_WOLFSSL)) || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x3050400fL)
79 #define SSL_get_peer_tmp_key SSL_get_server_tmp_key
80 #endif
81 
82 /* Functionality missing in 1.0.2 */
83 #if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(ENABLE_CRYPTO_WOLFSSL)
84 
90 static inline int
91 EVP_MD_CTX_reset(EVP_MD_CTX *ctx)
92 {
93  EVP_MD_CTX_cleanup(ctx);
94  return 1;
95 }
96 
102 static inline void
103 EVP_MD_CTX_free(EVP_MD_CTX *ctx)
104 {
105  free(ctx);
106 }
107 
113 static inline EVP_MD_CTX *
115 {
116  EVP_MD_CTX *ctx = NULL;
117  ALLOC_OBJ_CLEAR(ctx, EVP_MD_CTX);
118  return ctx;
119 }
120 
121 #define EVP_CIPHER_CTX_reset EVP_CIPHER_CTX_init
122 #define X509_get0_notBefore X509_get_notBefore
123 #define X509_get0_notAfter X509_get_notAfter
124 
140 static inline int
141 HMAC_CTX_reset(HMAC_CTX *ctx)
142 {
143  HMAC_CTX_cleanup(ctx);
144  HMAC_CTX_init(ctx);
145  return 1;
146 }
147 
153 static inline void
154 HMAC_CTX_free(HMAC_CTX *ctx)
155 {
156  HMAC_CTX_cleanup(ctx);
157  free(ctx);
158 }
159 
165 static inline HMAC_CTX *
167 {
168  HMAC_CTX *ctx = NULL;
169  ALLOC_OBJ_CLEAR(ctx, HMAC_CTX);
170  return ctx;
171 }
172 
179 static inline void *
181 {
182  return ctx ? ctx->default_passwd_callback_userdata : NULL;
183 }
184 
191 static inline pem_password_cb *
193 {
194  return ctx ? ctx->default_passwd_callback : NULL;
195 }
196 
203 static inline EVP_PKEY *
204 X509_get0_pubkey(const X509 *x)
205 {
206  return (x && x->cert_info && x->cert_info->key) ?
207  x->cert_info->key->pkey : NULL;
208 }
209 
216 static inline STACK_OF(X509_OBJECT)
217 *X509_STORE_get0_objects(X509_STORE *store)
218 {
219  return store ? store->objs : NULL;
220 }
221 
228 static inline int
229 X509_OBJECT_get_type(const X509_OBJECT *obj)
230 {
231  return obj ? obj->type : X509_LU_FAIL;
232 }
233 
240 static inline RSA *
241 EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
242 {
243  return (pkey && pkey->type == EVP_PKEY_RSA) ? pkey->pkey.rsa : NULL;
244 }
245 
252 static inline EC_KEY *
253 EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
254 {
255  return (pkey && pkey->type == EVP_PKEY_EC) ? pkey->pkey.ec : NULL;
256 }
257 
258 
265 static inline DSA *
266 EVP_PKEY_get0_DSA(EVP_PKEY *pkey)
267 {
268  return (pkey && pkey->type == EVP_PKEY_DSA) ? pkey->pkey.dsa : NULL;
269 }
270 
277 static inline void
278 RSA_set_flags(RSA *rsa, int flags)
279 {
280  if (rsa)
281  {
282  rsa->flags = flags;
283  }
284 }
285 
294 static inline void
295 RSA_get0_key(const RSA *rsa, const BIGNUM **n,
296  const BIGNUM **e, const BIGNUM **d)
297 {
298  if (n != NULL)
299  {
300  *n = rsa ? rsa->n : NULL;
301  }
302  if (e != NULL)
303  {
304  *e = rsa ? rsa->e : NULL;
305  }
306  if (d != NULL)
307  {
308  *d = rsa ? rsa->d : NULL;
309  }
310 }
311 
321 static inline int
322 RSA_set0_key(RSA *rsa, BIGNUM *n, BIGNUM *e, BIGNUM *d)
323 {
324  if ((rsa->n == NULL && n == NULL)
325  || (rsa->e == NULL && e == NULL))
326  {
327  return 0;
328  }
329 
330  if (n != NULL)
331  {
332  BN_free(rsa->n);
333  rsa->n = n;
334  }
335  if (e != NULL)
336  {
337  BN_free(rsa->e);
338  rsa->e = e;
339  }
340  if (d != NULL)
341  {
342  BN_free(rsa->d);
343  rsa->d = d;
344  }
345 
346  return 1;
347 }
348 
355 static inline int
356 RSA_bits(const RSA *rsa)
357 {
358  const BIGNUM *n = NULL;
359  RSA_get0_key(rsa, &n, NULL, NULL);
360  return n ? BN_num_bits(n) : 0;
361 }
362 
371 static inline void
372 DSA_get0_pqg(const DSA *dsa, const BIGNUM **p,
373  const BIGNUM **q, const BIGNUM **g)
374 {
375  if (p != NULL)
376  {
377  *p = dsa ? dsa->p : NULL;
378  }
379  if (q != NULL)
380  {
381  *q = dsa ? dsa->q : NULL;
382  }
383  if (g != NULL)
384  {
385  *g = dsa ? dsa->g : NULL;
386  }
387 }
388 
395 static inline int
396 DSA_bits(const DSA *dsa)
397 {
398  const BIGNUM *p = NULL;
399  DSA_get0_pqg(dsa, &p, NULL, NULL);
400  return p ? BN_num_bits(p) : 0;
401 }
402 
410 static inline RSA_METHOD *
411 RSA_meth_new(const char *name, int flags)
412 {
413  RSA_METHOD *rsa_meth = NULL;
414  ALLOC_OBJ_CLEAR(rsa_meth, RSA_METHOD);
415  rsa_meth->name = string_alloc(name, NULL);
416  rsa_meth->flags = flags;
417  return rsa_meth;
418 }
419 
425 static inline void
426 RSA_meth_free(RSA_METHOD *meth)
427 {
428  if (meth)
429  {
430  /* OpenSSL defines meth->name to be a const pointer, yet we
431  * feed it with an allocated string (from RSA_meth_new()).
432  * Thus we are allowed to free it here. In order to avoid a
433  * "passing 'const char *' to parameter of type 'void *' discards
434  * qualifiers" warning, we force the pointer to be a non-const value.
435  */
436  free((char *)meth->name);
437  free(meth);
438  }
439 }
440 
448 static inline int
449 RSA_meth_set_pub_enc(RSA_METHOD *meth,
450  int (*pub_enc)(int flen, const unsigned char *from,
451  unsigned char *to, RSA *rsa,
452  int padding))
453 {
454  if (meth)
455  {
456  meth->rsa_pub_enc = pub_enc;
457  return 1;
458  }
459  return 0;
460 }
461 
469 static inline int
470 RSA_meth_set_pub_dec(RSA_METHOD *meth,
471  int (*pub_dec)(int flen, const unsigned char *from,
472  unsigned char *to, RSA *rsa,
473  int padding))
474 {
475  if (meth)
476  {
477  meth->rsa_pub_dec = pub_dec;
478  return 1;
479  }
480  return 0;
481 }
482 
490 static inline int
491 RSA_meth_set_priv_enc(RSA_METHOD *meth,
492  int (*priv_enc)(int flen, const unsigned char *from,
493  unsigned char *to, RSA *rsa,
494  int padding))
495 {
496  if (meth)
497  {
498  meth->rsa_priv_enc = priv_enc;
499  return 1;
500  }
501  return 0;
502 }
503 
511 static inline int
512 RSA_meth_set_priv_dec(RSA_METHOD *meth,
513  int (*priv_dec)(int flen, const unsigned char *from,
514  unsigned char *to, RSA *rsa,
515  int padding))
516 {
517  if (meth)
518  {
519  meth->rsa_priv_dec = priv_dec;
520  return 1;
521  }
522  return 0;
523 }
524 
532 static inline int
533 RSA_meth_set_init(RSA_METHOD *meth, int (*init)(RSA *rsa))
534 {
535  if (meth)
536  {
537  meth->init = init;
538  return 1;
539  }
540  return 0;
541 }
542 
550 static inline
551 int
552 RSA_meth_set_sign(RSA_METHOD *meth,
553  int (*sign)(int type, const unsigned char *m,
554  unsigned int m_length,
555  unsigned char *sigret, unsigned int *siglen,
556  const RSA *rsa))
557 {
558  meth->rsa_sign = sign;
559  return 1;
560 }
561 
569 static inline int
570 RSA_meth_set_finish(RSA_METHOD *meth, int (*finish)(RSA *rsa))
571 {
572  if (meth)
573  {
574  meth->finish = finish;
575  return 1;
576  }
577  return 0;
578 }
579 
587 static inline int
588 RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data)
589 {
590  if (meth)
591  {
592  meth->app_data = app_data;
593  return 1;
594  }
595  return 0;
596 }
597 
604 static inline void *
605 RSA_meth_get0_app_data(const RSA_METHOD *meth)
606 {
607  return meth ? meth->app_data : NULL;
608 }
609 
616 static inline int
617 EC_GROUP_order_bits(const EC_GROUP *group)
618 {
619  BIGNUM *order = BN_new();
620  EC_GROUP_get_order(group, order, NULL);
621  int bits = BN_num_bits(order);
622  BN_free(order);
623  return bits;
624 }
625 
626 /* SSLeay symbols have been renamed in OpenSSL 1.1 */
627 #define OPENSSL_VERSION SSLEAY_VERSION
628 #define OpenSSL_version SSLeay_version
629 
632 static inline int
634 {
635  long sslopt = SSL_CTX_get_options(ctx);
636  if (!(sslopt & SSL_OP_NO_TLSv1))
637  {
638  return TLS1_VERSION;
639  }
640  if (!(sslopt & SSL_OP_NO_TLSv1_1))
641  {
642  return TLS1_1_VERSION;
643  }
644  if (!(sslopt & SSL_OP_NO_TLSv1_2))
645  {
646  return TLS1_2_VERSION;
647  }
648  return 0;
649 }
650 
653 static inline int
655 {
656  long sslopt = SSL_CTX_get_options(ctx);
657  if (!(sslopt & SSL_OP_NO_TLSv1_2))
658  {
659  return TLS1_2_VERSION;
660  }
661  if (!(sslopt & SSL_OP_NO_TLSv1_1))
662  {
663  return TLS1_1_VERSION;
664  }
665  if (!(sslopt & SSL_OP_NO_TLSv1))
666  {
667  return TLS1_VERSION;
668  }
669  return 0;
670 }
671 
673 static inline int
674 SSL_CTX_set_min_proto_version(SSL_CTX *ctx, long tls_ver_min)
675 {
676  long sslopt = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3; /* Never do < TLS 1.0 */
677 
678  if (tls_ver_min > TLS1_VERSION)
679  {
680  sslopt |= SSL_OP_NO_TLSv1;
681  }
682 #ifdef SSL_OP_NO_TLSv1_1
683  if (tls_ver_min > TLS1_1_VERSION)
684  {
685  sslopt |= SSL_OP_NO_TLSv1_1;
686  }
687 #endif
688 #ifdef SSL_OP_NO_TLSv1_2
689  if (tls_ver_min > TLS1_2_VERSION)
690  {
691  sslopt |= SSL_OP_NO_TLSv1_2;
692  }
693 #endif
694  SSL_CTX_set_options(ctx, sslopt);
695 
696  return 1;
697 }
698 
700 static inline int
701 SSL_CTX_set_max_proto_version(SSL_CTX *ctx, long tls_ver_max)
702 {
703  long sslopt = 0;
704 
705  if (tls_ver_max < TLS1_VERSION)
706  {
707  sslopt |= SSL_OP_NO_TLSv1;
708  }
709 #ifdef SSL_OP_NO_TLSv1_1
710  if (tls_ver_max < TLS1_1_VERSION)
711  {
712  sslopt |= SSL_OP_NO_TLSv1_1;
713  }
714 #endif
715 #ifdef SSL_OP_NO_TLSv1_2
716  if (tls_ver_max < TLS1_2_VERSION)
717  {
718  sslopt |= SSL_OP_NO_TLSv1_2;
719  }
720 #endif
721  SSL_CTX_set_options(ctx, sslopt);
722 
723  return 1;
724 }
725 #endif /* if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(ENABLE_CRYPTO_WOLFSSL) */
726 
727 /* Functionality missing in 1.1.1 */
728 #if OPENSSL_VERSION_NUMBER < 0x30000000L && !defined(OPENSSL_NO_EC)
729 
730 /* Note that this is not a perfect emulation of the new function but
731  * is good enough for our case of printing certificate details during
732  * handshake */
733 static inline
734 int
735 EVP_PKEY_get_group_name(EVP_PKEY *pkey, char *gname, size_t gname_sz,
736  size_t *gname_len)
737 {
738  const EC_KEY *ec = EVP_PKEY_get0_EC_KEY(pkey);
739  if (ec == NULL)
740  {
741  return 0;
742  }
743  const EC_GROUP *group = EC_KEY_get0_group(ec);
744  int nid = EC_GROUP_get_curve_name(group);
745 
746  if (nid == 0)
747  {
748  return 0;
749  }
750  const char *curve = OBJ_nid2sn(nid);
751  if (!curve)
752  {
753  curve = "(error fetching curve name)";
754  }
755 
756  strncpynt(gname, curve, gname_sz);
757 
758  /* strncpynt ensures null termination so just strlen is fine here */
759  *gname_len = strlen(curve);
760  return 1;
761 }
762 #endif /* if OPENSSL_VERSION_NUMBER < 0x30000000L && !defined(OPENSSL_NO_EC) */
763 
764 #if OPENSSL_VERSION_NUMBER < 0x30000000L
765 #define EVP_MD_get0_name EVP_MD_name
766 #define EVP_CIPHER_get0_name EVP_CIPHER_name
767 #define EVP_CIPHER_CTX_get_mode EVP_CIPHER_CTX_mode
768 
770 #define SSL_CTX_new_ex(libctx, propq, method) \
771  SSL_CTX_new((method))
772 
773 /* Some safe typedefs to avoid too many ifdefs */
774 typedef void OSSL_LIB_CTX;
775 typedef void OSSL_PROVIDER;
776 
777 /* Mimics the functions but only when the default context without
778  * options is chosen */
779 static inline const EVP_CIPHER *
780 EVP_CIPHER_fetch(void *ctx, const char *algorithm, const char *properties)
781 {
782  ASSERT(!ctx);
783  ASSERT(!properties);
784  return EVP_get_cipherbyname(algorithm);
785 }
786 
787 static inline const EVP_MD *
788 EVP_MD_fetch(void *ctx, const char *algorithm, const char *properties)
789 {
790  ASSERT(!ctx);
791  ASSERT(!properties);
792  return EVP_get_digestbyname(algorithm);
793 }
794 
795 static inline void
796 EVP_CIPHER_free(const EVP_CIPHER *cipher)
797 {
798  /* OpenSSL 1.1.1 and lower use only const EVP_CIPHER, nothing to free */
799 }
800 
801 static inline void
802 EVP_MD_free(const EVP_MD *md)
803 {
804  /* OpenSSL 1.1.1 and lower use only const EVP_MD, nothing to free */
805 }
806 
807 static inline unsigned long
808 ERR_get_error_all(const char **file, int *line,
809  const char **func,
810  const char **data, int *flags)
811 {
812  static const char *empty = "";
813  *func = empty;
814  unsigned long err = ERR_get_error_line_data(file, line, data, flags);
815  return err;
816 }
817 
818 #endif /* OPENSSL_VERSION_NUMBER < 0x30000000L */
819 
820 #endif /* OPENSSL_COMPAT_H_ */
EVP_CIPHER_free
static void EVP_CIPHER_free(const EVP_CIPHER *cipher)
Definition: openssl_compat.h:796
EVP_PKEY_get0_RSA
static RSA * EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
Get the RSA object of a public key.
Definition: openssl_compat.h:241
HMAC_CTX_new
static HMAC_CTX * HMAC_CTX_new(void)
Allocate a new HMAC context object.
Definition: openssl_compat.h:166
HMAC_CTX_free
static void HMAC_CTX_free(HMAC_CTX *ctx)
Cleanup and free an existing HMAC context.
Definition: openssl_compat.h:154
EVP_MD_fetch
static const EVP_MD * EVP_MD_fetch(void *ctx, const char *algorithm, const char *properties)
Definition: openssl_compat.h:788
RSA_meth_set_priv_dec
static int RSA_meth_set_priv_dec(RSA_METHOD *meth, int(*priv_dec)(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding))
Set the private decoding function of an RSA_METHOD object.
Definition: openssl_compat.h:512
EVP_MD_CTX_new
static EVP_MD_CTX * EVP_MD_CTX_new(void)
Allocate a new message digest object.
Definition: openssl_compat.h:114
DSA_bits
static int DSA_bits(const DSA *dsa)
Number of significant DSA bits.
Definition: openssl_compat.h:396
EVP_MD_CTX_reset
static int EVP_MD_CTX_reset(EVP_MD_CTX *ctx)
Reset a message digest context.
Definition: openssl_compat.h:91
RSA_meth_set_finish
static int RSA_meth_set_finish(RSA_METHOD *meth, int(*finish)(RSA *rsa))
Set the finish function of an RSA_METHOD object.
Definition: openssl_compat.h:570
EVP_MD_free
static void EVP_MD_free(const EVP_MD *md)
Definition: openssl_compat.h:802
EVP_CIPHER_fetch
static const EVP_CIPHER * EVP_CIPHER_fetch(void *ctx, const char *algorithm, const char *properties)
Definition: openssl_compat.h:780
EVP_PKEY_get0_DSA
static DSA * EVP_PKEY_get0_DSA(EVP_PKEY *pkey)
Get the DSA object of a public key.
Definition: openssl_compat.h:266
EC_GROUP_order_bits
static int EC_GROUP_order_bits(const EC_GROUP *group)
Gets the number of bits of the order of an EC_GROUP.
Definition: openssl_compat.h:617
RSA_set_flags
static void RSA_set_flags(RSA *rsa, int flags)
Set the RSA flags.
Definition: openssl_compat.h:278
string_alloc
char * string_alloc(const char *str, struct gc_arena *gc)
Definition: buffer.c:693
RSA_meth_new
static RSA_METHOD * RSA_meth_new(const char *name, int flags)
Allocate a new RSA method object.
Definition: openssl_compat.h:411
ASSERT
#define ASSERT(x)
Definition: error.h:201
SSL_CTX_get_default_passwd_cb_userdata
static void * SSL_CTX_get_default_passwd_cb_userdata(SSL_CTX *ctx)
Fetch the default password callback user data from the SSL context.
Definition: openssl_compat.h:180
STACK_OF
static STACK_OF(X509_OBJECT) *X509_STORE_get0_objects(X509_STORE *store)
Fetch the X509 object stack from the X509 store.
Definition: openssl_compat.h:216
RSA_meth_set_init
static int RSA_meth_set_init(RSA_METHOD *meth, int(*init)(RSA *rsa))
Set the init function of an RSA_METHOD object.
Definition: openssl_compat.h:533
RSA_meth_set_priv_enc
static int RSA_meth_set_priv_enc(RSA_METHOD *meth, int(*priv_enc)(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding))
Set the private encoding function of an RSA_METHOD object.
Definition: openssl_compat.h:491
SSL_CTX_get_min_proto_version
static int SSL_CTX_get_min_proto_version(SSL_CTX *ctx)
Return the min SSL protocol version currently enabled in the context.
Definition: openssl_compat.h:633
SSL_CTX_set_max_proto_version
static int SSL_CTX_set_max_proto_version(SSL_CTX *ctx, long tls_ver_max)
Mimics SSL_CTX_set_max_proto_version for OpenSSL < 1.1.
Definition: openssl_compat.h:701
ERR_get_error_all
static unsigned long ERR_get_error_all(const char **file, int *line, const char **func, const char **data, int *flags)
Definition: openssl_compat.h:808
RSA_get0_key
static void RSA_get0_key(const RSA *rsa, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
Get the RSA parameters.
Definition: openssl_compat.h:295
X509_get0_pubkey
static EVP_PKEY * X509_get0_pubkey(const X509 *x)
Get the public key from a X509 certificate.
Definition: openssl_compat.h:204
DSA_get0_pqg
static void DSA_get0_pqg(const DSA *dsa, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g)
Get the DSA parameters.
Definition: openssl_compat.h:372
EVP_MD_CTX_free
static void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
Free an existing message digest context.
Definition: openssl_compat.h:103
SSL_CTX_get_max_proto_version
static int SSL_CTX_get_max_proto_version(SSL_CTX *ctx)
Return the max SSL protocol version currently enabled in the context.
Definition: openssl_compat.h:654
X509_OBJECT_get_type
static int X509_OBJECT_get_type(const X509_OBJECT *obj)
Get the type of an X509 object.
Definition: openssl_compat.h:229
buffer.h
RSA_meth_get0_app_data
static void * RSA_meth_get0_app_data(const RSA_METHOD *meth)
Get the application data of an RSA_METHOD object.
Definition: openssl_compat.h:605
SSL_CTX_get_default_passwd_cb
static pem_password_cb * SSL_CTX_get_default_passwd_cb(SSL_CTX *ctx)
Fetch the default password callback from the SSL context.
Definition: openssl_compat.h:192
X509_OBJECT_free
static void X509_OBJECT_free(X509_OBJECT *obj)
Destroy a X509 object.
Definition: openssl_compat.h:61
init
static int init(void **state)
Definition: test_pkcs11.c:189
RSA_meth_set_pub_enc
static int RSA_meth_set_pub_enc(RSA_METHOD *meth, int(*pub_enc)(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding))
Set the public encoding function of an RSA_METHOD object.
Definition: openssl_compat.h:449
EVP_PKEY_get_group_name
static int EVP_PKEY_get_group_name(EVP_PKEY *pkey, char *gname, size_t gname_sz, size_t *gname_len)
Definition: openssl_compat.h:735
RSA_meth_set_pub_dec
static int RSA_meth_set_pub_dec(RSA_METHOD *meth, int(*pub_dec)(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding))
Set the public decoding function of an RSA_METHOD object.
Definition: openssl_compat.h:470
strncpynt
static void strncpynt(char *dest, const char *src, size_t maxlen)
Definition: buffer.h:361
RSA_set0_key
static int RSA_set0_key(RSA *rsa, BIGNUM *n, BIGNUM *e, BIGNUM *d)
Set the RSA parameters.
Definition: openssl_compat.h:322
SSL_CTX_set_min_proto_version
static int SSL_CTX_set_min_proto_version(SSL_CTX *ctx, long tls_ver_min)
Mimics SSL_CTX_set_min_proto_version for OpenSSL < 1.1.
Definition: openssl_compat.h:674
EVP_PKEY_get0_EC_KEY
static EC_KEY * EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
Get the EC_KEY object of a public key.
Definition: openssl_compat.h:253
ALLOC_OBJ_CLEAR
#define ALLOC_OBJ_CLEAR(dptr, type)
Definition: buffer.h:1066
RSA_meth_set0_app_data
static int RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data)
Set the application data of an RSA_METHOD object.
Definition: openssl_compat.h:588
OSSL_PROVIDER
void OSSL_PROVIDER
Definition: openssl_compat.h:775
config.h
RSA_meth_free
static void RSA_meth_free(RSA_METHOD *meth)
Free an existing RSA_METHOD object.
Definition: openssl_compat.h:426
RSA_bits
static int RSA_bits(const RSA *rsa)
Number of significant RSA bits.
Definition: openssl_compat.h:356
HMAC_CTX_reset
static int HMAC_CTX_reset(HMAC_CTX *ctx)
Reset a HMAC context.
Definition: openssl_compat.h:141
RSA_meth_set_sign
static int RSA_meth_set_sign(RSA_METHOD *meth, int(*sign)(int type, const unsigned char *m, unsigned int m_length, unsigned char *sigret, unsigned int *siglen, const RSA *rsa))
Set the sign function of an RSA_METHOD object.
Definition: openssl_compat.h:552
OSSL_LIB_CTX
void OSSL_LIB_CTX
Definition: openssl_compat.h:774