Esempio n. 1
0
#####################################################

if operation == 0:
    print "You should use this script by passing an argument like:"
    print " $ python testvectors.py adder"
    print " $ python testvectors.py subractor"
    print " $ python testvectors.py multiplication"
    print " $ python testvectors.py exponentiation"
    print " $ python testvectors.py crtrsa"

#####################################################

if operation == 1:
    print "Test Vector for Multi Precision Adder\n"

    A = helpers.getRandomInt(514)
    B = helpers.getRandomInt(514)
    C = HW.MultiPrecisionAdd(A, B, "add")

    print "A                = ", hex(A)  # 514-bits
    print "B                = ", hex(B)  # 514-bits
    print "A + B            = ", hex(C)  # 515-bits

#####################################################

if operation == 2:
    print "Test Vector for Multi Precision Subtractor\n"

    A = helpers.getRandomInt(514)
    B = helpers.getRandomInt(514)
    C = HW.MultiPrecisionAdd(A, B, "subtract")
Esempio n. 2
0
    print " $ python testvectors.py subractor"
    print " $ python testvectors.py multiplication"
    print " $ python testvectors.py exponentiation"
    print " $ python testvectors.py rsa"
    print ""
    print "You can also set a seed for randomness to work"
    print "with the same testvectors at each execution:"
    print " $ python testvectors.py rsa 2017"
    print ""

#####################################################

if operation == 1:
    print "Test Vector for Multi Precision Adder\n"

    A = helpers.getRandomInt(1027)
    B = helpers.getRandomInt(1027)
    C = HW.MultiPrecisionAddSub_1027(A, B, "add")

    print "A                = ", hex(A)  # 1027-bits
    print "B                = ", hex(B)  # 1027-bits
    print "A + B            = ", hex(C)  # 1028-bits

#####################################################

if operation == 2:
    print "Test Vector for Multi Precision Subtractor\n"

    A = helpers.getRandomInt(1027)
    B = helpers.getRandomInt(1027)
    C = HW.MultiPrecisionAddSub_1027(A, B, "subtract")
    print " $ python testvectors.py subractor"
    print " $ python testvectors.py multiplication"
    print " $ python testvectors.py exponentiation"
    print " $ python testvectors.py crtrsa"
    print ""
    print "You can also set a seed for randomness to work"
    print "with the same testvectors at each execution:"
    print " $ python testvectors.py crtrsa 2017"
    print ""

#####################################################

if operation == 1:
    print "Test Vector for Multi Precision Adder\n"

    A = helpers.getRandomInt(514)
    B = helpers.getRandomInt(514)
    C = HW.MultiPrecisionAdd(A, B, "add")

    print "A                = ", hex(A)  # 514-bits
    print "B                = ", hex(B)  # 514-bits
    print "A + B            = ", hex(C)  # 515-bits

#####################################################

if operation == 2:
    print "Test Vector for Multi Precision Subtractor\n"

    A = helpers.getRandomInt(514)
    B = helpers.getRandomInt(514)
    C = HW.MultiPrecisionAdd(A, B, "subtract")