Skip to content

Commit

Permalink
Merge pull request #19 from mcspr/fix/thunk-yield
Browse files Browse the repository at this point in the history
Special yield() variant for thunk'ed functions
  • Loading branch information
earlephilhower authored Aug 8, 2024
2 parents b024386 + 6cd56b5 commit f08b38b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/ec/ec_prime_i15.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ run_code(jacobian *P1, const jacobian *P2,
memcpy(t[P1x], P1->c, 3 * I15_LEN * sizeof(uint16_t));
memcpy(t[P2x], P2->c, 3 * I15_LEN * sizeof(uint16_t));

optimistic_yield(10000);
stack_thunk_yield();

/*
* Run formulas.
Expand Down
2 changes: 1 addition & 1 deletion src/ec/ec_prime_i31.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ run_code(jacobian *P1, const jacobian *P2,
memcpy(t[P1x], P1->c, 3 * I31_LEN * sizeof(uint32_t));
memcpy(t[P2x], P2->c, 3 * I31_LEN * sizeof(uint32_t));

optimistic_yield(10000);
stack_thunk_yield();

/*
* Run formulas.
Expand Down
4 changes: 2 additions & 2 deletions src/inner.h
Original file line number Diff line number Diff line change
Expand Up @@ -2595,13 +2595,13 @@ br_cpuid(uint32_t mask_eax, uint32_t mask_ebx,
#endif

#define _debugBearSSL (0)
extern void optimistic_yield(uint32_t);
extern void stack_thunk_yield(void);
#ifdef __cplusplus
}
#endif

#else
#define optimistic_yield(ignored)
#define stack_thunk_yield()
#endif


Expand Down
6 changes: 3 additions & 3 deletions src/rsa/rsa_i15_priv.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ br_rsa_i15_private(unsigned char *x, const br_rsa_private_key *sk)
mp = mq + 2 * fwlen;
memmove(mp, t1, fwlen * sizeof *t1);

optimistic_yield(10000);
stack_thunk_yield();

/*
* Compute s2 = x^dq mod q.
Expand All @@ -152,7 +152,7 @@ br_rsa_i15_private(unsigned char *x, const br_rsa_private_key *sk)
r &= br_i15_modpow_opt(s2, sk->dq, sk->dqlen, mq, q0i,
mq + 3 * fwlen, TLEN - 3 * fwlen);

optimistic_yield(10000);
stack_thunk_yield();

/*
* Compute s1 = x^dq mod q.
Expand Down Expand Up @@ -184,7 +184,7 @@ br_rsa_i15_private(unsigned char *x, const br_rsa_private_key *sk)
br_i15_decode_reduce(t1, sk->iq, sk->iqlen, mp);
br_i15_montymul(t2, s1, t1, mp, p0i);

optimistic_yield(10000);
stack_thunk_yield();

/*
* h is now in t2. We compute the final result:
Expand Down
6 changes: 3 additions & 3 deletions src/rsa/rsa_i31_priv.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ br_rsa_i31_private(unsigned char *x, const br_rsa_private_key *sk)
mp = mq + 2 * fwlen;
memmove(mp, t1, fwlen * sizeof *t1);

optimistic_yield(10000);
stack_thunk_yield();

/*
* Compute s2 = x^dq mod q.
Expand All @@ -146,7 +146,7 @@ br_rsa_i31_private(unsigned char *x, const br_rsa_private_key *sk)
r &= br_i31_modpow_opt(s2, sk->dq, sk->dqlen, mq, q0i,
mq + 3 * fwlen, TLEN - 3 * fwlen);

optimistic_yield(10000);
stack_thunk_yield();

/*
* Compute s1 = x^dp mod p.
Expand Down Expand Up @@ -178,7 +178,7 @@ br_rsa_i31_private(unsigned char *x, const br_rsa_private_key *sk)
br_i31_decode_reduce(t1, sk->iq, sk->iqlen, mp);
br_i31_montymul(t2, s1, t1, mp, p0i);

optimistic_yield(10000);
stack_thunk_yield();

/*
* h is now in t2. We compute the final result:
Expand Down

0 comments on commit f08b38b

Please sign in to comment.