Convert the remaining legacy ciphers to C99 initializers
authortb <tb@openbsd.org>
Sun, 7 Jan 2024 15:42:57 +0000 (15:42 +0000)
committertb <tb@openbsd.org>
Sun, 7 Jan 2024 15:42:57 +0000 (15:42 +0000)
No change in the generated aarch64 assembly apart from line number changes.

ok jsing

lib/libcrypto/evp/e_null.c
lib/libcrypto/evp/e_rc2.c
lib/libcrypto/evp/e_rc4.c
lib/libcrypto/evp/e_rc4_hmac_md5.c
lib/libcrypto/evp/e_xcbc_d.c

index d3364de..be46c1c 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: e_null.c,v 1.19 2024/01/04 17:38:36 tb Exp $ */
+/* $OpenBSD: e_null.c,v 1.20 2024/01/07 15:42:57 tb Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -70,16 +70,18 @@ static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
     const unsigned char *in, size_t inl);
 
 static const EVP_CIPHER n_cipher = {
-       NID_undef,
-       1, 0, 0,
-       0,
-       null_init_key,
-       null_cipher,
-       NULL,
-       0,
-       NULL,
-       NULL,
-       NULL,
+       .nid = NID_undef,
+       .block_size = 1,
+       .key_len = 0,
+       .iv_len = 0,
+       .flags = 0,
+       .init = null_init_key,
+       .do_cipher = null_cipher,
+       .cleanup = NULL,
+       .ctx_size = 0,
+       .set_asn1_parameters = NULL,
+       .get_asn1_parameters = NULL,
+       .ctrl = NULL,
 };
 
 const EVP_CIPHER *
index 6f8c051..0a19551 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: e_rc2.c,v 1.26 2024/01/04 17:38:36 tb Exp $ */
+/* $OpenBSD: e_rc2.c,v 1.27 2024/01/07 15:42:57 tb Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -248,29 +248,33 @@ EVP_rc2_ecb(void)
 #define RC2_128_MAGIC  0x3a
 
 static const EVP_CIPHER r2_64_cbc_cipher = {
-       NID_rc2_64_cbc,
-       8, 8 /* 64 bit */, 8,
-       EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
-       rc2_init_key,
-       rc2_cbc_cipher,
-       NULL,
-       sizeof(EVP_RC2_KEY),
-       rc2_set_asn1_type_and_iv,
-       rc2_get_asn1_type_and_iv,
-       rc2_ctrl,
+       .nid = NID_rc2_64_cbc,
+       .block_size = 8,
+       .key_len = 8,
+       .iv_len = 8,
+       .flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
+       .init = rc2_init_key,
+       .do_cipher = rc2_cbc_cipher,
+       .cleanup = NULL,
+       .ctx_size = sizeof(EVP_RC2_KEY),
+       .set_asn1_parameters = rc2_set_asn1_type_and_iv,
+       .get_asn1_parameters = rc2_get_asn1_type_and_iv,
+       .ctrl = rc2_ctrl,
 };
 
 static const EVP_CIPHER r2_40_cbc_cipher = {
-       NID_rc2_40_cbc,
-       8, 5 /* 40 bit */, 8,
-       EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
-       rc2_init_key,
-       rc2_cbc_cipher,
-       NULL,
-       sizeof(EVP_RC2_KEY),
-       rc2_set_asn1_type_and_iv,
-       rc2_get_asn1_type_and_iv,
-       rc2_ctrl,
+       .nid = NID_rc2_40_cbc,
+       .block_size = 8,
+       .key_len = 5,
+       .iv_len = 8,
+       .flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT,
+       .init = rc2_init_key,
+       .do_cipher = rc2_cbc_cipher,
+       .cleanup = NULL,
+       .ctx_size = sizeof(EVP_RC2_KEY),
+       .set_asn1_parameters = rc2_set_asn1_type_and_iv,
+       .get_asn1_parameters = rc2_get_asn1_type_and_iv,
+       .ctrl = rc2_ctrl,
 };
 
 const EVP_CIPHER *
