CR50: configure SHA random stalls

This change configures the SHA engine to
a) enable random stalls at 12% during regular
operation through SHA API's, and b) enables
random stalls at 25% when doing key-ladder
operations.

TCG tests continue to complete in ~20 minutes
(i.e. no noticeable slowdown).

BRANCH=none
BUG=b:38315169
TEST=TCG tests pass

Change-Id: Id4b541cdd3d51c57979a93f71a6291cca8eb1844
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/508172
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
This commit is contained in:
nagendra modadugu
2017-05-17 12:19:30 -07:00
committed by chrome-bot
parent 6b170d85e7
commit a8cf9d9213
2 changed files with 21 additions and 0 deletions

View File

@@ -17,6 +17,20 @@ static void ladder_init(void)
* the other pending sha flow.
* Hence leave as is and observe the error.
*/
/* Enable random stalls for key-ladder usage. Note that
* the stall rate used for key-ladder operations is
* 25% (vs. 12% for generic SHA operations). This distinction
* is made so as to increase the difficulty in characterizng
* the key-ladder engine via random inputs provided over the
* generic SHA interface.
*/
/* Turn off random nops (which are enabled by default). */
GWRITE_FIELD(KEYMGR, SHA_RAND_STALL_CTL, STALL_EN, 0);
/* Configure random nop percentage at 25%. */
GWRITE_FIELD(KEYMGR, SHA_RAND_STALL_CTL, FREQ, 1);
/* Now turn on random nops. */
GWRITE_FIELD(KEYMGR, SHA_RAND_STALL_CTL, STALL_EN, 1);
}
static int ladder_step(uint32_t cert, const uint32_t input[8])

View File

@@ -147,6 +147,13 @@ void dcrypto_sha_init(enum sha_mode mode)
val |= GC_KEYMGR_SHA_CFG_EN_SHA1_MASK;
GREG32(KEYMGR, SHA_CFG_EN) = val;
/* Turn off random nops (which are enabled by default). */
GWRITE_FIELD(KEYMGR, SHA_RAND_STALL_CTL, STALL_EN, 0);
/* Configure random nop percentage at 12%. */
GWRITE_FIELD(KEYMGR, SHA_RAND_STALL_CTL, FREQ, 2);
/* Now turn on random nops. */
GWRITE_FIELD(KEYMGR, SHA_RAND_STALL_CTL, STALL_EN, 1);
/* Start SHA engine. */
GREG32(KEYMGR, SHA_TRIG) = GC_KEYMGR_SHA_TRIG_TRIG_GO_MASK;
}