summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorjsing <>2022-09-04 13:34:13 +0000
committerjsing <>2022-09-04 13:34:13 +0000
commit3bfbb0618a4b8d094e6cb6604d01a69cf0f71c79 (patch)
treeeb34af692cbfcc9dc17e64138f74fe5daf61a623 /src/lib
parente0a6d27109c842f87e3f1f5c368f7eaf24cfd6f7 (diff)
downloadopenbsd-3bfbb0618a4b8d094e6cb6604d01a69cf0f71c79.tar.gz
openbsd-3bfbb0618a4b8d094e6cb6604d01a69cf0f71c79.tar.bz2
openbsd-3bfbb0618a4b8d094e6cb6604d01a69cf0f71c79.zip
Expand the looney M_do_cipher macro.
Only change in generated assembly is due to line numbers.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/evp/evp_enc.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c
index d925ed77d7..c46989b068 100644
--- a/src/lib/libcrypto/evp/evp_enc.c
+++ b/src/lib/libcrypto/evp/evp_enc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_enc.c,v 1.45 2022/07/26 19:50:06 tb Exp $ */ 1/* $OpenBSD: evp_enc.c,v 1.46 2022/09/04 13:34:13 jsing 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 *
@@ -74,8 +74,6 @@
74 74
75#include "evp_locl.h" 75#include "evp_locl.h"
76 76
77#define M_do_cipher(ctx, out, in, inl) ctx->cipher->do_cipher(ctx, out, in, inl)
78
79int 77int
80EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, 78EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
81 const unsigned char *key, const unsigned char *iv, int enc) 79 const unsigned char *key, const unsigned char *iv, int enc)
@@ -309,7 +307,7 @@ EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
309 return 1; 307 return 1;
310 308
311 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) { 309 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
312 i = M_do_cipher(ctx, out, in, inl); 310 i = ctx->cipher->do_cipher(ctx, out, in, inl);
313 if (i < 0) 311 if (i < 0)
314 return 0; 312 return 0;
315 else 313 else
@@ -318,7 +316,7 @@ EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
318 } 316 }
319 317
320 if (ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0) { 318 if (ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0) {
321 if (M_do_cipher(ctx, out, in, inl)) { 319 if (ctx->cipher->do_cipher(ctx, out, in, inl)) {
322 *outl = inl; 320 *outl = inl;
323 return 1; 321 return 1;
324 } else { 322 } else {
@@ -353,7 +351,7 @@ EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
353 return 0; 351 return 0;
354 } 352 }
355 memcpy(&(ctx->buf[i]), in, j); 353 memcpy(&(ctx->buf[i]), in, j);
356 if (!M_do_cipher(ctx, out, ctx->buf, bl)) 354 if (!ctx->cipher->do_cipher(ctx, out, ctx->buf, bl))
357 return 0; 355 return 0;
358 inl -= j; 356 inl -= j;
359 in += j; 357 in += j;
@@ -365,7 +363,7 @@ EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
365 i = inl&(bl - 1); 363 i = inl&(bl - 1);
366 inl -= i; 364 inl -= i;
367 if (inl > 0) { 365 if (inl > 0) {
368 if (!M_do_cipher(ctx, out, in, inl)) 366 if (!ctx->cipher->do_cipher(ctx, out, in, inl))
369 return 0; 367 return 0;
370 *outl += inl; 368 *outl += inl;
371 } 369 }
@@ -395,7 +393,7 @@ EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
395 unsigned int i, b, bl; 393 unsigned int i, b, bl;
396 394
397 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) { 395 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
398 ret = M_do_cipher(ctx, out, NULL, 0); 396 ret = ctx->cipher->do_cipher(ctx, out, NULL, 0);
399 if (ret < 0) 397 if (ret < 0)
400 return 0; 398 return 0;
401 else 399 else
@@ -425,7 +423,7 @@ EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
425 n = b - bl; 423 n = b - bl;
426 for (i = bl; i < b; i++) 424 for (i = bl; i < b; i++)
427 ctx->buf[i] = n; 425 ctx->buf[i] = n;
428 ret = M_do_cipher(ctx, out, ctx->buf, b); 426 ret = ctx->cipher->do_cipher(ctx, out, ctx->buf, b);
429 427
430 428
431 if (ret) 429 if (ret)
@@ -450,7 +448,7 @@ EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
450 return 1; 448 return 1;
451 449
452 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) { 450 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
453 fix_len = M_do_cipher(ctx, out, in, inl); 451 fix_len = ctx->cipher->do_cipher(ctx, out, in, inl);
454 if (fix_len < 0) { 452 if (fix_len < 0) {
455 *outl = 0; 453 *outl = 0;
456 return 0; 454 return 0;
@@ -524,7 +522,7 @@ EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
524 *outl = 0; 522 *outl = 0;
525 523
526 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) { 524 if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
527 i = M_do_cipher(ctx, out, NULL, 0); 525 i = ctx->cipher->do_cipher(ctx, out, NULL, 0);
528 if (i < 0) 526 if (i < 0)
529 return 0; 527 return 0;
530 else 528 else