Skip to content

Commit e3c9091

Browse files
Vge0rgerlubos
authored andcommitted
nrf_security: Fix 54lm20 alignment issue in Cracen
The Cracen in 54lm20 does not allow single byte writes in the PK memory. There was some single byte writes in Montgomery. This makes sure that the single byte writes are done using the relevant sx_ functions which implement workarounds for this issue when needed. Ref: NCSDK-33957 Signed-off-by: Georgios Vasilakis <[email protected]>
1 parent dbf8a43 commit e3c9091

File tree

1 file changed

+6
-6
lines changed
  • subsys/nrf_security/src/drivers/cracen/silexpk/src

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ struct sx_pk_acq_req sx_async_x25519_ptmult_go(const struct sx_x25519_op *k,
3434
sx_wrpkmem(inputs.p.addr, pt->bytes, SX_X25519_OP_SZ);
3535
sx_wrpkmem(inputs.k.addr, k->bytes, SX_X25519_OP_SZ);
3636
/* clamp the scalar */
37-
inputs.k.addr[31] |= 1 << 6;
38-
inputs.k.addr[31] &= 0x7f;
39-
inputs.k.addr[0] &= 0xF8;
37+
sx_wrpkmem_byte(&inputs.k.addr[31], (inputs.k.addr[31] | 1 << 6) & 0x7f);
38+
sx_wrpkmem_byte(&inputs.k.addr[0], inputs.k.addr[0] & 0xF8);
39+
4040
/* clamp the pt */
41-
inputs.p.addr[31] &= 0x7f;
41+
sx_wrpkmem_byte(&inputs.p.addr[31], inputs.p.addr[31] & 0x7f);
4242

4343
sx_pk_run(pkreq.req);
4444

@@ -90,8 +90,8 @@ struct sx_pk_acq_req sx_async_x448_ptmult_go(const struct sx_x448_op *k,
9090
sx_wrpkmem(inputs.p.addr, pt->bytes, SX_X448_OP_SZ);
9191
sx_wrpkmem(inputs.k.addr, k->bytes, SX_X448_OP_SZ);
9292
/* clamp the scalar */
93-
inputs.k.addr[55] |= 0x80;
94-
inputs.k.addr[0] &= 0xFC;
93+
sx_wrpkmem_byte(&inputs.k.addr[55], inputs.k.addr[55] | 0x80);
94+
sx_wrpkmem_byte(&inputs.k.addr[0], inputs.k.addr[0] & 0xFC);
9595

9696
sx_pk_run(pkreq.req);
9797

0 commit comments

Comments
 (0)