[Cryptech-Commits] [sw/libhal] 01/01: Add task_yield_maybe
git at cryptech.is
git at cryptech.is
Tue May 30 14:04:22 UTC 2017
This is an automated email from the git hooks/post-receive script.
paul at psgd.org pushed a commit to branch profiling
in repository sw/libhal.
commit c6543a796c8b560b06cb1d53fad9ffa3906df111
Author: Paul Selkirk <paul at psgd.org>
AuthorDate: Thu May 25 16:09:46 2017 -0400
Add task_yield_maybe
---
ecdsa.c | 1 +
hal_internal.h | 1 +
locks.c | 5 +++++
pbkdf2.c | 9 ++-------
4 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/ecdsa.c b/ecdsa.c
index 27c4c2e..b9b14d8 100644
--- a/ecdsa.c
+++ b/ecdsa.c
@@ -707,6 +707,7 @@ static hal_error_t point_scalar_multiply(const fp_int * const k,
point_double (M[1], M[1], curve);
point_add (M[bit], P, M[bit], curve);
+ hal_task_yield_maybe();
}
/*
diff --git a/hal_internal.h b/hal_internal.h
index 3aadb48..461feec 100644
--- a/hal_internal.h
+++ b/hal_internal.h
@@ -98,6 +98,7 @@ extern void hal_critical_section_end(void);
extern void hal_ks_lock(void);
extern void hal_ks_unlock(void);
extern void hal_task_yield(void);
+extern void hal_task_yield_maybe(void);
/*
* Thread sleep. Currently used only for bad-PIN delays.
diff --git a/locks.c b/locks.c
index 9b81769..72af43b 100644
--- a/locks.c
+++ b/locks.c
@@ -106,6 +106,11 @@ WEAK_FUNCTION void hal_task_yield(void)
return;
}
+WEAK_FUNCTION void hal_task_yield_maybe(void)
+{
+ return;
+}
+
/*
* Local variables:
* indent-tabs-mode: nil
diff --git a/pbkdf2.c b/pbkdf2.c
index 690831f..aa30bb5 100644
--- a/pbkdf2.c
+++ b/pbkdf2.c
@@ -108,13 +108,6 @@ hal_error_t hal_pbkdf2(hal_core_t *core,
memset(result, 0, sizeof(result));
memset(mac, 0, sizeof(mac));
-#if 1
- /* HACK - find the second sha256 core, to avoid interfering with rpc.
- */
- core = hal_core_find(descriptor->core_name, NULL);
- core = hal_core_find(descriptor->core_name, core);
-#endif
-
/*
* We probably should check here to see whether the password is
* longer than the HMAC block size, and, if so, we should hash the
@@ -148,6 +141,8 @@ hal_error_t hal_pbkdf2(hal_core_t *core,
for (iteration = 2; iteration <= iterations_desired; iteration++) {
+ hal_task_yield_maybe();
+
if ((err = do_hmac(core, descriptor, password, password_length,
mac, descriptor->digest_length,
0, mac, sizeof(mac))) != HAL_OK)
More information about the Commits
mailing list