| 1 | #cxx . . $ `<file>/mlspp/lib/hpke/src/openssl_common.cpp`/include "openssl_common.h"cxx . . $ `<file>/mlspp/lib/hpke/src/openssl_common.h`/ |
| 2 | |
| 3 | #include <openssl/ec.h> |
| 4 | #include <openssl/err.h> |
| 5 | #include <openssl/evp.h> |
| 6 | #include <openssl/hmac.h> |
| 7 | #include <openssl/x509.h> |
| 8 | #include <openssl/x509v3.h> |
| 9 | #if defined(WITH_OPENSSL3cxx . . $ `<built-in>:494:9`!) |
| 10 | #include <openssl/param_build.h> |
| 11 | #endif |
| 12 | |
| 13 | namespace mlsppcxx . . $ mlspp/::hpkecxx . . $ mlspp/hpke/ { |
| 14 | |
| 15 | template<> |
| 16 | void |
| 17 | typed_deletecxx . . $ mlspp/hpke/typed_delete(2ce94ba550a584ce).(EVP_CIPHER_CTX* ptr) |
| 18 | { |
| 19 | EVP_CIPHER_CTX_free(ptr); |
| 20 | } |
| 21 | |
| 22 | #if WITH_BORINGSSL |
| 23 | template<> |
| 24 | void |
| 25 | typed_delete(EVP_AEAD_CTX* ptr) |
| 26 | { |
| 27 | EVP_AEAD_CTX_free(ptr); |
| 28 | } |
| 29 | #endif |
| 30 | |
| 31 | template<> |
| 32 | void |
| 33 | typed_deletecxx . . $ mlspp/hpke/typed_delete(c275de2071327eed).(EVP_PKEY_CTX* ptr) |
| 34 | { |
| 35 | EVP_PKEY_CTX_free(ptr); |
| 36 | } |
| 37 | |
| 38 | template<> |
| 39 | void |
| 40 | typed_deletecxx . . $ mlspp/hpke/typed_delete(8d074dd1d53079e3).(EVP_MD_CTX* ptr) |
| 41 | { |
| 42 | EVP_MD_CTX_free(ptr); |
| 43 | } |
| 44 | |
| 45 | #if !defined(WITH_OPENSSL3cxx . . $ `<built-in>:494:9`!) |
| 46 | template<> |
| 47 | void |
| 48 | typed_delete(HMAC_CTX* ptr) |
| 49 | { |
| 50 | HMAC_CTX_free(ptr); |
| 51 | } |
| 52 | #endif |
| 53 | |
| 54 | template<> |
| 55 | void |
| 56 | typed_deletecxx . . $ mlspp/hpke/typed_delete(a36cc1e96a19ea9b).(EVP_PKEY* ptr) |
| 57 | { |
| 58 | EVP_PKEY_free(ptr); |
| 59 | } |
| 60 | |
| 61 | template<> |
| 62 | void |
| 63 | typed_deletecxx . . $ mlspp/hpke/typed_delete(e4941127fbd70553).(BIGNUM* ptr) |
| 64 | { |
| 65 | BN_free(ptr); |
| 66 | } |
| 67 | |
| 68 | template<> |
| 69 | void |
| 70 | typed_deletecxx . . $ mlspp/hpke/typed_delete(697abbb1b60cc7b9).(EC_POINT* ptr) |
| 71 | { |
| 72 | EC_POINT_free(ptr); |
| 73 | } |
| 74 | |
| 75 | #if !defined(WITH_OPENSSL3cxx . . $ `<built-in>:494:9`!) |
| 76 | template<> |
| 77 | void |
| 78 | typed_delete(EC_KEY* ptr) |
| 79 | { |
| 80 | EC_KEY_free(ptr); |
| 81 | } |
| 82 | #endif |
| 83 | |
| 84 | #if defined(WITH_OPENSSL3cxx . . $ `<built-in>:494:9`!) |
| 85 | template<> |
| 86 | void |
| 87 | typed_deletecxx . . $ mlspp/hpke/typed_delete(dde995a1f512cbab).(EVP_MAC* ptr) |
| 88 | { |
| 89 | EVP_MAC_free(ptr); |
| 90 | } |
| 91 | |
| 92 | template<> |
| 93 | void |
| 94 | typed_deletecxx . . $ mlspp/hpke/typed_delete(14ae7b6e5f7c72cf).(EVP_MAC_CTX* ptr) |
| 95 | { |
| 96 | EVP_MAC_CTX_free(ptr); |
| 97 | } |
| 98 | |
| 99 | template<> |
| 100 | void |
| 101 | typed_deletecxx . . $ mlspp/hpke/typed_delete(fd1d938b2000a96a).(EC_GROUP* ptr) |
| 102 | { |
| 103 | EC_GROUP_free(ptr); |
| 104 | } |
| 105 | |
| 106 | template<> |
| 107 | void |
| 108 | typed_deletecxx . . $ mlspp/hpke/typed_delete(beb0490323ad0ae).(OSSL_PARAM_BLD* ptr) |
| 109 | { |
| 110 | OSSL_PARAM_BLD_free(ptr); |
| 111 | } |
| 112 | |
| 113 | template<> |
| 114 | void |
| 115 | typed_deletecxx . . $ mlspp/hpke/typed_delete(4b230481a833e02d).(OSSL_PARAM* ptr) |
| 116 | { |
| 117 | OSSL_PARAM_free(ptr); |
| 118 | } |
| 119 | #endif |
| 120 | |
| 121 | template<> |
| 122 | void |
| 123 | typed_deletecxx . . $ mlspp/hpke/typed_delete(6d28345afe631eba).(X509* ptr) |
| 124 | { |
| 125 | X509_free(ptr); |
| 126 | } |
| 127 | |
| 128 | template<> |
| 129 | void |
| 130 | typed_deletecxx . . $ mlspp/hpke/typed_delete(b6245f8bb08bd723).(STACK_OFcxx . . $ `<external>/13247083851530363302/safestack.h:33:9`!(GENERAL_NAME) * ptr) |
| 131 | { |
| 132 | sk_GENERAL_NAME_pop_freecxx . . $ `<external>/8547403039021081366/x509v3.h:256:9`!(ptr, GENERAL_NAME_free); |
| 133 | } |
| 134 | |
| 135 | template<> |
| 136 | void |
| 137 | typed_deletecxx . . $ mlspp/hpke/typed_delete(df970fa47995b6e6).(BIO* ptr) |
| 138 | { |
| 139 | BIO_vfree(ptr); |
| 140 | } |
| 141 | |
| 142 | template<> |
| 143 | void |
| 144 | typed_deletecxx . . $ mlspp/hpke/typed_delete(a6a55535ab2bc082).(ASN1_TIME* ptr) |
| 145 | { |
| 146 | ASN1_TIME_free(ptr); |
| 147 | } |
| 148 | |
| 149 | /// |
| 150 | /// Map OpenSSL errors to C++ exceptions |
| 151 | /// |
| 152 | |
| 153 | stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error# |
| 154 | openssl_errorcxx . . $ mlspp/hpke/openssl_error(d6ab8afd00dfc651).() |
| 155 | { |
| 156 | auto code = ERR_get_error(); |
| 157 | return stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#(ERR_error_string(code, nullptr)); |
| 158 | } |
| 159 | |
| 160 | } // namespace mlspp::hpke |