@@ -161,8 +161,6 @@ static inline void wait_op_complete(void)
161
161
void curve25519Mul (uint32_t * r , const uint32_t * a , const uint32_t * b )
162
162
{
163
163
164
- mpi_enable_hardware_hw_op ();
165
-
166
164
uint32_t i ;
167
165
168
166
// Set mode register
@@ -214,8 +212,6 @@ void curve25519Mul(uint32_t *r, const uint32_t *a, const uint32_t *b)
214
212
r [i ] = DPORT_SEQUENCE_REG_READ (RSA_MEM_Z_BLOCK_BASE + i * 4 );
215
213
}
216
214
217
-
218
- mpi_disable_hardware_hw_op ();
219
215
}
220
216
221
217
void curve25519SetInt (uint32_t * a , uint32_t b )
@@ -652,6 +648,8 @@ int ed25519GeneratePublicKey(const uint8_t *privateKey, uint8_t *publicKey)
652
648
// the buffer as the little-endian integer, forming a secret scalar s
653
649
s = digest ;
654
650
651
+ mpi_enable_hardware_hw_op ();
652
+
655
653
// The lowest three bits of the first octet are cleared, the highest bit
656
654
// of the last octet is cleared, and the second highest bit of the last
657
655
// octet is set
@@ -665,6 +663,8 @@ int ed25519GeneratePublicKey(const uint8_t *privateKey, uint8_t *publicKey)
665
663
// The public key A is the encoding of the point s * B
666
664
ed25519Encode (& state -> sb , publicKey );
667
665
666
+ mpi_disable_hardware_hw_op ();
667
+
668
668
// Erase working state
669
669
memset (state , 0 , sizeof (Ed25519State ));
670
670
@@ -846,6 +846,8 @@ int ed25519GenerateSignatureEx(const uint8_t *privateKey,
846
846
// Construct the secret scalar s from the first half of the digest
847
847
memcpy (state -> s , digest , 32 );
848
848
849
+ mpi_enable_hardware_hw_op ();
850
+
849
851
// The lowest three bits of the first octet are cleared, the highest bit
850
852
// of the last octet is cleared, and the second highest bit of the last
851
853
// octet is set
@@ -946,6 +948,8 @@ int ed25519GenerateSignatureEx(const uint8_t *privateKey,
946
948
c = ed25519SubInt (state -> p , state -> s , ED25519_L , 32 );
947
949
ed25519SelectInt (signature + 32 , state -> p , state -> s , c , 32 );
948
950
951
+ mpi_disable_hardware_hw_op ();
952
+
949
953
// Erase working state
950
954
memset (state , 0 , sizeof (Ed25519State ));
951
955
0 commit comments