コード例 #1
0
ファイル: main.py プロジェクト: MG2033/Security_DS_Project
q = generate_safe_prime(NBYTES * BYTES_TO_BITS)
a = random.randint(2, q - 1)

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

# Alice Keys
x_a = random.randint(2, q - 1)
y_a = pow(a, x_a, q)
id_a = random.randint(1, MAX_ID)

d_a, e_a, n = rsa.generate_key_pair()

print("Alice Certificate...")
print(
    ca.generate_x509_certificate("Alice", id_a, "Alice_Sub", [a, q, n],
                                 [y_a, e_a], datetime.now(),
                                 datetime.now() + timedelta(365)), "\n")

# Alice RSA Keys
########################################################################################################################
# Bob Keys
x_b = random.randint(2, q - 1)
y_b = pow(a, x_b, q)
id_b = random.randint(1, MAX_ID)

d_b, e_b, n = rsa.generate_key_pair()

z, r = ca.generate_x509_certificate("Bob", id_b, "Bob_Sub", [a, q, n],
                                    [y_b, e_b], datetime.now(),
                                    datetime.now() + timedelta(365))
print("Bob Certificate...")