diff --git a/src/crypto/cipher_extra/e_des.c b/src/crypto/cipher_extra/e_des.c index baf0be0b8..62ac2a03a 100644 --- a/src/crypto/cipher_extra/e_des.c +++ b/src/crypto/cipher_extra/e_des.c @@ -85,16 +85,14 @@ static int des_cbc_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in, } static const EVP_CIPHER evp_des_cbc = { - /* nid = */ NID_des_cbc, - /* block_size = */ 8, - /* key_len = */ 8, - /* iv_len = */ 8, - /* ctx_size = */ sizeof(EVP_DES_KEY), - /* flags = */ EVP_CIPH_CBC_MODE, - /* init = */ des_init_key, - /* cipher = */ des_cbc_cipher, - /* cleanup = */ NULL, - /* ctrl = */ NULL, + .nid = NID_des_cbc, + .block_size = 8, + .key_len = 8, + .iv_len = 8, + .ctx_size = sizeof(EVP_DES_KEY), + .flags = EVP_CIPH_CBC_MODE, + .init = des_init_key, + .cipher = des_cbc_cipher, }; const EVP_CIPHER *EVP_des_cbc(void) { return &evp_des_cbc; } @@ -114,16 +112,14 @@ static int des_ecb_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in, } static const EVP_CIPHER evp_des_ecb = { - /* nid = */ NID_des_ecb, - /* block_size = */ 8, - /* key_len = */ 8, - /* iv_len = */ 0, - /* ctx_size = */ sizeof(EVP_DES_KEY), - /* flags = */ EVP_CIPH_ECB_MODE, - /* init = */ des_init_key, - /* cipher = */ des_ecb_cipher, - /* cleanup = */ NULL, - /* ctrl = */ NULL, + .nid = NID_des_ecb, + .block_size = 8, + .key_len = 8, + .iv_len = 0, + .ctx_size = sizeof(EVP_DES_KEY), + .flags = EVP_CIPH_ECB_MODE, + .init = des_init_key, + .cipher = des_ecb_cipher, }; const EVP_CIPHER *EVP_des_ecb(void) { return &evp_des_ecb; } @@ -153,16 +149,14 @@ static int des_ede3_cbc_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, } static const EVP_CIPHER evp_des_ede3_cbc = { - /* nid = */ NID_des_ede3_cbc, - /* block_size = */ 8, - /* key_len = */ 24, - /* iv_len = */ 8, - /* ctx_size = */ sizeof(DES_EDE_KEY), - /* flags = */ EVP_CIPH_CBC_MODE, - /* init = */ des_ede3_init_key, - /* cipher = */ des_ede3_cbc_cipher, - /* cleanup = */ NULL, - /* ctrl = */ NULL, + .nid = NID_des_ede3_cbc, + .block_size = 8, + .key_len = 24, + .iv_len = 8, + .ctx_size = sizeof(DES_EDE_KEY), + .flags = EVP_CIPH_CBC_MODE, + .init = des_ede3_init_key, + .cipher = des_ede3_cbc_cipher, }; const EVP_CIPHER *EVP_des_ede3_cbc(void) { return &evp_des_ede3_cbc; } @@ -178,16 +172,14 @@ static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const uint8_t *key, } static const EVP_CIPHER evp_des_ede_cbc = { - /* nid = */ NID_des_ede_cbc, - /* block_size = */ 8, - /* key_len = */ 16, - /* iv_len = */ 8, - /* ctx_size = */ sizeof(DES_EDE_KEY), - /* flags = */ EVP_CIPH_CBC_MODE, - /* init = */ des_ede_init_key, - /* cipher = */ des_ede3_cbc_cipher, - /* cleanup = */ NULL, - /* ctrl = */ NULL, + .nid = NID_des_ede_cbc, + .block_size = 8, + .key_len = 16, + .iv_len = 8, + .ctx_size = sizeof(DES_EDE_KEY), + .flags = EVP_CIPH_CBC_MODE, + .init = des_ede_init_key, + .cipher = des_ede3_cbc_cipher, }; const EVP_CIPHER *EVP_des_ede_cbc(void) { return &evp_des_ede_cbc; } @@ -208,31 +200,27 @@ static int des_ede_ecb_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, } static const EVP_CIPHER evp_des_ede = { - /* nid = */ NID_des_ede_ecb, - /* block_size = */ 8, - /* key_len = */ 16, - /* iv_len = */ 0, - /* ctx_size = */ sizeof(DES_EDE_KEY), - /* flags = */ EVP_CIPH_ECB_MODE, - /* init = */ des_ede_init_key, - /* cipher = */ des_ede_ecb_cipher, - /* cleanup = */ NULL, - /* ctrl = */ NULL, + .nid = NID_des_ede_ecb, + .block_size = 8, + .key_len = 16, + .iv_len = 0, + .ctx_size = sizeof(DES_EDE_KEY), + .flags = EVP_CIPH_ECB_MODE, + .init = des_ede_init_key, + .cipher = des_ede_ecb_cipher, }; const EVP_CIPHER *EVP_des_ede(void) { return &evp_des_ede; } static const EVP_CIPHER evp_des_ede3 = { - /* nid = */ NID_des_ede3_ecb, - /* block_size = */ 8, - /* key_len = */ 24, - /* iv_len = */ 0, - /* ctx_size = */ sizeof(DES_EDE_KEY), - /* flags = */ EVP_CIPH_ECB_MODE, - /* init = */ des_ede3_init_key, - /* cipher = */ des_ede_ecb_cipher, - /* cleanup = */ NULL, - /* ctrl = */ NULL, + .nid = NID_des_ede3_ecb, + .block_size = 8, + .key_len = 24, + .iv_len = 0, + .ctx_size = sizeof(DES_EDE_KEY), + .flags = EVP_CIPH_ECB_MODE, + .init = des_ede3_init_key, + .cipher = des_ede_ecb_cipher, }; const EVP_CIPHER *EVP_des_ede3(void) { return &evp_des_ede3; } diff --git a/src/crypto/cipher_extra/e_null.c b/src/crypto/cipher_extra/e_null.c index 10a5c269e..ad99df924 100644 --- a/src/crypto/cipher_extra/e_null.c +++ b/src/crypto/cipher_extra/e_null.c @@ -78,9 +78,13 @@ static int null_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, } static const EVP_CIPHER n_cipher = { - NID_undef, 1 /* block size */, 0 /* key_len */, 0 /* iv_len */, - 0 /* ctx_size */, 0 /* flags */, null_init_key, null_cipher, - NULL /* cleanup */, NULL /* ctrl */, + .nid = NID_undef, + .block_size = 1, + .key_len = 0, + .iv_len = 0, + .ctx_size = 0, + .init = null_init_key, + .cipher = null_cipher, }; const EVP_CIPHER *EVP_enc_null(void) { return &n_cipher; } diff --git a/src/crypto/cipher_extra/e_rc2.c b/src/crypto/cipher_extra/e_rc2.c index acc99ad8c..c2a143eba 100644 --- a/src/crypto/cipher_extra/e_rc2.c +++ b/src/crypto/cipher_extra/e_rc2.c @@ -427,35 +427,29 @@ static int rc2_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) { } static const EVP_CIPHER rc2_40_cbc = { - NID_rc2_40_cbc, - 8 /* block size */, - 5 /* 40 bit */, - 8 /* iv len */, - sizeof(EVP_RC2_KEY), - EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, - rc2_init_key, - rc2_cbc_cipher, - NULL, - rc2_ctrl, + .nid = NID_rc2_40_cbc, + .block_size = 8, + .key_len = 5 /* 40 bit */, + .iv_len = 8, + .ctx_size = sizeof(EVP_RC2_KEY), + .flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, + .init = rc2_init_key, + .cipher = rc2_cbc_cipher, + .ctrl = rc2_ctrl, }; -const EVP_CIPHER *EVP_rc2_40_cbc(void) { - return &rc2_40_cbc; -} +const EVP_CIPHER *EVP_rc2_40_cbc(void) { return &rc2_40_cbc; } static const EVP_CIPHER rc2_cbc = { - NID_rc2_cbc, - 8 /* block size */, - 16 /* 128 bit */, - 8 /* iv len */, - sizeof(EVP_RC2_KEY), - EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, - rc2_init_key, - rc2_cbc_cipher, - NULL, - rc2_ctrl, + .nid = NID_rc2_cbc, + .block_size = 8, + .key_len = 16 /* 128 bit */, + .iv_len = 8, + .ctx_size = sizeof(EVP_RC2_KEY), + .flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, + .init = rc2_init_key, + .cipher = rc2_cbc_cipher, + .ctrl = rc2_ctrl, }; -const EVP_CIPHER *EVP_rc2_cbc(void) { - return &rc2_cbc; -} +const EVP_CIPHER *EVP_rc2_cbc(void) { return &rc2_cbc; } diff --git a/src/crypto/cipher_extra/e_rc4.c b/src/crypto/cipher_extra/e_rc4.c index e252ad8dc..0c3404fd7 100644 --- a/src/crypto/cipher_extra/e_rc4.c +++ b/src/crypto/cipher_extra/e_rc4.c @@ -81,10 +81,14 @@ static int rc4_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in, } static const EVP_CIPHER rc4 = { - NID_rc4, 1 /* block_size */, 16 /* key_size */, - 0 /* iv_len */, sizeof(RC4_KEY), EVP_CIPH_VARIABLE_LENGTH, - rc4_init_key, rc4_cipher, NULL /* cleanup */, - NULL /* ctrl */, + .nid = NID_rc4, + .block_size = 1, + .key_len = 16, + .iv_len = 0, + .ctx_size = sizeof(RC4_KEY), + .flags = EVP_CIPH_VARIABLE_LENGTH, + .init = rc4_init_key, + .cipher = rc4_cipher, }; const EVP_CIPHER *EVP_rc4(void) { return &rc4; } diff --git a/src/decrepit/blowfish/blowfish.c b/src/decrepit/blowfish/blowfish.c index 654cd86f9..82acb5f89 100644 --- a/src/decrepit/blowfish/blowfish.c +++ b/src/decrepit/blowfish/blowfish.c @@ -594,27 +594,36 @@ static int bf_cfb_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in, } static const EVP_CIPHER bf_ecb = { - NID_bf_ecb, BF_BLOCK /* block_size */, - 16 /* key_size */, BF_BLOCK /* iv_len */, - sizeof(BF_KEY), EVP_CIPH_ECB_MODE | EVP_CIPH_VARIABLE_LENGTH, - bf_init_key, bf_ecb_cipher, - NULL /* cleanup */, NULL /* ctrl */, + .nid = NID_bf_ecb, + .block_size = BF_BLOCK, + .key_len = 16, + .iv_len = BF_BLOCK, + .ctx_size = sizeof(BF_KEY), + .flags = EVP_CIPH_ECB_MODE | EVP_CIPH_VARIABLE_LENGTH, + .init = bf_init_key, + .cipher = bf_ecb_cipher, }; static const EVP_CIPHER bf_cbc = { - NID_bf_cbc, BF_BLOCK /* block_size */, - 16 /* key_size */, BF_BLOCK /* iv_len */, - sizeof(BF_KEY), EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH, - bf_init_key, bf_cbc_cipher, - NULL /* cleanup */, NULL /* ctrl */, + .nid = NID_bf_cbc, + .block_size = BF_BLOCK, + .key_len = 16, + .iv_len = BF_BLOCK, + .ctx_size = sizeof(BF_KEY), + .flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH, + .init = bf_init_key, + .cipher = bf_cbc_cipher, }; static const EVP_CIPHER bf_cfb = { - NID_bf_cfb64, 1 /* block_size */, - 16 /* key_size */, BF_BLOCK /* iv_len */, - sizeof(BF_KEY), EVP_CIPH_CFB_MODE | EVP_CIPH_VARIABLE_LENGTH, - bf_init_key, bf_cfb_cipher, - NULL /* cleanup */, NULL /* ctrl */, + .nid = NID_bf_cfb64, + .block_size = 1, + .key_len = 16, + .iv_len = BF_BLOCK, + .ctx_size = sizeof(BF_KEY), + .flags = EVP_CIPH_CFB_MODE | EVP_CIPH_VARIABLE_LENGTH, + .init = bf_init_key, + .cipher = bf_cfb_cipher, }; const EVP_CIPHER *EVP_bf_ecb(void) { return &bf_ecb; } diff --git a/src/decrepit/cast/cast.c b/src/decrepit/cast/cast.c index 9e87b3f76..f6f1963ab 100644 --- a/src/decrepit/cast/cast.c +++ b/src/decrepit/cast/cast.c @@ -437,19 +437,25 @@ static int cast_cbc_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, const uint8_t *in, } static const EVP_CIPHER cast5_ecb = { - NID_cast5_ecb, CAST_BLOCK, - CAST_KEY_LENGTH, CAST_BLOCK /* iv_len */, - sizeof(CAST_KEY), EVP_CIPH_ECB_MODE | EVP_CIPH_VARIABLE_LENGTH, - cast_init_key, cast_ecb_cipher, - NULL /* cleanup */, NULL /* ctrl */, + .nid = NID_cast5_ecb, + .block_size = CAST_BLOCK, + .key_len = CAST_KEY_LENGTH, + .iv_len = CAST_BLOCK, + .ctx_size = sizeof(CAST_KEY), + .flags = EVP_CIPH_ECB_MODE | EVP_CIPH_VARIABLE_LENGTH, + .init = cast_init_key, + .cipher = cast_ecb_cipher, }; static const EVP_CIPHER cast5_cbc = { - NID_cast5_cbc, CAST_BLOCK, - CAST_KEY_LENGTH, CAST_BLOCK /* iv_len */, - sizeof(CAST_KEY), EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH, - cast_init_key, cast_cbc_cipher, - NULL /* cleanup */, NULL /* ctrl */, + .nid = NID_cast5_cbc, + .block_size = CAST_BLOCK, + .key_len = CAST_KEY_LENGTH, + .iv_len = CAST_BLOCK, + .ctx_size = sizeof(CAST_KEY), + .flags = EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH, + .init = cast_init_key, + .cipher = cast_cbc_cipher, }; const EVP_CIPHER *EVP_cast5_ecb(void) { return &cast5_ecb; } diff --git a/src/decrepit/cfb/cfb.c b/src/decrepit/cfb/cfb.c index 12709a48b..0ac32288c 100644 --- a/src/decrepit/cfb/cfb.c +++ b/src/decrepit/cfb/cfb.c @@ -52,24 +52,36 @@ static int aes_cfb128_cipher(EVP_CIPHER_CTX *ctx, uint8_t *out, } static const EVP_CIPHER aes_128_cfb128 = { - NID_aes_128_cfb128, 1 /* block_size */, 16 /* key_size */, - 16 /* iv_len */, sizeof(EVP_CFB_CTX), EVP_CIPH_CFB_MODE, - aes_cfb_init_key, aes_cfb128_cipher, NULL /* cleanup */, - NULL /* ctrl */, + .nid = NID_aes_128_cfb128, + .block_size = 1, + .key_len = 16, + .iv_len = 16, + .ctx_size = sizeof(EVP_CFB_CTX), + .flags = EVP_CIPH_CFB_MODE, + .init = aes_cfb_init_key, + .cipher = aes_cfb128_cipher, }; static const EVP_CIPHER aes_192_cfb128 = { - NID_aes_192_cfb128, 1 /* block_size */, 24 /* key_size */, - 16 /* iv_len */, sizeof(EVP_CFB_CTX), EVP_CIPH_CFB_MODE, - aes_cfb_init_key, aes_cfb128_cipher, NULL /* cleanup */, - NULL /* ctrl */, + .nid = NID_aes_192_cfb128, + .block_size = 1, + .key_len = 24, + .iv_len = 16, + .ctx_size = sizeof(EVP_CFB_CTX), + .flags = EVP_CIPH_CFB_MODE, + .init = aes_cfb_init_key, + .cipher = aes_cfb128_cipher, }; static const EVP_CIPHER aes_256_cfb128 = { - NID_aes_256_cfb128, 1 /* block_size */, 32 /* key_size */, - 16 /* iv_len */, sizeof(EVP_CFB_CTX), EVP_CIPH_CFB_MODE, - aes_cfb_init_key, aes_cfb128_cipher, NULL /* cleanup */, - NULL /* ctrl */, + .nid = NID_aes_256_cfb128, + .block_size = 1, + .key_len = 32, + .iv_len = 16, + .ctx_size = sizeof(EVP_CFB_CTX), + .flags = EVP_CIPH_CFB_MODE, + .init = aes_cfb_init_key, + .cipher = aes_cfb128_cipher, }; const EVP_CIPHER *EVP_aes_128_cfb128(void) { return &aes_128_cfb128; } diff --git a/src/decrepit/xts/xts.c b/src/decrepit/xts/xts.c index b44d6f4d9..47c704404 100644 --- a/src/decrepit/xts/xts.c +++ b/src/decrepit/xts/xts.c @@ -229,16 +229,16 @@ static int aes_xts_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) { } static const EVP_CIPHER aes_256_xts = { - NID_aes_256_xts, - 1 /* block_size */, - 64 /* key_size (2 AES keys) */, - 16 /* iv_len */, - sizeof(EVP_AES_XTS_CTX), - EVP_CIPH_XTS_MODE | EVP_CIPH_CUSTOM_IV | EVP_CIPH_ALWAYS_CALL_INIT | - EVP_CIPH_CTRL_INIT | EVP_CIPH_CUSTOM_COPY, - aes_xts_init_key, - aes_xts_cipher, - NULL /* cleanup */, - aes_xts_ctrl}; + .nid = NID_aes_256_xts, + .block_size = 1, + .key_len = 64 /* 2 AES-256 keys */, + .iv_len = 16, + .ctx_size = sizeof(EVP_AES_XTS_CTX), + .flags = EVP_CIPH_XTS_MODE | EVP_CIPH_CUSTOM_IV | + EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT | + EVP_CIPH_CUSTOM_COPY, + .init = aes_xts_init_key, + .cipher = aes_xts_cipher, + .ctrl = aes_xts_ctrl}; const EVP_CIPHER *EVP_aes_256_xts(void) { return &aes_256_xts; }