Skip to content

Commit 634592a

Browse files
committed
Special yield() variant for thunked functions
cont_suspend() wants stack pointer to be within cont.stack and panic()s otherwise esp8266/Arduino#9170 (comment) stack_thunk_yield() func then gets added from the Core side, which should do 'SP store -> yield() -> SP restore' with known stack thunk values esp8266/Arduino@master...mcspr:esp8266-Arduino:bssl/9170-thunk
1 parent b024386 commit 634592a

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

src/ec/ec_prime_i15.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ run_code(jacobian *P1, const jacobian *P2,
465465
memcpy(t[P1x], P1->c, 3 * I15_LEN * sizeof(uint16_t));
466466
memcpy(t[P2x], P2->c, 3 * I15_LEN * sizeof(uint16_t));
467467

468-
optimistic_yield(10000);
468+
stack_thunk_yield();
469469

470470
/*
471471
* Run formulas.

src/ec/ec_prime_i31.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ run_code(jacobian *P1, const jacobian *P2,
464464
memcpy(t[P1x], P1->c, 3 * I31_LEN * sizeof(uint32_t));
465465
memcpy(t[P2x], P2->c, 3 * I31_LEN * sizeof(uint32_t));
466466

467-
optimistic_yield(10000);
467+
stack_thunk_yield();
468468

469469
/*
470470
* Run formulas.

src/inner.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -2595,13 +2595,13 @@ br_cpuid(uint32_t mask_eax, uint32_t mask_ebx,
25952595
#endif
25962596

25972597
#define _debugBearSSL (0)
2598-
extern void optimistic_yield(uint32_t);
2598+
extern void stack_thunk_yield();
25992599
#ifdef __cplusplus
26002600
}
26012601
#endif
26022602

26032603
#else
2604-
#define optimistic_yield(ignored)
2604+
#define stack_thunk_yield()
26052605
#endif
26062606

26072607

src/rsa/rsa_i15_priv.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ br_rsa_i15_private(unsigned char *x, const br_rsa_private_key *sk)
141141
mp = mq + 2 * fwlen;
142142
memmove(mp, t1, fwlen * sizeof *t1);
143143

144-
optimistic_yield(10000);
144+
stack_thunk_yield();
145145

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

155-
optimistic_yield(10000);
155+
stack_thunk_yield();
156156

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

187-
optimistic_yield(10000);
187+
stack_thunk_yield();
188188

189189
/*
190190
* h is now in t2. We compute the final result:

src/rsa/rsa_i31_priv.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ br_rsa_i31_private(unsigned char *x, const br_rsa_private_key *sk)
135135
mp = mq + 2 * fwlen;
136136
memmove(mp, t1, fwlen * sizeof *t1);
137137

138-
optimistic_yield(10000);
138+
stack_thunk_yield();
139139

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

149-
optimistic_yield(10000);
149+
stack_thunk_yield();
150150

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

181-
optimistic_yield(10000);
181+
stack_thunk_yield();
182182

183183
/*
184184
* h is now in t2. We compute the final result:

0 commit comments

Comments
 (0)