|
18 | 18 | #include "regs_addr.h"
|
19 | 19 | #include <silexpk/ec_curves.h>
|
20 | 20 | #include <silexpk/ik.h>
|
| 21 | +#ifdef CONFIG_CRACEN_HW_VERSION_LITE |
| 22 | +#include "hal/nrf_cracen.h" |
| 23 | +#endif |
21 | 24 |
|
22 | 25 | int cracen_prepare_ik_key(const uint8_t *user_data);
|
23 | 26 |
|
@@ -48,6 +51,16 @@ void sx_pk_run(sx_pk_req *req)
|
48 | 51 | if (sx_pk_is_ik_cmd(req)) {
|
49 | 52 | sx_pk_wrreg(&req->regs, IK_REG_PK_CONTROL,
|
50 | 53 | IK_PK_CONTROL_START_OP | IK_PK_CONTROL_CLEAR_IRQ);
|
| 54 | +#ifdef CONFIG_CRACEN_HW_VERSION_LITE |
| 55 | + /* Workaround to handle IKG freezing on CRACEN lite. |
| 56 | + * THE PKE-IKG interrupt can not be cleared from software, but can |
| 57 | + * be cleared by hardware when in PK mode. |
| 58 | + * So the interrupt is disabled after leaving PK mode and enabled when entering. |
| 59 | + */ |
| 60 | + if (req->cmd != SX_PK_CMD_IK_EXIT) { |
| 61 | + nrf_cracen_int_enable(NRF_CRACEN, CRACEN_INTENCLR_PKEIKG_Msk); |
| 62 | + } |
| 63 | +#endif |
51 | 64 | } else {
|
52 | 65 | sx_pk_wrreg(&req->regs, PK_REG_CONTROL,
|
53 | 66 | PK_RB_CONTROL_START_OP | PK_RB_CONTROL_CLEAR_IRQ);
|
@@ -75,11 +88,18 @@ int sx_pk_list_ik_inslots(sx_pk_req *req, unsigned int key, struct sx_pk_slot *i
|
75 | 88 | const struct sx_pk_capabilities *caps;
|
76 | 89 |
|
77 | 90 | if (req->cmd->cmdcode == PK_OP_IK_EXIT) {
|
| 91 | +#ifdef CONFIG_CRACEN_HW_VERSION_LITE |
| 92 | + /* Workaround to handle IKG freezing on CRACEN lite. |
| 93 | + * THE PKE-IKG interrupt can not be cleared from software, but can |
| 94 | + * be cleared by hardware when in PK mode. |
| 95 | + * so the interrupt is disabled after leaving PK mode and enabled when entering. |
| 96 | + */ |
| 97 | + nrf_cracen_int_disable(NRF_CRACEN, CRACEN_INTENCLR_PKEIKG_Msk); |
| 98 | +#endif |
78 | 99 | req->ik_mode = 0;
|
79 | 100 | } else {
|
80 | 101 | if (!req->ik_mode) {
|
81 | 102 | int status = cracen_prepare_ik_key((uint8_t *)&key);
|
82 |
| - |
83 | 103 | if (status != SX_OK) {
|
84 | 104 | sx_pk_release_req(req);
|
85 | 105 | return SX_ERR_INVALID_PARAM;
|
|
0 commit comments