index 4588dfc..c0f12fb 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: e_rc4.c,v 1.18 2024/01/04 17:38:36 tb Exp $ */
+/* $OpenBSD: e_rc4.c,v 1.19 2024/01/07 15:42:57 tb Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -83,29 +83,33 @@ static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
     const unsigned char *in, size_t inl);
 
 static const EVP_CIPHER r4_cipher = {
-       NID_rc4,
-       1, EVP_RC4_KEY_SIZE, 0,
-       EVP_CIPH_VARIABLE_LENGTH,
-       rc4_init_key,
-       rc4_cipher,
-       NULL,
-       sizeof(EVP_RC4_KEY),
-       NULL,
-       NULL,
-       NULL,
+       .nid = NID_rc4,
+       .block_size = 1,
+       .key_len = EVP_RC4_KEY_SIZE,
+       .iv_len = 0,
+       .flags = EVP_CIPH_VARIABLE_LENGTH,
+       .init = rc4_init_key,
+       .do_cipher = rc4_cipher,
+       .cleanup = NULL,
+       .ctx_size = sizeof(EVP_RC4_KEY),
+       .set_asn1_parameters = NULL,
+       .get_asn1_parameters = NULL,
+       .ctrl = NULL,
 };
 
 static const EVP_CIPHER r4_40_cipher = {
-       NID_rc4_40,
-       1, 5 /* 40 bit */, 0,
-       EVP_CIPH_VARIABLE_LENGTH,
-       rc4_init_key,
-       rc4_cipher,
-       NULL,
-       sizeof(EVP_RC4_KEY),
-       NULL,
-       NULL,
-       NULL,
+       .nid = NID_rc4_40,
+       .block_size = 1,
+       .key_len = 5,
+       .iv_len = 0,
+       .flags = EVP_CIPH_VARIABLE_LENGTH,
+       .init = rc4_init_key,
+       .do_cipher = rc4_cipher,
+       .cleanup = NULL,
+       .ctx_size = sizeof(EVP_RC4_KEY),
+       .set_asn1_parameters = NULL,
+       .get_asn1_parameters = NULL,
+       .ctrl = NULL,
 };
 
 const EVP_CIPHER *
index a9301dc..5701aee 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: e_rc4_hmac_md5.c,v 1.13 2024/01/04 17:38:36 tb Exp $ */
+/* $OpenBSD: e_rc4_hmac_md5.c,v 1.14 2024/01/07 15:42:57 tb Exp $ */
 /* ====================================================================
  * Copyright (c) 2011 The OpenSSL Project.  All rights reserved.
  *
@@ -283,19 +283,21 @@ rc4_hmac_md5_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
 
 static EVP_CIPHER r4_hmac_md5_cipher = {
 #ifdef NID_rc4_hmac_md5
-       NID_rc4_hmac_md5,
+       .nid = NID_rc4_hmac_md5,
 #else
-       NID_undef,
+       .nid = NID_undef,
 #endif
-       1, EVP_RC4_KEY_SIZE, 0,
-       EVP_CIPH_STREAM_CIPHER|EVP_CIPH_VARIABLE_LENGTH|EVP_CIPH_FLAG_AEAD_CIPHER,
-       rc4_hmac_md5_init_key,
-       rc4_hmac_md5_cipher,
-       NULL,
-       sizeof(EVP_RC4_HMAC_MD5),
-       NULL,
-       NULL,
-       rc4_hmac_md5_ctrl,
+       .block_size = 1,
+       .key_len = EVP_RC4_KEY_SIZE,
+       .iv_len = 0,
+       .flags = EVP_CIPH_STREAM_CIPHER|EVP_CIPH_VARIABLE_LENGTH|EVP_CIPH_FLAG_AEAD_CIPHER,
+       .init = rc4_hmac_md5_init_key,
+       .do_cipher = rc4_hmac_md5_cipher,
+       .cleanup = NULL,
+       .ctx_size = sizeof(EVP_RC4_HMAC_MD5),
+       .set_asn1_parameters = NULL,
+       .get_asn1_parameters = NULL,
+       .ctrl = rc4_hmac_md5_ctrl,
 };
 
 const EVP_CIPHER *
index 5a3d535..dc01cbb 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: e_xcbc_d.c,v 1.16 2024/01/04 17:38:36 tb Exp $ */
+/* $OpenBSD: e_xcbc_d.c,v 1.17 2024/01/07 15:42:57 tb Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -84,16 +84,18 @@ typedef struct {
 #define data(ctx) ((DESX_CBC_KEY *)(ctx)->cipher_data)
 
 static const EVP_CIPHER d_xcbc_cipher = {
-       NID_desx_cbc,
-       8, 24, 8,
-       EVP_CIPH_CBC_MODE,
-       desx_cbc_init_key,
-       desx_cbc_cipher,
-       NULL,
-       sizeof(DESX_CBC_KEY),
-       EVP_CIPHER_set_asn1_iv,
-       EVP_CIPHER_get_asn1_iv,
-       NULL,
+       .nid = NID_desx_cbc,
+       .block_size = 8,
+       .key_len = 24,
+       .iv_len = 8,
+       .flags = EVP_CIPH_CBC_MODE,
+       .init = desx_cbc_init_key,
+       .do_cipher = desx_cbc_cipher,
+       .cleanup = NULL,
+       .ctx_size = sizeof(DESX_CBC_KEY),
+       .set_asn1_parameters = EVP_CIPHER_set_asn1_iv,
+       .get_asn1_parameters = EVP_CIPHER_get_asn1_iv,
+       .ctrl = NULL,
 };
 
 const EVP_CIPHER *