Files
openssl/crypto/evp/e_sm4.c
Matt Caswell 32eaa748a3 Cleanup block cipher macros in include/crypto/evp.h
Remove some unneeded deadcode and fix the formatting

Also fix all users of those macros to avoid compilation warnings

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29446)
2026-01-12 08:31:38 +00:00

48 lines
2.3 KiB
C

/*
* Copyright 2017-2022 The OpenSSL Project Authors. All Rights Reserved.
* Copyright 2017 Ribose Inc. All Rights Reserved.
* Ported from Ribose contributions from Botan.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#include "internal/deprecated.h"
#include "internal/cryptlib.h"
#ifndef OPENSSL_NO_SM4
#include <openssl/evp.h>
#include <openssl/modes.h>
#include "crypto/sm4.h"
#include "crypto/evp.h"
#include "crypto/sm4_platform.h"
#include "evp_local.h"
#define BLOCK_CIPHER_generic(nid, blocksize, ivlen, nmode, mode, MODE, flags) \
static const EVP_CIPHER sm4_##mode = { \
nid##_##nmode, blocksize, 128 / 8, ivlen, \
flags | EVP_CIPH_##MODE##_MODE, \
EVP_ORIG_GLOBAL, \
NULL, \
NULL, \
NULL, \
0, \
NULL, NULL, NULL, NULL \
}; \
const EVP_CIPHER *EVP_sm4_##mode(void) \
{ \
return &sm4_##mode; \
}
#define DEFINE_BLOCK_CIPHERS(nid, flags) \
BLOCK_CIPHER_generic(nid, 16, 16, cbc, cbc, CBC, flags | EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid, 16, 0, ecb, ecb, ECB, flags | EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid, 1, 16, ofb128, ofb, OFB, flags | EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid, 1, 16, cfb128, cfb, CFB, flags | EVP_CIPH_FLAG_DEFAULT_ASN1) \
BLOCK_CIPHER_generic(nid, 1, 16, ctr, ctr, CTR, flags)
DEFINE_BLOCK_CIPHERS(NID_sm4, 0)
#endif