Skip to content

Commit

Permalink
Trial with cryptomath library.
Browse files Browse the repository at this point in the history
  • Loading branch information
calonso88 committed Apr 14, 2024
1 parent 980def8 commit 4fc484f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SPDX-FileCopyrightText: © 2023 Uri Shaked <[email protected]>
# SPDX-License-Identifier: MIT
import random
import cryptomath

import cocotb
from cocotb.clock import Clock
Expand Down Expand Up @@ -308,8 +309,10 @@ async def test_spi(dut):

while True:
e = random.randint(min_prime, phi_m)
e_is_prime = is_prime(e)
if ( ( e < phi_m ) and ( e_is_prime == 1 ) ):
#e_is_prime = is_prime(e)
#if ( ( e < phi_m ) and ( e_is_prime == 1 ) ):
# break
if (cryptomath.gcd(e, phi_m) == 1):
break

# DEBUG
Expand All @@ -321,7 +324,8 @@ async def test_spi(dut):
# DEBUG

#d = invmod(e, phi_m) -> d*e == 1 mod phi_m
d = pow(e, -1, phi_m)
#d = pow(e, -1, phi_m)
d = cryptomath.findModInverse(e, phi_m)

# Number of bits for RSA implementation
hwbits = bits + 2
Expand Down

0 comments on commit 4fc484f

Please sign in to comment.