Skip to content

Commit bcb7788

Browse files
committed
code style
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
1 parent 132687e commit bcb7788

3 files changed

Lines changed: 50 additions & 27 deletions

File tree

drivers/builtin/src/aesce.c

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ int mbedtls_aesce_has_support_impl(void)
182182

183183

184184
static inline uint8x16_t aesce_encrypt_block_inline(uint8x16_t block,
185-
const uint8x16_t *vkeys,
186-
int nr)
185+
const uint8x16_t *vkeys,
186+
int nr)
187187
{
188188
/* 10, 12 or 14 rounds. Unroll loop. */
189189
#if defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH)
@@ -210,8 +210,8 @@ static inline uint8x16_t aesce_encrypt_block_inline(uint8x16_t block,
210210
}
211211

212212
static NO_INLINE uint8x16_t aesce_encrypt_block(uint8x16_t block,
213-
const uint8x16_t *vkeys,
214-
const int nr)
213+
const uint8x16_t *vkeys,
214+
const int nr)
215215
{
216216
return aesce_encrypt_block_inline(block, vkeys, nr);
217217
}
@@ -781,16 +781,17 @@ static inline uint8x16_t poly_mult_reduce(uint8x16x4_t input)
781781
}
782782

783783
// Having a not-inlined copy helps code-size on non-perf-sensitive paths
784-
static NO_INLINE uint8x16_t poly_mult_multiply_and_reduce(uint8x16_t a, uint8x16_t b) {
785-
return poly_mult_reduce(poly_mult_128(a,b));
784+
static NO_INLINE uint8x16_t poly_mult_multiply_and_reduce(uint8x16_t a, uint8x16_t b)
785+
{
786+
return poly_mult_reduce(poly_mult_128(a, b));
786787
}
787788

788789
/*
789790
* GCM multiplication: c = a times b in GF(2^128)
790791
*/
791792
NO_INLINE void mbedtls_aesce_gcm_mult(unsigned char c[16],
792-
const unsigned char a[16],
793-
const unsigned char b[16])
793+
const unsigned char a[16],
794+
const unsigned char b[16])
794795
{
795796
uint8x16_t va, vb, vc;
796797
va = vrbitq_u8(vld1q_u8(&a[0]));
@@ -848,7 +849,8 @@ void mbedtls_aesce_gcm_update_block_partial(
848849
const uint8_t *input,
849850
uint8_t *output,
850851
unsigned offset, unsigned len, uint8_t scratch[32]
851-
) {
852+
)
853+
{
852854
MBEDTLS_ASSUME(len > 0);
853855
int nr = MBEDTLS_AES_GET_NR(aes_ctx);
854856
const uint8x16_t *vkeys = aes_ctx->vkeys;
@@ -901,11 +903,11 @@ void mbedtls_aesce_gcm_update_block_partial(
901903

902904
MBEDTLS_OPTIMIZE_FOR_PERFORMANCE
903905
void mbedtls_aesce_gcm_update_blocks(
904-
mbedtls_aes_context *aes_ctx,
905-
mbedtls_gcm_context *ctx,
906-
const unsigned char *input,
907-
unsigned char *output,
908-
size_t blocks)
906+
mbedtls_aes_context *aes_ctx,
907+
mbedtls_gcm_context *ctx,
908+
const unsigned char *input,
909+
unsigned char *output,
910+
size_t blocks)
909911
{
910912
const uint8x16_t *vkeys = aes_ctx->vkeys;
911913

@@ -927,7 +929,9 @@ void mbedtls_aesce_gcm_update_blocks(
927929
MBEDTLS_MAYBE_UNUSED const uint8x16x4_t vh = ctx->vghash_4;
928930

929931
// compute keystream in ve
930-
for (size_t b = 0; b < (blocks - (blocks % MBEDTLS_AESCE_GCM_MULTIBLOCK)); b += MBEDTLS_AESCE_GCM_MULTIBLOCK) {
932+
for (size_t b = 0;
933+
b < (blocks - (blocks % MBEDTLS_AESCE_GCM_MULTIBLOCK));
934+
b += MBEDTLS_AESCE_GCM_MULTIBLOCK) {
931935
// manually unrolling and ordering instructions makes a big difference
932936
// to performance (esp. GCC), and also a small size benefit.
933937

@@ -1026,7 +1030,7 @@ void mbedtls_aesce_gcm_update_blocks(
10261030
vtag = poly_mult_reduce(tag_x4);
10271031
}
10281032
#else
1029-
uint8x16_t ct0,ct1,ct2,ct3;
1033+
uint8x16_t ct0, ct1, ct2, ct3;
10301034
if (mode == MBEDTLS_AES_ENCRYPT) {
10311035
ct0 = vout[0];
10321036
ct1 = vout[1];
@@ -1076,7 +1080,7 @@ void mbedtls_aesce_gcm_update_blocks(
10761080
0,
10771081
16,
10781082
scratch
1079-
);
1083+
);
10801084
input += 16;
10811085
output += 16;
10821086
}

drivers/builtin/src/aesce.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ int mbedtls_aesce_crypt_ecb(mbedtls_aes_context *ctx,
120120
#if MBEDTLS_AESCE_OPTIMISE_FOR_SIZE == 0
121121

122122
void mbedtls_aesce_gcm_update_blocks(
123-
mbedtls_aes_context *aes_ctx,
124-
mbedtls_gcm_context *ctx,
125-
const unsigned char *input,
126-
unsigned char *output,
127-
size_t blocks);
123+
mbedtls_aes_context *aes_ctx,
124+
mbedtls_gcm_context *ctx,
125+
const unsigned char *input,
126+
unsigned char *output,
127+
size_t blocks);
128128

129129
#endif // MBEDTLS_AESCE_OPTIMISE_FOR_SIZE
130130

@@ -146,7 +146,7 @@ void mbedtls_aesce_gcm_update_block_partial(
146146
unsigned offset,
147147
unsigned length,
148148
uint8_t scratch[32]
149-
);
149+
);
150150

151151
#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT)
152152
/**

drivers/builtin/src/gcm.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,8 @@ static int gcm_mask(mbedtls_gcm_context *ctx,
601601
};
602602
uint8_t **ap = (ctx->mode == MBEDTLS_GCM_DECRYPT) ? &ps[0] : &ps[3];
603603
for (unsigned i = 0; i < 6; i += 3) {
604-
mbedtls_xor_no_simd(ap[i], (const uint8_t *) ap[i + 1], (const uint8_t *) ap[i + 2], use_len);
604+
mbedtls_xor_no_simd(ap[i], (const uint8_t *) ap[i + 1], (const uint8_t *) ap[i + 2],
605+
use_len);
605606
}
606607

607608
return 0;
@@ -663,7 +664,13 @@ int mbedtls_gcm_update(mbedtls_gcm_context *ctx,
663664

664665
#if defined(MBEDTLS_AESCE_HAVE_CODE) && defined(MBEDTLS_AES_C)
665666
if (use_aesce) {
666-
mbedtls_aesce_gcm_update_block_partial(GCM_GET_AES_CTX(ctx), ctx, p, out_p, offset, use_len, scratch);
667+
mbedtls_aesce_gcm_update_block_partial(GCM_GET_AES_CTX(ctx),
668+
ctx,
669+
p,
670+
out_p,
671+
offset,
672+
use_len,
673+
scratch);
667674
} else
668675
#endif
669676
{
@@ -689,7 +696,13 @@ int mbedtls_gcm_update(mbedtls_gcm_context *ctx,
689696
size_t blocks = input_length / 16;
690697
#if MBEDTLS_AESCE_OPTIMISE_FOR_SIZE == 1
691698
for (size_t i = 0; i < blocks; i++) {
692-
mbedtls_aesce_gcm_update_block_partial(GCM_GET_AES_CTX(ctx), ctx, p + i * 16, out_p + i * 16, 0, 16, scratch);
699+
mbedtls_aesce_gcm_update_block_partial(GCM_GET_AES_CTX(ctx),
700+
ctx,
701+
p + i * 16,
702+
out_p + i * 16,
703+
0,
704+
16,
705+
scratch);
693706
}
694707
#else
695708
mbedtls_aesce_gcm_update_blocks(GCM_GET_AES_CTX(ctx), ctx, p, out_p, blocks);
@@ -717,7 +730,13 @@ int mbedtls_gcm_update(mbedtls_gcm_context *ctx,
717730
if (input_length > 0) {
718731
#if defined(MBEDTLS_AESCE_HAVE_CODE) && defined(MBEDTLS_AES_C)
719732
if (use_aesce) {
720-
mbedtls_aesce_gcm_update_block_partial(GCM_GET_AES_CTX(ctx), ctx, p, out_p, 0, input_length, scratch);
733+
mbedtls_aesce_gcm_update_block_partial(GCM_GET_AES_CTX(ctx),
734+
ctx,
735+
p,
736+
out_p,
737+
0,
738+
input_length,
739+
scratch);
721740
} else
722741
#endif
723742
{

0 commit comments

Comments
 (0)