Skip to content

Commit 7b45205

Browse files
committed
Run clang-format on relevant files to satisfy style-checker.
1 parent c03d9f9 commit 7b45205

3 files changed

Lines changed: 42 additions & 42 deletions

File tree

include/crypto/sm4_platform.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
#define OSSL_SM4_PLATFORM_H
1212
#pragma once
1313

14-
# if defined(OPENSSL_CPUID_OBJ)
15-
# if defined(__aarch64__) || defined (_M_ARM64)
16-
# include "crypto/arm_arch.h"
14+
#if defined(OPENSSL_CPUID_OBJ)
15+
#if defined(__aarch64__) || defined(_M_ARM64)
16+
#include "crypto/arm_arch.h"
1717
extern unsigned int OPENSSL_arm_midr;
1818
static inline int vpsm4_capable(void)
1919
{

providers/implementations/ciphers/cipher_sm4_hw.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static int cipher_hw_sm4_initkey(PROV_CIPHER_CTX *ctx,
4343
} else
4444
#endif
4545
#ifdef VPSM4_EX_CAPABLE
46-
if (VPSM4_EX_CAPABLE && (ctx->mode != EVP_CIPH_CBC_MODE)) {
46+
if (VPSM4_EX_CAPABLE && (ctx->mode != EVP_CIPH_CBC_MODE)) {
4747
vpsm4_ex_set_encrypt_key(key, ks);
4848
ctx->block = (block128_f)vpsm4_ex_encrypt;
4949
ctx->stream.cbc = NULL;
@@ -54,7 +54,7 @@ static int cipher_hw_sm4_initkey(PROV_CIPHER_CTX *ctx,
5454
} else
5555
#endif
5656
#ifdef VPSM4_CAPABLE
57-
if (VPSM4_CAPABLE && (ctx->mode != EVP_CIPH_CBC_MODE)) {
57+
if (VPSM4_CAPABLE && (ctx->mode != EVP_CIPH_CBC_MODE)) {
5858
vpsm4_set_encrypt_key(key, ks);
5959
ctx->block = (block128_f)vpsm4_encrypt;
6060
ctx->stream.cbc = NULL;
@@ -85,7 +85,7 @@ static int cipher_hw_sm4_initkey(PROV_CIPHER_CTX *ctx,
8585
} else
8686
#endif
8787
#ifdef VPSM4_EX_CAPABLE
88-
if (VPSM4_EX_CAPABLE) {
88+
if (VPSM4_EX_CAPABLE) {
8989
vpsm4_ex_set_decrypt_key(key, ks);
9090
ctx->block = (block128_f)vpsm4_ex_decrypt;
9191
ctx->stream.cbc = NULL;
@@ -96,7 +96,7 @@ static int cipher_hw_sm4_initkey(PROV_CIPHER_CTX *ctx,
9696
} else
9797
#endif
9898
#ifdef VPSM4_CAPABLE
99-
if (VPSM4_CAPABLE) {
99+
if (VPSM4_CAPABLE) {
100100
vpsm4_set_decrypt_key(key, ks);
101101
ctx->block = (block128_f)vpsm4_decrypt;
102102
ctx->stream.cbc = NULL;
@@ -117,17 +117,17 @@ static int cipher_hw_sm4_initkey(PROV_CIPHER_CTX *ctx,
117117

118118
IMPLEMENT_CIPHER_HW_COPYCTX(cipher_hw_sm4_copyctx, PROV_SM4_CTX)
119119

120-
#define PROV_CIPHER_HW_sm4_mode(mode) \
121-
static const PROV_CIPHER_HW sm4_##mode = { \
122-
cipher_hw_sm4_initkey, \
123-
ossl_cipher_hw_generic_##mode, \
124-
cipher_hw_sm4_copyctx \
125-
}; \
126-
PROV_CIPHER_HW_declare(mode) \
127-
const PROV_CIPHER_HW * \
128-
ossl_prov_cipher_hw_sm4_##mode(size_t keybits) \
129-
{ \
130-
PROV_CIPHER_HW_select(mode) return &sm4_##mode; \
120+
#define PROV_CIPHER_HW_sm4_mode(mode) \
121+
static const PROV_CIPHER_HW sm4_##mode = { \
122+
cipher_hw_sm4_initkey, \
123+
ossl_cipher_hw_generic_##mode, \
124+
cipher_hw_sm4_copyctx \
125+
}; \
126+
PROV_CIPHER_HW_declare(mode) \
127+
const PROV_CIPHER_HW * \
128+
ossl_prov_cipher_hw_sm4_##mode(size_t keybits) \
129+
{ \
130+
PROV_CIPHER_HW_select(mode) return &sm4_##mode; \
131131
}
132132

133133
#if defined(OPENSSL_CPUID_OBJ) && defined(__riscv) && __riscv_xlen == 64

test/sm4_internal_test.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
#define VPSM4_ASM
2323

2424
#if defined(OPENSSL_CPUID_OBJ) && (defined(__aarch64__) || defined(_M_ARM64))
25-
# include "crypto/arm_arch.h"
25+
#include "crypto/arm_arch.h"
2626
#endif
2727

28-
# include "crypto/sm4.h"
29-
# include "crypto/modes.h"
30-
# include "crypto/sm4_platform.h"
28+
#include "crypto/sm4.h"
29+
#include "crypto/modes.h"
30+
#include "crypto/sm4_platform.h"
3131

3232
static int test_sm4_ecb(void)
3333
{
@@ -73,7 +73,7 @@ static int test_sm4_ecb(void)
7373
} else
7474
#endif
7575
#if defined(VPSM4_CAPABLE)
76-
if (vpsm4_capable()) {
76+
if (vpsm4_capable()) {
7777
vpsm4_ecb_encrypt(block, block, sizeof(block), &key, SM4_ENCRYPT);
7878
} else
7979
#endif
@@ -90,7 +90,7 @@ static int test_sm4_ecb(void)
9090
} else
9191
#endif
9292
#if defined(VPSM4_CAPABLE)
93-
if (vpsm4_capable()) {
93+
if (vpsm4_capable()) {
9494
vpsm4_ecb_encrypt(block, block, sizeof(block), &key, SM4_ENCRYPT);
9595
} else
9696
#endif
@@ -107,7 +107,7 @@ static int test_sm4_ecb(void)
107107
} else
108108
#endif
109109
#if defined(VPSM4_CAPABLE)
110-
if (vpsm4_capable()) {
110+
if (vpsm4_capable()) {
111111
vpsm4_set_decrypt_key(k, &key);
112112
}
113113
#endif
@@ -119,12 +119,12 @@ static int test_sm4_ecb(void)
119119
} else
120120
#endif
121121
#if defined(VPSM4_CAPABLE)
122-
if (vpsm4_capable()) {
122+
if (vpsm4_capable()) {
123123
vpsm4_ecb_encrypt(block, block, sizeof(block), &key, SM4_DECRYPT);
124124
} else
125125
#endif
126126
{
127-
ossl_sm4_decrypt(block, block, &key);
127+
ossl_sm4_decrypt(block, block, &key);
128128
}
129129
}
130130
if (!TEST_mem_eq(block, SM4_BLOCK_SIZE, input, SM4_BLOCK_SIZE))
@@ -172,43 +172,43 @@ static int test_vpsm4_cbc(void)
172172
#if defined(VPSM4_EX_CAPABLE)
173173
if (vpsm4_ex_capable()) {
174174
vpsm4_ex_cbc_encrypt(plaintext, ciphertext, sizeof(plaintext), &key, iv,
175-
SM4_ENCRYPT);
175+
SM4_ENCRYPT);
176176
} else
177177
#endif
178178
#if defined(VPSM4_CAPABLE)
179-
if (vpsm4_capable()) {
179+
if (vpsm4_capable()) {
180180
vpsm4_cbc_encrypt(plaintext, ciphertext, sizeof(plaintext), &key, iv,
181-
SM4_ENCRYPT);
181+
SM4_ENCRYPT);
182182
} else
183183
#endif
184184
{
185185
CRYPTO_cbc128_encrypt(plaintext, ciphertext, sizeof(plaintext), &key, iv,
186-
(block128_f)ossl_sm4_encrypt);
186+
(block128_f)ossl_sm4_encrypt);
187187
}
188188

189189
if (!TEST_mem_eq(ciphertext, sizeof(ciphertext),
190-
expected_ciphertext, sizeof(expected_ciphertext)))
190+
expected_ciphertext, sizeof(expected_ciphertext)))
191191
return 0;
192192

193193
/* --- Test Decryption --- */
194194
memcpy(iv, iv_bytes, SM4_BLOCK_SIZE); /* Reset IV for decryption */
195195
#if defined(VPSM4_EX_CAPABLE)
196196
if (vpsm4_ex_capable()) {
197-
vpsm4_ex_set_decrypt_key(key_bytes, &key);
197+
vpsm4_ex_set_decrypt_key(key_bytes, &key);
198198
vpsm4_ex_cbc_encrypt(ciphertext, decrypted, sizeof(ciphertext), &key, iv,
199-
SM4_DECRYPT);
199+
SM4_DECRYPT);
200200
} else
201201
#endif
202202
#if defined(VPSM4_CAPABLE)
203-
if (vpsm4_capable()) {
204-
vpsm4_set_decrypt_key(key_bytes, &key);
203+
if (vpsm4_capable()) {
204+
vpsm4_set_decrypt_key(key_bytes, &key);
205205
vpsm4_cbc_encrypt(ciphertext, decrypted, sizeof(ciphertext), &key, iv,
206-
SM4_DECRYPT);
206+
SM4_DECRYPT);
207207
} else
208208
#endif
209209
{
210210
CRYPTO_cbc128_decrypt(ciphertext, decrypted, sizeof(ciphertext), &key, iv,
211-
(block128_f)ossl_sm4_decrypt);
211+
(block128_f)ossl_sm4_decrypt);
212212
}
213213

214214
if (!TEST_mem_eq(decrypted, sizeof(decrypted), plaintext, sizeof(plaintext)))
@@ -218,7 +218,7 @@ static int test_vpsm4_cbc(void)
218218
}
219219

220220
/*
221-
* Internal SM4 CBC test - compiled C implementation.
221+
* Internal SM4 CBC test - compiled C implementation.
222222
*/
223223
static int test_sm4_cbc(void)
224224
{
@@ -253,16 +253,16 @@ static int test_sm4_cbc(void)
253253
ossl_sm4_set_key(key_bytes, &key);
254254
memcpy(iv, iv_bytes, SM4_BLOCK_SIZE); /* Use a working copy of the IV */
255255
CRYPTO_cbc128_encrypt(plaintext, ciphertext, sizeof(plaintext), &key, iv,
256-
(block128_f)ossl_sm4_encrypt);
256+
(block128_f)ossl_sm4_encrypt);
257257

258258
if (!TEST_mem_eq(ciphertext, sizeof(ciphertext),
259-
expected_ciphertext, sizeof(expected_ciphertext)))
259+
expected_ciphertext, sizeof(expected_ciphertext)))
260260
return 0;
261261

262262
/* --- Test Decryption --- */
263263
memcpy(iv, iv_bytes, SM4_BLOCK_SIZE); /* Reset IV for decryption */
264264
CRYPTO_cbc128_decrypt(ciphertext, decrypted, sizeof(ciphertext), &key, iv,
265-
(block128_f)ossl_sm4_decrypt);
265+
(block128_f)ossl_sm4_decrypt);
266266

267267
if (!TEST_mem_eq(decrypted, sizeof(decrypted), plaintext, sizeof(plaintext)))
268268
return 0;

0 commit comments

Comments
 (0)