| 1 |
/* |
| 2 |
* Copyright (c) 2016, Kungliga Tekniska Högskolan |
| 3 |
* (Royal Institute of Technology, Stockholm, Sweden). |
| 4 |
* All rights reserved. |
| 5 |
* |
| 6 |
* Redistribution and use in source and binary forms, with or without |
| 7 |
* modification, are permitted provided that the following conditions |
| 8 |
* are met: |
| 9 |
* |
| 10 |
* - Redistributions of source code must retain the above copyright |
| 11 |
* notice, this list of conditions and the following disclaimer. |
| 12 |
* |
| 13 |
* - Redistributions in binary form must reproduce the above copyright |
| 14 |
* notice, this list of conditions and the following disclaimer in |
| 15 |
* the documentation and/or other materials provided with the |
| 16 |
* distribution. |
| 17 |
* |
| 18 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 21 |
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 22 |
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
| 23 |
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 24 |
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 25 |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 26 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 27 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 29 |
* OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 |
*/ |
| 31 |
|
| 32 |
/* OpenSSL provider */ |
| 33 |
|
| 34 |
#include "config.h" |
| 35 |
#include <roken.h> |
| 36 |
#include <heimbase.h> |
| 37 |
|
| 38 |
#include <assert.h> |
| 39 |
#include <evp.h> |
| 40 |
|
| 41 |
#ifdef HAVE_HCRYPTO_W_OPENSSL |
| 42 |
|
| 43 |
/* |
| 44 |
* This is the OpenSSL 1.x backend for hcrypto. It has been tested with |
| 45 |
* OpenSSL 1.0.1f and OpenSSL 1.1.0-pre3-dev. |
| 46 |
* |
| 47 |
* NOTE: In order for this to work with OpenSSL 1.1.x and up, it is |
| 48 |
* critical to use opaque OpenSSL type accessors everywhere / |
| 49 |
* never use knowledge of opaque OpenSSL type internals. |
| 50 |
*/ |
| 51 |
|
| 52 |
#include <evp-openssl.h> |
| 53 |
|
| 54 |
/* |
| 55 |
* This being an OpenSSL backend for hcrypto... we need to be able to |
| 56 |
* refer to types and objects (functions) from both, OpenSSL and |
| 57 |
* hcrypto. |
| 58 |
* |
| 59 |
* The hcrypto API is *very* similar to the OpenSSL 1.0.x API, with the |
| 60 |
* same type and symbol names in many cases, except that the hcrypto |
| 61 |
* names are prefixed with hc_*. hcrypto has convenience macros that |
| 62 |
* provide OpenSSL aliases for the hcrypto interfaces, and hcrypto |
| 63 |
* applications are expected to use the OpenSSL names. |
| 64 |
* |
| 65 |
* Since here we must be able to refer to types and objects from both |
| 66 |
* OpenSSL and from hcrypto, we disable the hcrypto renaming for the |
| 67 |
* rest of this file. These #undefs could be collected into an |
| 68 |
* <hcrypto/undef.h> for the purpose of permitting other applications to |
| 69 |
* use both, hcrypto and OpenSSL in the same source files (provided that |
| 70 |
* such applications refer to hcrypto types and objects by their proper |
| 71 |
* hc_-prefixed names). |
| 72 |
*/ |
| 73 |
#include <undef.h> |
| 74 |
|
| 75 |
/* Now it's safe to include OpenSSL headers */ |
| 76 |
#include <openssl/evp.h> |
| 77 |
|
| 78 |
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) |
| 79 |
#define EVP_MD_CTX_new EVP_MD_CTX_create |
| 80 |
#define EVP_MD_CTX_free EVP_MD_CTX_destroy |
| 81 |
#endif |
| 82 |
|
| 83 |
/* A HEIM_BASE_ONCE argument struct for per-EVP one-time initialization */ |
| 84 |
struct once_init_cipher_ctx { |
| 85 |
const hc_EVP_CIPHER **hc_memoizep; |
| 86 |
hc_EVP_CIPHER *hc_memoize; |
| 87 |
const hc_EVP_CIPHER *fallback; |
| 88 |
unsigned long flags; |
| 89 |
int nid; |
| 90 |
}; |
| 91 |
|
| 92 |
/* Our wrapper for OpenSSL EVP_CIPHER_CTXs */ |
| 93 |
struct ossl_cipher_ctx { |
| 94 |
EVP_CIPHER_CTX *ossl_cipher_ctx; /* OpenSSL cipher ctx */ |
| 95 |
const EVP_CIPHER *ossl_cipher; /* OpenSSL cipher */ |
| 96 |
int initialized; |
| 97 |
}; |
| 98 |
|
| 99 |
/* |
| 100 |
* Our hc_EVP_CIPHER init() method; wraps around OpenSSL |
| 101 |
* EVP_CipherInit_ex(). |
| 102 |
* |
| 103 |
* This is very similar to the init() function pointer in an OpenSSL |
| 104 |
* EVP_CIPHER, but a) we can't access them in 1.1, and b) the method |
| 105 |
* invocation protocols in hcrypto and OpenSSL are similar but not the |
| 106 |
* same, thus we must have this wrapper. |
| 107 |
*/ |
| 108 |
static int |
| 109 |
cipher_ctx_init(hc_EVP_CIPHER_CTX *ctx, const unsigned char *key, |
| 110 |
const unsigned char *iv, int enc) |
| 111 |
{ |
| 112 |
struct ossl_cipher_ctx *ossl_ctx = ctx->cipher_data; /* EVP_CIPHER_CTX wrapper */ |
| 113 |
const EVP_CIPHER *c; |
| 114 |
|
| 115 |
assert(ossl_ctx != NULL); |
| 116 |
assert(ctx->cipher != NULL); |
| 117 |
assert(ctx->cipher->app_data != NULL); |
| 118 |
|
| 119 |
/* |
| 120 |
* Here be dragons. |
| 121 |
* |
| 122 |
* We need to make sure that the OpenSSL EVP_CipherInit_ex() is |
| 123 |
* called with cipher!=NULL just once per EVP_CIPHER_CTX, otherwise |
| 124 |
* state in the OpenSSL EVP_CIPHER_CTX will get cleaned up and then |
| 125 |
* we'll segfault. |
| 126 |
* |
| 127 |
* hcrypto applications can re-initialize an (hc_)EVP_CIPHER_CTX as |
| 128 |
* usual by calling (hc)EVP_CipherInit_ex() with a non-NULL cipher |
| 129 |
* argument, and that will cause cipher_cleanup() (below) to be |
| 130 |
* called. |
| 131 |
*/ |
| 132 |
c = ossl_ctx->ossl_cipher = ctx->cipher->app_data; /* OpenSSL's EVP_CIPHER * */ |
| 133 |
if (!ossl_ctx->initialized) { |
| 134 |
ossl_ctx->ossl_cipher_ctx = EVP_CIPHER_CTX_new(); |
| 135 |
if (ossl_ctx->ossl_cipher_ctx == NULL) |
| 136 |
return 0; |
| 137 |
/* |
| 138 |
* So we always call EVP_CipherInit_ex() with c!=NULL, but other |
| 139 |
* things NULL... |
| 140 |
*/ |
| 141 |
if (!EVP_CipherInit_ex(ossl_ctx->ossl_cipher_ctx, c, NULL, NULL, NULL, enc)) |
| 142 |
return 0; |
| 143 |
ossl_ctx->initialized = 1; |
| 144 |
} |
| 145 |
|
| 146 |
/* ...and from here on always call EVP_CipherInit_ex() with c=NULL */ |
| 147 |
if ((ctx->cipher->flags & hc_EVP_CIPH_VARIABLE_LENGTH) && |
| 148 |
ctx->key_len > 0) |
| 149 |
EVP_CIPHER_CTX_set_key_length(ossl_ctx->ossl_cipher_ctx, ctx->key_len); |
| 150 |
|
| 151 |
return EVP_CipherInit_ex(ossl_ctx->ossl_cipher_ctx, NULL, NULL, key, iv, enc); |
| 152 |
} |
| 153 |
|
| 154 |
static int |
| 155 |
cipher_do_cipher(hc_EVP_CIPHER_CTX *ctx, unsigned char *out, |
| 156 |
const unsigned char *in, unsigned int len) |
| 157 |
{ |
| 158 |
struct ossl_cipher_ctx *ossl_ctx = ctx->cipher_data; |
| 159 |
|
| 160 |
assert(ossl_ctx != NULL); |
| 161 |
return EVP_Cipher(ossl_ctx->ossl_cipher_ctx, out, in, len); |
| 162 |
} |
| 163 |
|
| 164 |
static int |
| 165 |
cipher_cleanup(hc_EVP_CIPHER_CTX *ctx) |
| 166 |
{ |
| 167 |
struct ossl_cipher_ctx *ossl_ctx = ctx->cipher_data; |
| 168 |
|
| 169 |
if (ossl_ctx == NULL || !ossl_ctx->initialized) |
| 170 |
return 1; |
| 171 |
|
| 172 |
if (ossl_ctx->ossl_cipher_ctx != NULL) |
| 173 |
EVP_CIPHER_CTX_free(ossl_ctx->ossl_cipher_ctx); |
| 174 |
|
| 175 |
ossl_ctx->ossl_cipher_ctx = NULL; |
| 176 |
ossl_ctx->ossl_cipher = NULL; |
| 177 |
ossl_ctx->initialized = 0; |
| 178 |
return 1; |
| 179 |
} |
| 180 |
|
| 181 |
static int |
| 182 |
cipher_ctrl(hc_EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) |
| 183 |
{ |
| 184 |
struct ossl_cipher_ctx *ossl_ctx = ctx->cipher_data; |
| 185 |
|
| 186 |
assert(ossl_ctx != NULL); |
| 187 |
return EVP_CIPHER_CTX_ctrl(ossl_ctx->ossl_cipher_ctx, type, arg, ptr); |
| 188 |
} |
| 189 |
|
| 190 |
|
| 191 |
static void |
| 192 |
get_EVP_CIPHER_once_cb(void *d) |
| 193 |
{ |
| 194 |
struct once_init_cipher_ctx *arg = d; |
| 195 |
const EVP_CIPHER *ossl_evp; |
| 196 |
hc_EVP_CIPHER *hc_evp; |
| 197 |
|
| 198 |
hc_evp = arg->hc_memoize; |
| 199 |
|
| 200 |
/* |
| 201 |
* We lookup EVP_CIPHER *s by NID so that we don't fail to find a |
| 202 |
* symbol such as EVP_aes...() when libcrypto changes after build |
| 203 |
* time (e.g., updates, LD_LIBRARY_PATH/LD_PRELOAD). |
| 204 |
*/ |
| 205 |
ossl_evp = EVP_get_cipherbynid(arg->nid); |
| 206 |
if (ossl_evp == NULL) { |
| 207 |
(void) memset(hc_evp, 0, sizeof(*hc_evp)); |
| 208 |
#if HCRYPTO_FALLBACK |
| 209 |
*arg->hc_memoizep = arg->fallback; |
| 210 |
#endif |
| 211 |
return; |
| 212 |
} |
| 213 |
|
| 214 |
/* Build the hc_EVP_CIPHER */ |
| 215 |
hc_evp->nid = EVP_CIPHER_nid(ossl_evp); /* We would an hcrypto NIDs if we had them */ |
| 216 |
hc_evp->block_size = EVP_CIPHER_block_size(ossl_evp); |
| 217 |
hc_evp->key_len = EVP_CIPHER_key_length(ossl_evp); |
| 218 |
hc_evp->iv_len = EVP_CIPHER_iv_length(ossl_evp); |
| 219 |
|
| 220 |
/* |
| 221 |
* We force hc_EVP_CipherInit_ex to always call our init() function, |
| 222 |
* otherwise we don't get a chance to call EVP_CipherInit_ex() |
| 223 |
* correctly. |
| 224 |
*/ |
| 225 |
hc_evp->flags = hc_EVP_CIPH_ALWAYS_CALL_INIT | arg->flags; |
| 226 |
|
| 227 |
/* Our cipher context */ |
| 228 |
hc_evp->ctx_size = sizeof(struct ossl_cipher_ctx); |
| 229 |
|
| 230 |
/* Our wrappers */ |
| 231 |
hc_evp->init = cipher_ctx_init; |
| 232 |
hc_evp->do_cipher = cipher_do_cipher; |
| 233 |
hc_evp->cleanup = cipher_cleanup; |
| 234 |
hc_evp->set_asn1_parameters = NULL; |
| 235 |
hc_evp->get_asn1_parameters = NULL; |
| 236 |
hc_evp->ctrl = cipher_ctrl; |
| 237 |
|
| 238 |
/* Our link to the OpenSSL EVP_CIPHER */ |
| 239 |
hc_evp->app_data = (void *)ossl_evp; |
| 240 |
|
| 241 |
/* Finally, set the static hc_EVP_CIPHER * to the one we just built */ |
| 242 |
*arg->hc_memoizep = hc_evp; |
| 243 |
} |
| 244 |
|
| 245 |
static const hc_EVP_CIPHER * |
| 246 |
get_EVP_CIPHER(heim_base_once_t *once, hc_EVP_CIPHER *hc_memoize, |
| 247 |
const hc_EVP_CIPHER **hc_memoizep, |
| 248 |
const hc_EVP_CIPHER *fallback, |
| 249 |
unsigned long flags, int nid) |
| 250 |
{ |
| 251 |
struct once_init_cipher_ctx arg; |
| 252 |
|
| 253 |
arg.flags = flags; |
| 254 |
arg.hc_memoizep = hc_memoizep; |
| 255 |
arg.hc_memoize = hc_memoize; |
| 256 |
arg.fallback = fallback; |
| 257 |
arg.nid = nid; |
| 258 |
heim_base_once_f(once, &arg, get_EVP_CIPHER_once_cb); |
| 259 |
return *hc_memoizep; /* May be NULL */ |
| 260 |
} |
| 261 |
|
| 262 |
#define OSSL_CIPHER_ALGORITHM(name, flags) \ |
| 263 |
extern const hc_EVP_CIPHER *hc_EVP_hcrypto_##name(void); \ |
| 264 |
const hc_EVP_CIPHER *hc_EVP_ossl_##name(void) \ |
| 265 |
{ \ |
| 266 |
static hc_EVP_CIPHER ossl_##name##_st; \ |
| 267 |
static const hc_EVP_CIPHER *ossl_##name; \ |
| 268 |
static heim_base_once_t once = HEIM_BASE_ONCE_INIT; \ |
| 269 |
return get_EVP_CIPHER(&once, &ossl_##name##_st, &ossl_##name, \ |
| 270 |
hc_EVP_hcrypto_##name(), \ |
| 271 |
flags, NID_##name); \ |
| 272 |
} |
| 273 |
|
| 274 |
/* As above, but for EVP_MDs */ |
| 275 |
|
| 276 |
struct ossl_md_ctx { |
| 277 |
EVP_MD_CTX *ossl_md_ctx; /* OpenSSL md ctx */ |
| 278 |
const EVP_MD *ossl_md; /* OpenSSL md */ |
| 279 |
int initialized; |
| 280 |
}; |
| 281 |
|
| 282 |
static int |
| 283 |
ossl_md_init(struct ossl_md_ctx *ctx, const EVP_MD *md) |
| 284 |
{ |
| 285 |
if (ctx->initialized) |
| 286 |
EVP_MD_CTX_free(ctx->ossl_md_ctx); |
| 287 |
ctx->initialized = 0; |
| 288 |
|
| 289 |
ctx->ossl_md = md; |
| 290 |
ctx->ossl_md_ctx = EVP_MD_CTX_new(); |
| 291 |
if (!EVP_DigestInit(ctx->ossl_md_ctx, md)) { |
| 292 |
EVP_MD_CTX_free(ctx->ossl_md_ctx); |
| 293 |
ctx->ossl_md_ctx = NULL; |
| 294 |
ctx->ossl_md = NULL; |
| 295 |
return 0; |
| 296 |
} |
| 297 |
ctx->initialized = 1; |
| 298 |
return 1; |
| 299 |
} |
| 300 |
|
| 301 |
static int |
| 302 |
ossl_md_update(hc_EVP_MD_CTX *d, const void *data, size_t count) |
| 303 |
{ |
| 304 |
struct ossl_md_ctx *ctx = (void *)d; |
| 305 |
|
| 306 |
return EVP_DigestUpdate(ctx->ossl_md_ctx, data, count); |
| 307 |
} |
| 308 |
|
| 309 |
static int |
| 310 |
ossl_md_final(void *md_data, hc_EVP_MD_CTX *d) |
| 311 |
{ |
| 312 |
struct ossl_md_ctx *ctx = (void *)d; |
| 313 |
|
| 314 |
return EVP_DigestFinal(ctx->ossl_md_ctx, md_data, NULL); |
| 315 |
} |
| 316 |
|
| 317 |
static int |
| 318 |
ossl_md_cleanup(hc_EVP_MD_CTX *d) |
| 319 |
{ |
| 320 |
struct ossl_md_ctx *ctx = (void *)d; |
| 321 |
|
| 322 |
if (!ctx->initialized) |
| 323 |
return 1; |
| 324 |
EVP_MD_CTX_free(ctx->ossl_md_ctx); |
| 325 |
ctx->ossl_md = NULL; |
| 326 |
ctx->initialized = 0; |
| 327 |
|
| 328 |
return 1; |
| 329 |
} |
| 330 |
|
| 331 |
struct once_init_md_ctx { |
| 332 |
const EVP_MD **ossl_memoizep; |
| 333 |
const hc_EVP_MD **hc_memoizep; |
| 334 |
hc_EVP_MD *hc_memoize; |
| 335 |
const hc_EVP_MD *fallback; |
| 336 |
hc_evp_md_init md_init; |
| 337 |
int nid; |
| 338 |
}; |
| 339 |
|
| 340 |
static void |
| 341 |
get_EVP_MD_once_cb(void *d) |
| 342 |
{ |
| 343 |
struct once_init_md_ctx *arg = d; |
| 344 |
const EVP_MD *ossl_evp; |
| 345 |
hc_EVP_MD *hc_evp; |
| 346 |
|
| 347 |
hc_evp = arg->hc_memoize; |
| 348 |
*arg->ossl_memoizep = ossl_evp = EVP_get_digestbynid(arg->nid); |
| 349 |
|
| 350 |
if (ossl_evp == NULL) { |
| 351 |
(void) memset(hc_evp, 0, sizeof(*hc_evp)); |
| 352 |
#if HCRYPTO_FALLBACK |
| 353 |
*arg->hc_memoizep = arg->fallback; |
| 354 |
#endif |
| 355 |
return; |
| 356 |
} |
| 357 |
|
| 358 |
/* Build the hc_EVP_MD */ |
| 359 |
hc_evp->block_size = EVP_MD_block_size(ossl_evp); |
| 360 |
hc_evp->hash_size = EVP_MD_size(ossl_evp); |
| 361 |
hc_evp->ctx_size = sizeof(struct ossl_md_ctx); |
| 362 |
hc_evp->init = arg->md_init; |
| 363 |
hc_evp->update = ossl_md_update; |
| 364 |
hc_evp->final = ossl_md_final; |
| 365 |
hc_evp->cleanup = ossl_md_cleanup; |
| 366 |
|
| 367 |
*arg->hc_memoizep = hc_evp; |
| 368 |
} |
| 369 |
|
| 370 |
static const hc_EVP_MD * |
| 371 |
get_EVP_MD(heim_base_once_t *once, hc_EVP_MD *hc_memoize, |
| 372 |
const hc_EVP_MD **hc_memoizep, const EVP_MD **ossl_memoizep, |
| 373 |
const hc_EVP_MD *fallback, |
| 374 |
hc_evp_md_init md_init, int nid) |
| 375 |
{ |
| 376 |
struct once_init_md_ctx ctx; |
| 377 |
|
| 378 |
ctx.ossl_memoizep = ossl_memoizep; |
| 379 |
ctx.hc_memoizep = hc_memoizep; |
| 380 |
ctx.hc_memoize = hc_memoize; |
| 381 |
ctx.fallback = fallback; |
| 382 |
ctx.md_init = md_init; |
| 383 |
ctx.nid = nid; |
| 384 |
heim_base_once_f(once, &ctx, get_EVP_MD_once_cb); |
| 385 |
return *hc_memoizep; /* May be NULL */ |
| 386 |
} |
| 387 |
|
| 388 |
#define OSSL_MD_ALGORITHM(name) \ |
| 389 |
extern const hc_EVP_MD *hc_EVP_hcrypto_##name(void); \ |
| 390 |
static const EVP_MD *ossl_EVP_##name; \ |
| 391 |
static const hc_EVP_MD *ossl_##name; \ |
| 392 |
static int ossl_init_##name(hc_EVP_MD_CTX *d) \ |
| 393 |
{ \ |
| 394 |
return ossl_md_init((void *)d, ossl_EVP_##name); \ |
| 395 |
} \ |
| 396 |
const hc_EVP_MD *hc_EVP_ossl_##name(void) \ |
| 397 |
{ \ |
| 398 |
static hc_EVP_MD ossl_##name##_st; \ |
| 399 |
static heim_base_once_t once = HEIM_BASE_ONCE_INIT; \ |
| 400 |
return get_EVP_MD(&once, &ossl_##name##_st, &ossl_##name, \ |
| 401 |
&ossl_EVP_##name, hc_EVP_hcrypto_##name(), \ |
| 402 |
ossl_init_##name, NID_##name); \ |
| 403 |
} |
| 404 |
|
| 405 |
#else /* HAVE_HCRYPTO_W_OPENSSL */ |
| 406 |
|
| 407 |
#include "evp-hcrypto.h" |
| 408 |
|
| 409 |
#define OSSL_CIPHER_ALGORITHM(name, flags) \ |
| 410 |
extern const hc_EVP_CIPHER *hc_EVP_ossl_##name(void); \ |
| 411 |
const hc_EVP_CIPHER *hc_EVP_ossl_##name(void) \ |
| 412 |
{ \ |
| 413 |
return hc_EVP_hcrypto_##name(); \ |
| 414 |
} |
| 415 |
|
| 416 |
#define OSSL_MD_ALGORITHM(name) \ |
| 417 |
extern const hc_EVP_MD *hc_EVP_ossl_##name(void); \ |
| 418 |
const hc_EVP_MD *hc_EVP_ossl_##name(void) \ |
| 419 |
{ \ |
| 420 |
return hc_EVP_hcrypto_##name(); \ |
| 421 |
} |
| 422 |
|
| 423 |
#endif /* HAVE_HCRYPTO_W_OPENSSL */ |
| 424 |
|
| 425 |
/** |
| 426 |
* The triple DES cipher type (OpenSSL provider) |
| 427 |
* |
| 428 |
* @return the DES-EDE3-CBC EVP_CIPHER pointer. |
| 429 |
* |
| 430 |
* @ingroup hcrypto_evp |
| 431 |
*/ |
| 432 |
OSSL_CIPHER_ALGORITHM(des_ede3_cbc, hc_EVP_CIPH_CBC_MODE) |
| 433 |
|
| 434 |
/** |
| 435 |
* The DES cipher type (OpenSSL provider) |
| 436 |
* |
| 437 |
* @return the DES-CBC EVP_CIPHER pointer. |
| 438 |
* |
| 439 |
* @ingroup hcrypto_evp |
| 440 |
*/ |
| 441 |
OSSL_CIPHER_ALGORITHM(des_cbc, hc_EVP_CIPH_CBC_MODE) |
| 442 |
|
| 443 |
/** |
| 444 |
* The AES-128 cipher type (OpenSSL provider) |
| 445 |
* |
| 446 |
* @return the AES-128-CBC EVP_CIPHER pointer. |
| 447 |
* |
| 448 |
* @ingroup hcrypto_evp |
| 449 |
*/ |
| 450 |
OSSL_CIPHER_ALGORITHM(aes_128_cbc, hc_EVP_CIPH_CBC_MODE) |
| 451 |
|
| 452 |
/** |
| 453 |
* The AES-192 cipher type (OpenSSL provider) |
| 454 |
* |
| 455 |
* @return the AES-192-CBC EVP_CIPHER pointer. |
| 456 |
* |
| 457 |
* @ingroup hcrypto_evp |
| 458 |
*/ |
| 459 |
OSSL_CIPHER_ALGORITHM(aes_192_cbc, hc_EVP_CIPH_CBC_MODE) |
| 460 |
|
| 461 |
/** |
| 462 |
* The AES-256 cipher type (OpenSSL provider) |
| 463 |
* |
| 464 |
* @return the AES-256-CBC EVP_CIPHER pointer. |
| 465 |
* |
| 466 |
* @ingroup hcrypto_evp |
| 467 |
*/ |
| 468 |
OSSL_CIPHER_ALGORITHM(aes_256_cbc, hc_EVP_CIPH_CBC_MODE) |
| 469 |
|
| 470 |
/** |
| 471 |
* The AES-128 CFB8 cipher type (OpenSSL provider) |
| 472 |
* |
| 473 |
* @return the AES-128-CFB8 EVP_CIPHER pointer. |
| 474 |
* |
| 475 |
* @ingroup hcrypto_evp |
| 476 |
*/ |
| 477 |
OSSL_CIPHER_ALGORITHM(aes_128_cfb8, hc_EVP_CIPH_CFB8_MODE) |
| 478 |
|
| 479 |
/** |
| 480 |
* The AES-192 CFB8 cipher type (OpenSSL provider) |
| 481 |
* |
| 482 |
* @return the AES-192-CFB8 EVP_CIPHER pointer. |
| 483 |
* |
| 484 |
* @ingroup hcrypto_evp |
| 485 |
*/ |
| 486 |
OSSL_CIPHER_ALGORITHM(aes_192_cfb8, hc_EVP_CIPH_CFB8_MODE) |
| 487 |
|
| 488 |
/** |
| 489 |
* The AES-256 CFB8 cipher type (OpenSSL provider) |
| 490 |
* |
| 491 |
* @return the AES-256-CFB8 EVP_CIPHER pointer. |
| 492 |
* |
| 493 |
* @ingroup hcrypto_evp |
| 494 |
*/ |
| 495 |
OSSL_CIPHER_ALGORITHM(aes_256_cfb8, hc_EVP_CIPH_CFB8_MODE) |
| 496 |
|
| 497 |
/* |
| 498 |
* RC2 is only needed for tests of PKCS#12 support, which currently uses |
| 499 |
* the RC2 PBE. So no RC2 -> tests fail. |
| 500 |
*/ |
| 501 |
|
| 502 |
/** |
| 503 |
* The RC2 cipher type - OpenSSL |
| 504 |
* |
| 505 |
* @return the RC2 EVP_CIPHER pointer. |
| 506 |
* |
| 507 |
* @ingroup hcrypto_evp |
| 508 |
*/ |
| 509 |
OSSL_CIPHER_ALGORITHM(rc2_cbc, |
| 510 |
hc_EVP_CIPH_CBC_MODE | |
| 511 |
hc_EVP_CIPH_VARIABLE_LENGTH) |
| 512 |
|
| 513 |
/** |
| 514 |
* The RC2-40 cipher type - OpenSSL |
| 515 |
* |
| 516 |
* @return the RC2-40 EVP_CIPHER pointer. |
| 517 |
* |
| 518 |
* @ingroup hcrypto_evp |
| 519 |
*/ |
| 520 |
OSSL_CIPHER_ALGORITHM(rc2_40_cbc, |
| 521 |
hc_EVP_CIPH_CBC_MODE) |
| 522 |
|
| 523 |
/** |
| 524 |
* The RC2-64 cipher type - OpenSSL |
| 525 |
* |
| 526 |
* @return the RC2-64 EVP_CIPHER pointer. |
| 527 |
* |
| 528 |
* @ingroup hcrypto_evp |
| 529 |
*/ |
| 530 |
OSSL_CIPHER_ALGORITHM(rc2_64_cbc, |
| 531 |
hc_EVP_CIPH_CBC_MODE | |
| 532 |
hc_EVP_CIPH_VARIABLE_LENGTH) |
| 533 |
|
| 534 |
/** |
| 535 |
* The Camellia-128 cipher type - OpenSSL |
| 536 |
* |
| 537 |
* @return the Camellia-128 EVP_CIPHER pointer. |
| 538 |
* |
| 539 |
* @ingroup hcrypto_evp |
| 540 |
*/ |
| 541 |
OSSL_CIPHER_ALGORITHM(camellia_128_cbc, hc_EVP_CIPH_CBC_MODE) |
| 542 |
|
| 543 |
/** |
| 544 |
* The Camellia-198 cipher type - OpenSSL |
| 545 |
* |
| 546 |
* @return the Camellia-198 EVP_CIPHER pointer. |
| 547 |
* |
| 548 |
* @ingroup hcrypto_evp |
| 549 |
*/ |
| 550 |
OSSL_CIPHER_ALGORITHM(camellia_192_cbc, hc_EVP_CIPH_CBC_MODE) |
| 551 |
|
| 552 |
/** |
| 553 |
* The Camellia-256 cipher type - OpenSSL |
| 554 |
* |
| 555 |
* @return the Camellia-256 EVP_CIPHER pointer. |
| 556 |
* |
| 557 |
* @ingroup hcrypto_evp |
| 558 |
*/ |
| 559 |
OSSL_CIPHER_ALGORITHM(camellia_256_cbc, hc_EVP_CIPH_CBC_MODE) |
| 560 |
|
| 561 |
/** |
| 562 |
* The RC4 cipher type (OpenSSL provider) |
| 563 |
* |
| 564 |
* @return the RC4 EVP_CIPHER pointer. |
| 565 |
* |
| 566 |
* @ingroup hcrypto_evp |
| 567 |
*/ |
| 568 |
OSSL_CIPHER_ALGORITHM(rc4, |
| 569 |
hc_EVP_CIPH_STREAM_CIPHER | |
| 570 |
hc_EVP_CIPH_VARIABLE_LENGTH) |
| 571 |
|
| 572 |
/** |
| 573 |
* The RC4-40 cipher type (OpenSSL provider) |
| 574 |
* |
| 575 |
* @return the RC4 EVP_CIPHER pointer. |
| 576 |
* |
| 577 |
* @ingroup hcrypto_evp |
| 578 |
*/ |
| 579 |
OSSL_CIPHER_ALGORITHM(rc4_40, |
| 580 |
hc_EVP_CIPH_STREAM_CIPHER | |
| 581 |
hc_EVP_CIPH_VARIABLE_LENGTH) |
| 582 |
|
| 583 |
/** |
| 584 |
* The MD4 hash algorithm (OpenSSL provider) |
| 585 |
* |
| 586 |
* @return the MD4 EVP_MD pointer. |
| 587 |
* |
| 588 |
* @ingroup hcrypto_evp |
| 589 |
*/ |
| 590 |
OSSL_MD_ALGORITHM(md4) |
| 591 |
|
| 592 |
/** |
| 593 |
* The MD5 hash algorithm (OpenSSL provider) |
| 594 |
* |
| 595 |
* @return the MD5 EVP_MD pointer. |
| 596 |
* |
| 597 |
* @ingroup hcrypto_evp |
| 598 |
*/ |
| 599 |
OSSL_MD_ALGORITHM(md5) |
| 600 |
|
| 601 |
/** |
| 602 |
* The SHA-1 hash algorithm (OpenSSL provider) |
| 603 |
* |
| 604 |
* @return the SHA-1 EVP_MD pointer. |
| 605 |
* |
| 606 |
* @ingroup hcrypto_evp |
| 607 |
*/ |
| 608 |
OSSL_MD_ALGORITHM(sha1) |
| 609 |
|
| 610 |
/** |
| 611 |
* The SHA-256 hash algorithm (OpenSSL provider) |
| 612 |
* |
| 613 |
* @return the SHA-256 EVP_MD pointer. |
| 614 |
* |
| 615 |
* @ingroup hcrypto_evp |
| 616 |
*/ |
| 617 |
OSSL_MD_ALGORITHM(sha256) |
| 618 |
|
| 619 |
/** |
| 620 |
* The SHA-384 hash algorithm (OpenSSL provider) |
| 621 |
* |
| 622 |
* @return the SHA-384 EVP_MD pointer. |
| 623 |
* |
| 624 |
* @ingroup hcrypto_evp |
| 625 |
*/ |
| 626 |
OSSL_MD_ALGORITHM(sha384) |
| 627 |
|
| 628 |
/** |
| 629 |
* The SHA-512 hash algorithm (OpenSSL provider) |
| 630 |
* |
| 631 |
* @return the SHA-512 EVP_MD pointer. |
| 632 |
* |
| 633 |
* @ingroup hcrypto_evp |
| 634 |
*/ |
| 635 |
OSSL_MD_ALGORITHM(sha512) |