def test_not_enabled(): # TODO: test broken as the compiled lib determines which algorithms are supported and enabled for alg_name in oqs.get_supported_sig_mechanisms(): if alg_name not in oqs.get_enabled_sig_mechanisms(): # found a non-enabled but supported alg try: sig = oqs.Signature(alg_name) raise AssertionError("oqs.MechanismNotEnabledError was not raised.") except oqs.MechanismNotEnabledError: pass except E: raise AssertionError("An unexpected exception was raised. " + E)
def test_wrong_public_key(): for alg_name in oqs.get_enabled_sig_mechanisms(): if any(item in alg_name for item in disabled_sig_patterns): continue yield check_wrong_public_key, alg_name
def test_correctness(): for alg_name in oqs.get_enabled_sig_mechanisms(): if any(item in alg_name for item in disabled_sig_patterns): continue yield check_correctness, alg_name
def test_wrong_public_key(): for alg_name in oqs.get_enabled_sig_mechanisms(): yield check_wrong_public_key, alg_name
def test_correctness(): for alg_name in oqs.get_enabled_sig_mechanisms(): yield check_correctness, alg_name
def test_wrong_signature(): for alg_name in oqs.get_enabled_sig_mechanisms(): yield check_wrong_signature, alg_name
# signature Python example from pprint import pprint import oqs ####################################################################### # signature example ####################################################################### sigs = oqs.get_enabled_sig_mechanisms() print("Enabled signature mechanisms:") pprint(sigs, compact="True") message = "This is the message to sign".encode() # create signer and verifier with default signature mechanisms sigalg = "DEFAULT" with oqs.Signature(sigalg) as signer: with oqs.Signature(sigalg) as verifier: print("\nSignature details:") pprint(signer.details) # signer generates its keypair signer_public_key = signer.generate_keypair() # optionally, the secret key can be obtained by calling export_secret_key() # and the signer can later be re-instantiated with the key pair: # secret_key = signer.export_secret_key() # store key pair, wait... (session resumption): # signer = oqs.Signature(sigalg, secret_key)
def test_wrong_message(): for alg_name in oqs.get_enabled_sig_mechanisms(): yield (check_wrong_message, alg_name)