Skip to content

Commit 0c7a734

Browse files
degjorvanordicjm
authored andcommitted
nrf_security: CRACEN: Remove single symbol variable names
Update variable naming to remove single symbol variable names Ignored mathmatical notation Counter variables were not changed This should make the code more readable Signed-off-by: Dag Erik Gjørvad <[email protected]>
1 parent 7b23a37 commit 0c7a734

File tree

16 files changed

+710
-661
lines changed

16 files changed

+710
-661
lines changed

subsys/nrf_security/src/drivers/cracen/cracenpsa/src/cipher.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,8 @@ psa_status_t cracen_cipher_update(cracen_cipher_operation_t *operation, const ui
521521
__ASSERT_NO_MSG(output_length != NULL);
522522

523523
int sx_status = SX_ERR_UNINITIALIZED_OBJ;
524+
psa_status_t psa_status = PSA_ERROR_CORRUPTION_DETECTED;
524525
*output_length = 0;
525-
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
526526

527527
if (input_length == 0) {
528528
return PSA_SUCCESS;
@@ -577,23 +577,23 @@ psa_status_t cracen_cipher_update(cracen_cipher_operation_t *operation, const ui
577577
if (operation->unprocessed_input_bytes) {
578578
__ASSERT_NO_MSG(operation->unprocessed_input_bytes ==
579579
operation->blk_size);
580-
status = crypt_ecb(
580+
psa_status = crypt_ecb(
581581
&operation->keyref, operation->unprocessed_input,
582582
operation->unprocessed_input_bytes, output,
583583
output_size, output_length, operation->dir);
584-
if (status != PSA_SUCCESS) {
585-
return status;
584+
if (psa_status != PSA_SUCCESS) {
585+
return psa_status;
586586
}
587587
output += (uint32_t)operation->unprocessed_input_bytes;
588588
operation->unprocessed_input_bytes = 0;
589589
}
590590

591591
if (block_bytes) {
592-
status = crypt_ecb(
592+
psa_status = crypt_ecb(
593593
&operation->keyref, input, block_bytes, output,
594594
output_size, output_length, operation->dir);
595-
if (status != PSA_SUCCESS) {
596-
return status;
595+
if (psa_status != PSA_SUCCESS) {
596+
return psa_status;
597597
}
598598
}
599599
}
@@ -605,10 +605,10 @@ psa_status_t cracen_cipher_update(cracen_cipher_operation_t *operation, const ui
605605
return silex_statuscodes_to_psa(sx_status);
606606
}
607607
} else {
608-
psa_status_t r = initialize_cipher(operation);
608+
psa_status = initialize_cipher(operation);
609609

610-
if (r != PSA_SUCCESS) {
611-
return r;
610+
if (psa_status != PSA_SUCCESS) {
611+
return psa_status;
612612
}
613613
}
614614

@@ -659,7 +659,7 @@ psa_status_t cracen_cipher_update(cracen_cipher_operation_t *operation, const ui
659659
operation->unprocessed_input_bytes = input_length - block_bytes;
660660
}
661661

662-
(void)status;
662+
(void)psa_status;
663663
return PSA_SUCCESS;
664664
}
665665

@@ -698,10 +698,10 @@ psa_status_t cracen_cipher_finish(cracen_cipher_operation_t *operation, uint8_t
698698
return silex_statuscodes_to_psa(sx_status);
699699
}
700700
} else {
701-
psa_status_t r = initialize_cipher(operation);
701+
psa_status_t result = initialize_cipher(operation);
702702

703-
if (r != PSA_SUCCESS) {
704-
return r;
703+
if (result != PSA_SUCCESS) {
704+
return result;
705705
}
706706
}
707707

subsys/nrf_security/src/drivers/cracen/cracenpsa/src/common.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,11 @@ int cracen_signature_get_rsa_key(struct cracen_rsa_key *rsa, bool extract_pubkey
563563
{
564564
int ret, version;
565565
size_t len;
566-
uint8_t *p;
566+
uint8_t *parser_ptr;
567567
uint8_t *end;
568568

569-
p = (uint8_t *)key;
570-
end = p + keylen;
569+
parser_ptr = (uint8_t *)key;
570+
end = parser_ptr + keylen;
571571

572572
if (!extract_pubkey && !is_key_pair) {
573573
return SX_ERR_INVALID_KEYREF;
@@ -598,15 +598,15 @@ int cracen_signature_get_rsa_key(struct cracen_rsa_key *rsa, bool extract_pubkey
598598
* OpenSSL wraps public keys with an RSA algorithm identifier that we skip
599599
* if it is present.
600600
*/
601-
ret = cracen_asn1_get_tag(&p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE);
601+
ret = cracen_asn1_get_tag(&parser_ptr, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE);
602602
if (ret) {
603603
return SX_ERR_INVALID_KEYREF;
604604
}
605605

606-
end = p + len;
606+
end = parser_ptr + len;
607607

608608
if (is_key_pair) {
609-
ret = cracen_asn1_get_int(&p, end, &version);
609+
ret = cracen_asn1_get_int(&parser_ptr, end, &version);
610610
if (ret) {
611611
return SX_ERR_INVALID_KEYREF;
612612
}
@@ -615,7 +615,7 @@ int cracen_signature_get_rsa_key(struct cracen_rsa_key *rsa, bool extract_pubkey
615615
}
616616
} else {
617617
/* Skip algorithm identifier prefix. */
618-
uint8_t *id_seq = p;
618+
uint8_t *id_seq = parser_ptr;
619619

620620
ret = cracen_asn1_get_tag(&id_seq, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE);
621621
if (ret == 0) {
@@ -634,9 +634,10 @@ int cracen_signature_get_rsa_key(struct cracen_rsa_key *rsa, bool extract_pubkey
634634
return SX_ERR_INVALID_KEYREF;
635635
}
636636

637-
p = id_seq + 1;
637+
parser_ptr = id_seq + 1;
638638

639-
ret = cracen_asn1_get_tag(&p, end, &len, ASN1_CONSTRUCTED | ASN1_SEQUENCE);
639+
ret = cracen_asn1_get_tag(&parser_ptr, end, &len,
640+
ASN1_CONSTRUCTED | ASN1_SEQUENCE);
640641
if (ret) {
641642
return SX_ERR_INVALID_KEYREF;
642643
}
@@ -646,7 +647,7 @@ int cracen_signature_get_rsa_key(struct cracen_rsa_key *rsa, bool extract_pubkey
646647
*rsa = CRACEN_KEY_INIT_RSA(modulus, exponent);
647648

648649
/* Import N */
649-
ret = cracen_signature_asn1_get_operand(&p, end, modulus);
650+
ret = cracen_signature_asn1_get_operand(&parser_ptr, end, modulus);
650651
if (ret) {
651652
return ret;
652653
}
@@ -656,7 +657,7 @@ int cracen_signature_get_rsa_key(struct cracen_rsa_key *rsa, bool extract_pubkey
656657
}
657658

658659
/* Import E */
659-
ret = cracen_signature_asn1_get_operand(&p, end, exponent);
660+
ret = cracen_signature_asn1_get_operand(&parser_ptr, end, exponent);
660661
if (ret) {
661662
return ret;
662663
}
@@ -665,7 +666,7 @@ int cracen_signature_get_rsa_key(struct cracen_rsa_key *rsa, bool extract_pubkey
665666
}
666667

667668
/* Import D */
668-
ret = cracen_signature_asn1_get_operand(&p, end, exponent);
669+
ret = cracen_signature_asn1_get_operand(&parser_ptr, end, exponent);
669670
if (ret) {
670671
return ret;
671672
}

subsys/nrf_security/src/drivers/cracen/silexpk/src/blind.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ void sx_pk_cnx_configure_blinding(struct sx_pk_cnx *cnx, struct sx_pk_blinder *p
1515
if (!prng || !caps->blinding) {
1616
return;
1717
}
18-
struct sx_pk_blinder **p = sx_pk_get_blinder(cnx);
19-
*p = prng;
18+
struct sx_pk_blinder **blinder_ptr = sx_pk_get_blinder(cnx);
19+
*blinder_ptr = prng;
2020
}
2121

2222
sx_pk_blind_factor sx_pk_default_blind_gen(struct sx_pk_blinder *blinder)

subsys/nrf_security/src/drivers/cracen/silexpk/src/iomem.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,27 @@
2222
void sx_clrpkmem(void *dst, size_t sz)
2323
{
2424
typedef int64_t clrblk_t;
25-
volatile char *d = (volatile char *)dst;
25+
volatile char *dst_ptr = (volatile char *)dst;
2626

2727
if (sz == 0) {
2828
return;
2929
}
3030

31-
while (sz && (!IS_NATURAL_ALIGNED(d, clrblk_t))) {
32-
*d = 0;
33-
d++;
31+
while (sz && (!IS_NATURAL_ALIGNED(dst_ptr, clrblk_t))) {
32+
*dst_ptr = 0;
33+
dst_ptr++;
3434
sz--;
3535
}
3636

3737
#if !defined(__aarch64__)
38-
memset((char *)d, 0, MASK_TO_NATURAL_SIZE(sz, clrblk_t));
39-
d += MASK_TO_NATURAL_SIZE(sz, clrblk_t);
38+
memset((char *)dst_ptr, 0, MASK_TO_NATURAL_SIZE(sz, clrblk_t));
39+
dst_ptr += MASK_TO_NATURAL_SIZE(sz, clrblk_t);
4040
sz -= MASK_TO_NATURAL_SIZE(sz, clrblk_t);
4141

4242
#endif
4343
while (sz) {
44-
*d = 0;
45-
d++;
44+
*dst_ptr = 0;
45+
dst_ptr++;
4646
sz--;
4747
}
4848
}
@@ -56,16 +56,16 @@ typedef struct uchunk tfrblk;
5656

5757
void sx_wrpkmem(void *dst, const void *src, size_t sz)
5858
{
59-
volatile char *d = (volatile char *)dst;
60-
volatile const char *s = (volatile const char *)src;
59+
volatile char *dst_ptr = (volatile char *)dst;
60+
volatile const char *src_ptr = (volatile const char *)src;
6161

62-
while (sz && (!IS_NATURAL_ALIGNED(d, tfrblk) || !IS_NATURAL_SIZE(sz, tfrblk))) {
63-
*d = *s;
64-
d++;
65-
s++;
62+
while (sz && (!IS_NATURAL_ALIGNED(dst_ptr, tfrblk) || !IS_NATURAL_SIZE(sz, tfrblk))) {
63+
*dst_ptr = *src_ptr;
64+
dst_ptr++;
65+
src_ptr++;
6666
sz--;
6767
}
68-
memcpy((char *)d, (char *)s, sz);
68+
memcpy((char *)dst_ptr, (char *)src_ptr, sz);
6969
}
7070

7171
#else /* 54LM20A requires word-aligned, word-sized memory accesses */

subsys/nrf_security/src/drivers/cracen/silexpk/target/baremetal_ba414e_with_ik/pk_baremetal.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,40 +134,40 @@ int sx_pk_wait(sx_pk_req *req)
134134
return read_status(req);
135135
}
136136

137-
void sx_pk_wrreg(struct sx_regs *regs, uint32_t addr, uint32_t v)
137+
void sx_pk_wrreg(struct sx_regs *regs, uint32_t addr, uint32_t value)
138138
{
139-
volatile uint32_t *p = (uint32_t *)(regs->base + addr);
139+
volatile uint32_t *reg_ptr = (uint32_t *)(regs->base + addr);
140140

141141
#ifdef SX_INSTRUMENT_MMIO_WITH_PRINTFS
142-
printk("sx_pk_wrreg(addr=0x%x, p=%p, val=0x%x)\r\n", addr, p, v);
142+
printk("sx_pk_wrreg(addr=0x%x, reg_ptr=%p, val=0x%x)\r\n", addr, reg_ptr, value);
143143
#endif
144-
if ((uintptr_t)p % 4) {
145-
SX_WARN_UNALIGNED_ADDR(p);
144+
if ((uintptr_t)reg_ptr % 4) {
145+
SX_WARN_UNALIGNED_ADDR(reg_ptr);
146146
}
147147

148-
*p = v;
148+
*reg_ptr = value;
149149
}
150150

151151
uint32_t sx_pk_rdreg(struct sx_regs *regs, uint32_t addr)
152152
{
153-
volatile uint32_t *p = (uint32_t *)(regs->base + addr);
154-
uint32_t v;
153+
volatile uint32_t *reg_ptr = (uint32_t *)(regs->base + addr);
154+
uint32_t value;
155155

156156

157157
#ifdef SX_INSTRUMENT_MMIO_WITH_PRINTFS
158-
printk("sx_pk_rdreg(addr=0x%x, p=%p)\r\n", addr, p);
158+
printk("sx_pk_rdreg(addr=0x%x, reg_ptr=%p)\r\n", addr, reg_ptr);
159159
#endif
160-
if ((uintptr_t)p % 4) {
161-
SX_WARN_UNALIGNED_ADDR(p);
160+
if ((uintptr_t)reg_ptr % 4) {
161+
SX_WARN_UNALIGNED_ADDR(reg_ptr);
162162
}
163163

164-
v = *p;
164+
value = *reg_ptr;
165165

166166
#ifdef SX_INSTRUMENT_MMIO_WITH_PRINTFS
167-
printk("result = 0x%x\r\n", v);
167+
printk("result = 0x%x\r\n", value);
168168
#endif
169169

170-
return v;
170+
return value;
171171
}
172172

173173
struct sx_pk_blinder **sx_pk_get_blinder(struct sx_pk_cnx *cnx)

0 commit comments

Comments
 (0)