示例#1
0
def test_GenerateKey():

    for x in range(10):
        # Generate a random string of fixed length
        String = randomString(10)

        # Generate a key from random generated nonce value
        actual_value = Nakasendo.SymEncDec(String)
        actual_value.GenerateKey()
        actual_value = actual_value.GetKey()

        # verifying the actual value with the expected value
        assert len(actual_value) == 64, "Test failed"
示例#2
0
def test_EncodeDecodeAES(test_data_dir):

    for x in range(10):
        # Generate a random string of fixed length as secret code
        secretCode = randomString(100)

        # Generate a random string of fixed length
        String = randomString(10)

        # Generate a key from random generated nonce value
        keyAsHex = Nakasendo.SymEncDec(String)
        keyAsHex.GenerateKey()

        # verifying the length of generated key as 64
        assert len(keyAsHex.GetKey()) == 64, "Test failed"

        # Encoding the secret code using AES encryption
        encode_value = keyAsHex.Encode(secretCode)

        # Decoding the secret code using AES encryption
        decode_value = keyAsHex.Decode(encode_value)

        # Verifying decode value same as secret code
        assert decode_value == secretCode, "Test failed"
示例#3
0
        "Creating a point on a curve with ID - 704 ... I don;t like this as it requires users to know the ID of the curve"
    )
    ECPointOnScep112r1_a = Nakasendo.ECPoint(704)
    ECPointOnScep112r1_b = Nakasendo.ECPoint(704)

    print("ECPointOnScep112r1_a: %s\nECPointOnScep112r1_b %s\n" %
          (ECPointOnScep112r1_a, ECPointOnScep112r1_b))
    ECPointOnScep112r1_sum = ECPointOnScep112r1_a + ECPointOnScep112r1_b
    print("Result of addtion on a curve with ID - 704: %s " %
          ECPointOnScep112r1_sum)

    print("Check if its on the curve")

    print("Check Encoding/Decoding/Key creation")
    password = '******'
    encoder = Nakasendo.SymEncDec(password)
    print("Contents: %s" % encoder)
    encoder.GenerateKey()
    print("Contents: %s" % encoder)

    msgToEncode = 'the quick brown fox jumped over the lazy dog'
    encodedAsHex = encoder.Encode(msgToEncode)
    print("EncodedMsgAsHex: %s" % encodedAsHex)

    decoded = encoder.Decode(encodedAsHex)
    print("Decoded Message %s" % decoded)

    print("Testing Base64..Encoding")
    msgToEncode = 'Development team'
    for x in range(1, 10):
        myMsgHash = Nakasendo.MessageHash(msgToEncode)