diff options
Diffstat (limited to 'src/lib/libcrypto/evp/evp_lib.c')
| -rw-r--r-- | src/lib/libcrypto/evp/evp_lib.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/lib/libcrypto/evp/evp_lib.c b/src/lib/libcrypto/evp/evp_lib.c index 3571755620..90107739e7 100644 --- a/src/lib/libcrypto/evp/evp_lib.c +++ b/src/lib/libcrypto/evp/evp_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: evp_lib.c,v 1.16 2018/08/24 19:36:52 tb Exp $ */ | 1 | /* $OpenBSD: evp_lib.c,v 1.17 2018/09/12 06:35:38 djm Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -274,6 +274,44 @@ EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx) | |||
| 274 | } | 274 | } |
| 275 | 275 | ||
| 276 | int | 276 | int |
| 277 | EVP_CIPHER_CTX_get_iv(const EVP_CIPHER_CTX *ctx, unsigned char *iv, size_t len) | ||
| 278 | { | ||
| 279 | if (ctx == NULL || len != EVP_CIPHER_CTX_iv_length(ctx)) | ||
| 280 | return 0; | ||
| 281 | if (len > EVP_MAX_IV_LENGTH) | ||
| 282 | return 0; /* sanity check; shouldn't happen */ | ||
| 283 | /* | ||
| 284 | * Skip the memcpy entirely when the requested IV length is zero, | ||
| 285 | * since the iv pointer may be NULL or invalid. | ||
| 286 | */ | ||
| 287 | if (len != 0) { | ||
| 288 | if (iv == NULL) | ||
| 289 | return 0; | ||
| 290 | memcpy(iv, ctx->iv, len); | ||
| 291 | } | ||
| 292 | return 1; | ||
| 293 | } | ||
| 294 | |||
| 295 | int | ||
| 296 | EVP_CIPHER_CTX_set_iv(EVP_CIPHER_CTX *ctx, const unsigned char *iv, size_t len) | ||
| 297 | { | ||
| 298 | if (ctx == NULL || len != EVP_CIPHER_CTX_iv_length(ctx)) | ||
| 299 | return 0; | ||
| 300 | if (len > EVP_MAX_IV_LENGTH) | ||
| 301 | return 0; /* sanity check; shouldn't happen */ | ||
| 302 | /* | ||
| 303 | * Skip the memcpy entirely when the requested IV length is zero, | ||
| 304 | * since the iv pointer may be NULL or invalid. | ||
| 305 | */ | ||
| 306 | if (len != 0) { | ||
| 307 | if (iv == NULL) | ||
| 308 | return 0; | ||
| 309 | memcpy(ctx->iv, iv, len); | ||
| 310 | } | ||
| 311 | return 1; | ||
| 312 | } | ||
| 313 | |||
| 314 | int | ||
| 277 | EVP_MD_block_size(const EVP_MD *md) | 315 | EVP_MD_block_size(const EVP_MD *md) |
| 278 | { | 316 | { |
| 279 | return md->block_size; | 317 | return md->block_size; |
