@@ -39,8 +39,6 @@ OTBN_DECLARE_SYMBOL_ADDR(run_curve25519,
3939 ed25519_r0 ); // 640-bit first share of r.
4040OTBN_DECLARE_SYMBOL_ADDR (run_curve25519 ,
4141 ed25519_r1 ); // 640-bit second share of r.
42- OTBN_DECLARE_SYMBOL_ADDR (run_curve25519 ,
43- x25519_private_key ); // X25519 private key.
4442OTBN_DECLARE_SYMBOL_ADDR (run_curve25519 ,
4543 x25519_public_key ); // X25519 public key.
4644OTBN_DECLARE_SYMBOL_ADDR (run_curve25519 ,
6260 /*
6361 * The expected instruction counts for constant time functions.
6462 */
65- kModeKeygenInsCnt = 339495 ,
66- kModeSignStage1InsCnt = 679051 ,
63+ kModeKeygenInsCnt = 342109 ,
64+ kModeSignStage1InsCnt = 684279 ,
6765 kModeSignStage2InsCnt = 655 ,
6866};
6967
@@ -299,7 +297,8 @@ status_t curve25519_verify_finalize(hardened_bool_t *result) {
299297}
300298
301299status_t curve25519_x25519_start (
302- const uint32_t private_key [kCurve25519ScalarWords ],
300+ const uint32_t s0 [kCurve25519ScalarWords ],
301+ const uint32_t s1 [kCurve25519ScalarWords ],
303302 const uint32_t public_key [kCurve25519PointWords ]) {
304303 // Load the Curve25519 app. Fails if OTBN is non-idle.
305304 const otbn_app_t kOtbnAppCurve25519 = OTBN_APP_T_INIT (run_curve25519 );
@@ -310,11 +309,11 @@ status_t curve25519_x25519_start(
310309 const otbn_addr_t kOtbnVarMode = OTBN_ADDR_T_INIT (run_curve25519 , mode );
311310 HARDENED_TRY (otbn_dmem_write (kCurve25519ModeWords , & mode , kOtbnVarMode ));
312311
313- // Write the private key to DMEM.
314- const otbn_addr_t kOtbnVarX25519PrivateKey =
315- OTBN_ADDR_T_INIT (run_curve25519 , x25519_private_key );
316- HARDENED_TRY (otbn_dmem_write (kCurve25519ScalarWords , private_key ,
317- kOtbnVarX25519PrivateKey ));
312+ // Write the private key arithmetic shares to DMEM.
313+ const otbn_addr_t kOtbnVarS0 = OTBN_ADDR_T_INIT ( run_curve25519 , ed25519_s0 );
314+ const otbn_addr_t kOtbnVarS1 = OTBN_ADDR_T_INIT (run_curve25519 , ed25519_s1 );
315+ HARDENED_TRY (otbn_dmem_write (kCurve25519ScalarWords , s0 , kOtbnVarS0 ));
316+ HARDENED_TRY ( otbn_dmem_write ( kCurve25519ScalarWords , s1 , kOtbnVarS1 ));
318317
319318 // Write the public key to DMEM.
320319 const otbn_addr_t kOtbnVarX25519PublicKey =
@@ -386,7 +385,8 @@ status_t curve25519_x25519_finalize(
386385}
387386
388387status_t curve25519_x25519_keygen_start (
389- const uint32_t private_key [kCurve25519ScalarWords ]) {
388+ const uint32_t s0 [kCurve25519ScalarWords ],
389+ const uint32_t s1 [kCurve25519ScalarWords ]) {
390390 // Load the Curve25519 app. Fails if OTBN is non-idle.
391391 const otbn_app_t kOtbnAppCurve25519 = OTBN_APP_T_INIT (run_curve25519 );
392392 HARDENED_TRY (otbn_load_app (kOtbnAppCurve25519 ));
@@ -396,11 +396,11 @@ status_t curve25519_x25519_keygen_start(
396396 const otbn_addr_t kOtbnVarMode = OTBN_ADDR_T_INIT (run_curve25519 , mode );
397397 HARDENED_TRY (otbn_dmem_write (kCurve25519ModeWords , & mode , kOtbnVarMode ));
398398
399- // Write the private key to DMEM.
400- const otbn_addr_t kOtbnVarX25519PrivateKey =
401- OTBN_ADDR_T_INIT (run_curve25519 , x25519_private_key );
402- HARDENED_TRY (otbn_dmem_write (kCurve25519ScalarWords , private_key ,
403- kOtbnVarX25519PrivateKey ));
399+ // Write the private key arithmetic shares to DMEM.
400+ const otbn_addr_t kOtbnVarS0 = OTBN_ADDR_T_INIT ( run_curve25519 , ed25519_s0 );
401+ const otbn_addr_t kOtbnVarS1 = OTBN_ADDR_T_INIT (run_curve25519 , ed25519_s1 );
402+ HARDENED_TRY (otbn_dmem_write (kCurve25519ScalarWords , s0 , kOtbnVarS0 ));
403+ HARDENED_TRY ( otbn_dmem_write ( kCurve25519ScalarWords , s1 , kOtbnVarS1 ));
404404
405405 // Start the OTBN routine.
406406 return otbn_execute ();
0 commit comments