Skip to content

Commit 012d8ae

Browse files
committed
[sw,cryptolib] Update ECC random scalar gen function header
This commit updates the ECC random secret scalar generation function header. I checked the implementation for FIPS 186-5 compliance and updated the header comment accordingly. Signed-off-by: Hakim Filali <[email protected]>
1 parent 6d41f4b commit 012d8ae

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

sw/otbn/crypto/p256_base.s

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,10 +1611,10 @@ p256_base_mult:
16111611
*
16121612
* Returns t, a random value that is nonzero mod n, in shares.
16131613
*
1614-
* This follows a modified version of the method in FIPS 186-4 sections B.4.1
1615-
* and B.5.1 for generation of secret scalar values d and k. The computation
1616-
* in FIPS 186-4 is:
1617-
* seed = RBG(seedlen) // seedlen >= 320
1614+
* This follows a modified version of the method in FIPS 186-5 sections A.2.2
1615+
* and A.3.2 for generation of secret scalar values d and k. The computation
1616+
* in FIPS 186-5 is:
1617+
* seed = RBG(seedlen) // seedlen >= 256
16181618
* return (seed mod (n-1)) + 1
16191619
*
16201620
* The important features here are that (a) the seed is at least 64 bits longer
@@ -1924,7 +1924,7 @@ boolean_to_arithmetic:
19241924
* d = (d0 + d1) mod n
19251925
* ...where n is the curve order.
19261926
*
1927-
* This implementation follows FIPS 186-4 section B.4.1, where we
1927+
* This implementation follows FIPS 186-5 section A.2.2, where we
19281928
* generate d using N+64 random bits (320 bits in this case) as a seed. But
19291929
* while FIPS computes d = (seed mod (n-1)) + 1 to ensure a nonzero key, we
19301930
* instead just compute d = seed mod n. The caller MUST ensure that if this

sw/otbn/crypto/p384_keygen.s

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
*
1414
* Returns t, a random value that is nonzero mod n, in shares.
1515
*
16-
* This follows a modified version of the method in FIPS 186-4 sections B.4.1
17-
* and B.5.1 for generation of secret scalar values d and k. The computation
18-
* in FIPS 186-4 is:
19-
* seed = RBG(seedlen) // seedlen >= 448
16+
* This follows a modified version of the method in FIPS 186-5 sections A.2.2
17+
* and A.3.2 for generation of secret scalar values d and k. The computation
18+
* in FIPS 186-5 is:
19+
* seed = RBG(seedlen) // seedlen >= 384
2020
* return (seed mod (n-1)) + 1
2121
*
2222
* The important features here are that (a) the seed is at least 64 bits longer

0 commit comments

Comments
 (0)