MySQL 9.1.0
Source Code Documentation
encode_ptr.h
Go to the documentation of this file.
1/* Copyright (c) 2021, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 Without limiting anything contained in the foregoing, this file,
16 which is part of C Driver for MySQL (Connector/C), is also subject to the
17 Universal FOSS Exception, version 1.0, a copy of which can be found at
18 http://oss.oracle.com/licenses/universal-foss-exception.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License, version 2.0, for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
28
29#ifndef OCI_SSL_DELETERS_H
30#define OCI_SSL_DELETERS_H
31
32#include <openssl/evp.h>
33#include <openssl/pem.h>
34
35#include <memory>
36
37namespace oci {
38namespace ssl {
40 void operator()(BIO *p) const {
41 if (p) BIO_free(p);
42 }
43};
44
46 void operator()(X509 *p) const {
47 if (p) X509_free(p);
48 }
49};
50
52 void operator()(ASN1_TIME *p) const {
53 if (p) ASN1_STRING_free(p);
54 }
55};
57 void operator()(EVP_PKEY *p) const {
58 if (p) EVP_PKEY_free(p);
59 }
60};
61
63 void operator()(EVP_MD_CTX *p) const {
64#if OPENSSL_VERSION_NUMBER > 0x10100000L
65 if (p) EVP_MD_CTX_free(p);
66#else
67 // 1.0.x
68 if (p) EVP_MD_CTX_destroy(p);
69#endif
70 }
71};
72
73using BIO_ptr = std::unique_ptr<BIO, BIO_deleter>;
74using X509_ptr = std::unique_ptr<X509, X509_deleter>;
75using ASN1_TIME_ptr = std::unique_ptr<ASN1_TIME, ASN1_TIME_deleter>;
76using EVP_PKEY_ptr = std::unique_ptr<EVP_PKEY, EVP_PKEY_deleter>;
77using EVP_MD_CTX_ptr = std::unique_ptr<EVP_MD_CTX, EVP_MD_CTX_deleter>;
78
79} // namespace ssl
80} // namespace oci
81#endif // OCI_SSL_DELETERS_H
const char * p
Definition: ctype-mb.cc:1225
constexpr value_type ssl
Definition: classic_protocol_constants.h:49
std::unique_ptr< EVP_MD_CTX, EVP_MD_CTX_deleter > EVP_MD_CTX_ptr
Definition: encode_ptr.h:77
std::unique_ptr< X509, X509_deleter > X509_ptr
Definition: encode_ptr.h:74
std::unique_ptr< ASN1_TIME, ASN1_TIME_deleter > ASN1_TIME_ptr
Definition: encode_ptr.h:75
std::unique_ptr< BIO, BIO_deleter > BIO_ptr
Definition: encode_ptr.h:73
std::unique_ptr< EVP_PKEY, EVP_PKEY_deleter > EVP_PKEY_ptr
Definition: encode_ptr.h:76
Definition: my_base64_encode.cc:41
Definition: encode_ptr.h:51
void operator()(ASN1_TIME *p) const
Definition: encode_ptr.h:52
Definition: encode_ptr.h:39
void operator()(BIO *p) const
Definition: encode_ptr.h:40
Definition: encode_ptr.h:62
void operator()(EVP_MD_CTX *p) const
Definition: encode_ptr.h:63
Definition: encode_ptr.h:56
void operator()(EVP_PKEY *p) const
Definition: encode_ptr.h:57
Definition: encode_ptr.h:45
void operator()(X509 *p) const
Definition: encode_ptr.h:46