Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special yield() variant for thunk'ed functions #19

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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