summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2024-01-02 18:21:02 +0000
committertb <>2024-01-02 18:21:02 +0000
commitb6549e2a0696898a23eee24771874a505fe4881e (patch)
treeba3ad19f03f5a5c99d83c908b29a22e8b4f08eb1 /src
parent23a8a257fa7066fafd85ae4c43b6a88cbf37a9c7 (diff)
downloadopenbsd-b6549e2a0696898a23eee24771874a505fe4881e.tar.gz
openbsd-b6549e2a0696898a23eee24771874a505fe4881e.tar.bz2
openbsd-b6549e2a0696898a23eee24771874a505fe4881e.zip
Consistently use ctx for an EVP_CIPHER_CTX
Not c (which is most of the time an EVP_CIPHER) or a (?!).
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/evp/evp_cipher.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/src/lib/libcrypto/evp/evp_cipher.c b/src/lib/libcrypto/evp/evp_cipher.c
index 751360cd7b..b9bc15e371 100644
--- a/src/lib/libcrypto/evp/evp_cipher.c
+++ b/src/lib/libcrypto/evp/evp_cipher.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: evp_cipher.c,v 1.3 2023/12/29 06:56:38 tb Exp $ */ 1/* $OpenBSD: evp_cipher.c,v 1.4 2024/01/02 18:21:02 tb 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 *
@@ -618,40 +618,40 @@ EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx)
618} 618}
619 619
620int 620int
621EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *a) 621EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *ctx)
622{ 622{
623 return EVP_CIPHER_CTX_cleanup(a); 623 return EVP_CIPHER_CTX_cleanup(ctx);
624} 624}
625 625
626int 626int
627EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c) 627EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *ctx)
628{ 628{
629 if (c->cipher != NULL) { 629 if (ctx->cipher != NULL) {
630 /* XXX - Avoid leaks, so ignore return value of cleanup()... */ 630 /* XXX - Avoid leaks, so ignore return value of cleanup()... */
631 if (c->cipher->cleanup != NULL) 631 if (ctx->cipher->cleanup != NULL)
632 c->cipher->cleanup(c); 632 ctx->cipher->cleanup(ctx);
633 if (c->cipher_data != NULL) 633 if (ctx->cipher_data != NULL)
634 explicit_bzero(c->cipher_data, c->cipher->ctx_size); 634 explicit_bzero(ctx->cipher_data, ctx->cipher->ctx_size);
635 } 635 }
636 636
637 /* XXX - store size of cipher_data so we can always freezero(). */ 637 /* XXX - store size of cipher_data so we can always freezero(). */
638 free(c->cipher_data); 638 free(ctx->cipher_data);
639 639
640 explicit_bzero(c, sizeof(EVP_CIPHER_CTX)); 640 explicit_bzero(ctx, sizeof(EVP_CIPHER_CTX));
641 641
642 return 1; 642 return 1;
643} 643}
644 644
645int 645int
646EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *c, int keylen) 646EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *ctx, int keylen)
647{ 647{
648 if (c->cipher->flags & EVP_CIPH_CUSTOM_KEY_LENGTH) 648 if (ctx->cipher->flags & EVP_CIPH_CUSTOM_KEY_LENGTH)
649 return EVP_CIPHER_CTX_ctrl(c, EVP_CTRL_SET_KEY_LENGTH, 649 return EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_SET_KEY_LENGTH,
650 keylen, NULL); 650 keylen, NULL);
651 if (c->key_len == keylen) 651 if (ctx->key_len == keylen)
652 return 1; 652 return 1;
653 if (keylen > 0 && (c->cipher->flags & EVP_CIPH_VARIABLE_LENGTH)) { 653 if (keylen > 0 && (ctx->cipher->flags & EVP_CIPH_VARIABLE_LENGTH)) {
654 c->key_len = keylen; 654 ctx->key_len = keylen;
655 return 1; 655 return 1;
656 } 656 }
657 EVPerror(EVP_R_INVALID_KEY_LENGTH); 657 EVPerror(EVP_R_INVALID_KEY_LENGTH);
@@ -740,67 +740,67 @@ EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in)
740} 740}
741 741
742int 742int
743EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type) 743EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
744{ 744{
745 int ret; 745 int ret;
746 746
747 if (c->cipher->set_asn1_parameters != NULL) 747 if (ctx->cipher->set_asn1_parameters != NULL)
748 ret = c->cipher->set_asn1_parameters(c, type); 748 ret = ctx->cipher->set_asn1_parameters(ctx, type);
749 else if (c->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) 749 else if (ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1)
750 ret = EVP_CIPHER_set_asn1_iv(c, type); 750 ret = EVP_CIPHER_set_asn1_iv(ctx, type);
751 else 751 else
752 ret = -1; 752 ret = -1;
753 return (ret); 753 return (ret);
754} 754}
755 755
756int 756int
757EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type) 757EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
758{ 758{
759 int ret; 759 int ret;
760 760
761 if (c->cipher->get_asn1_parameters != NULL) 761 if (ctx->cipher->get_asn1_parameters != NULL)
762 ret = c->cipher->get_asn1_parameters(c, type); 762 ret = ctx->cipher->get_asn1_parameters(ctx, type);
763 else if (c->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) 763 else if (ctx->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1)
764 ret = EVP_CIPHER_get_asn1_iv(c, type); 764 ret = EVP_CIPHER_get_asn1_iv(ctx, type);
765 else 765 else
766 ret = -1; 766 ret = -1;
767 return (ret); 767 return (ret);
768} 768}
769 769
770int 770int
771EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) 771EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
772{ 772{
773 int i = 0; 773 int i = 0;
774 int l; 774 int l;
775 775
776 if (type != NULL) { 776 if (type != NULL) {
777 l = EVP_CIPHER_CTX_iv_length(c); 777 l = EVP_CIPHER_CTX_iv_length(ctx);
778 if (l < 0 || l > sizeof(c->iv)) { 778 if (l < 0 || l > sizeof(ctx->iv)) {
779 EVPerror(EVP_R_IV_TOO_LARGE); 779 EVPerror(EVP_R_IV_TOO_LARGE);
780 return 0; 780 return 0;
781 } 781 }
782 i = ASN1_TYPE_get_octetstring(type, c->oiv, l); 782 i = ASN1_TYPE_get_octetstring(type, ctx->oiv, l);
783 if (i != l) 783 if (i != l)
784 return (-1); 784 return (-1);
785 else if (i > 0) 785 else if (i > 0)
786 memcpy(c->iv, c->oiv, l); 786 memcpy(ctx->iv, ctx->oiv, l);
787 } 787 }
788 return (i); 788 return (i);
789} 789}
790 790
791int 791int
792EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) 792EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *ctx, ASN1_TYPE *type)
793{ 793{
794 int i = 0; 794 int i = 0;
795 int j; 795 int j;
796 796
797 if (type != NULL) { 797 if (type != NULL) {
798 j = EVP_CIPHER_CTX_iv_length(c); 798 j = EVP_CIPHER_CTX_iv_length(ctx);
799 if (j < 0 || j > sizeof(c->iv)) { 799 if (j < 0 || j > sizeof(ctx->iv)) {
800 EVPerror(EVP_R_IV_TOO_LARGE); 800 EVPerror(EVP_R_IV_TOO_LARGE);
801 return 0; 801 return 0;
802 } 802 }
803 i = ASN1_TYPE_set_octetstring(type, c->oiv, j); 803 i = ASN1_TYPE_set_octetstring(type, ctx->oiv, j);
804 } 804 }
805 return (i); 805 return (i);
806} 806}