Skip to content

Commit 9ba5d42

Browse files
sasdfnasahlpa
authored andcommitted
[otbn,cov] Add p256 key generation sim test
Change-Id: I2b94c1ae73076d07c134ddbcee45178281ab0c50 Signed-off-by: Yi-Hsuan Deng <[email protected]>
1 parent eb31951 commit 9ba5d42

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

sw/otbn/crypto/tests/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ otbn_sim_test_suite(
395395
"p256_check_public_key_x_too_large.hjson",
396396
"p256_check_public_key_y_too_large.hjson",
397397
"p256_isoncurve_valid.hjson",
398+
"p256_keygen_valid.hjson",
398399
],
399400
)
400401

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright lowRISC contributors (OpenTitan project).
2+
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
// SPDX-License-Identifier: Apache-2.0
4+
{
5+
/**
6+
* @param[out] dmem[d0]: First share of secret key.
7+
* @param[out] dmem[d1]: Second share of secret key.
8+
* @param[out] dmem[x]: Public key x-coordinate.
9+
* @param[out] dmem[y]: Public key y-coordinate.
10+
*/
11+
12+
"input": {
13+
"dmem": {
14+
"mode": "0x000005c5" # MODE_KEYGEN
15+
}
16+
}
17+
"output": {
18+
"dmem": {
19+
# Verified that (x, y) == (d0 + d1) * G
20+
"x": "0xbc17c155181376b3197b131eac726c220cdf7ab4ad947226393afc1d82372b5e"
21+
"y": "0xf00fa582f6dc92f3d9016563addf53be343e2ddf13d61a60148a10823b363b0c"
22+
23+
# BUG: the upper 64 bits are cleared incorrectly in p256_random_scalar.
24+
# bn.rshi w16, w20, w31 >> 192
25+
#
26+
# This bug is runtime-patched by ROM_EXT (PR #27679).
27+
"d0":
28+
'''
29+
0x0000000000000000000000000000000000000000000000000000000000000000
30+
cad51b98eeb2713c8b67bf9e1701f3fac2d04d8ecf8d2a5b69240a89b4dae4e1
31+
'''
32+
33+
"d1":
34+
'''
35+
0x0000000000000000000000000000000000000000000000009bac529d8188e972
36+
167bff297e742904961ff21ed1bc0dcde57b792d508dd4768ae99c4d870e512b
37+
'''
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)