You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
from cryptosystem_core import *
|
|
|
|
def main(): #comment "return" for testing
|
|
core = McEliece_core()
|
|
n, k = core.get_config()
|
|
print(n, k)
|
|
core.change_config(5, 3) #check comments in class implementation to understand possible values
|
|
n, k = core.get_config()
|
|
print(n, k)
|
|
print()
|
|
core.generate_keys() #true random
|
|
print(core.get_pubkey())
|
|
print(core.get_privkey_S())
|
|
print(core.get_privkey_p())
|
|
print()
|
|
core.generate_keys(sum([ord(i) for i in list("password")])) #very simple seed
|
|
G = core.get_pubkey()
|
|
S = core.get_privkey_S()
|
|
p = core.get_privkey_p()
|
|
print(G)
|
|
print(S)
|
|
print(p)
|
|
print()
|
|
core.change_config(5, 3) #unset all keys inside core
|
|
core.set_privkey_S(S)
|
|
core.set_privkey_p(p)
|
|
core.restore_pubkey()
|
|
print(core.get_pubkey() == G)
|
|
core.change_config(5, 3) #unset all keys inside core
|
|
core.set_pubkey(G)
|
|
core.set_privkey_p(p)
|
|
core.restore_privkey_S()
|
|
print(core.get_privkey_S() == S)
|
|
core.change_config(5, 3) #unset all keys inside core
|
|
core.set_pubkey(G)
|
|
core.set_privkey_S(S)
|
|
core.restore_privkey_p()
|
|
print(core.get_privkey_p() == p)
|
|
print()
|
|
for j in range(2):
|
|
text = [i + 1 for i in range(5)]
|
|
msg = core.encrypt(text)
|
|
print(msg)
|
|
text = core.decrypt(msg)
|
|
print(text)
|
|
print()
|
|
print("All tests are finished!")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|