예제 #1
0
 def ee0_key(self, version):
     if version < TLSVersion.TLSv1_1:
         ee0_key = RSA()
     else:
         ee0_key = ECC()
     ee0_key.generate()
     return ee0_key
예제 #2
0
 def ca1_key(self, version):
     if version < TLSVersion.TLSv1_1:
         ca1_key = RSA()
     else:
         ca1_key = ECC()
     ca1_key.generate()
     return ca1_key
예제 #3
0
def make_crt(
    issuer_crt,
    issuer_key,
    subject=None,
    not_before=None,
    not_after=None,
    serial_number=None,
    basic_constraints=None,
    digestmod=None,
):
    if subject is None:
        subject = "OU=test, CN=hostname"
    if not_before is None:
        not_before = issuer_crt.not_before
    if not_after is None:
        not_after = issuer_crt.not_after
    if serial_number is None:
        serial_number = 0x123456
    if basic_constraints is None:
        basic_constraints = BasicConstraints()
    if digestmod is None:
        # TODO: issuer_crt.digestmod should work but doesn't.
        digestmod = hashlib.sha256

    key = RSA()
    key.generate()
    crt = issuer_crt.sign(
        csr=CSR.new(key, subject, digestmod()),
        issuer_key=issuer_key,
        not_before=not_before,
        not_after=not_after,
        serial_number=serial_number,
        basic_constraints=basic_constraints,
    )
    return crt, key
예제 #4
0
def make_root_ca(
    subject=None,
    not_before=None,
    not_after=None,
    serial_number=None,
    basic_constraints=None,
    digestmod=None,
):
    if subject is None:
        subject = "OU=test, CN=Trusted CA"
    if not_before is None:
        not_before = dt.datetime.utcnow()
    if not_after is None:
        not_after = not_before + dt.timedelta(days=90)
    if serial_number is None:
        serial_number = 0x123456
    if basic_constraints is None:
        basic_constraints = BasicConstraints(True, -1)
    if digestmod is None:
        digestmod = hashlib.sha256

    key = RSA()
    key.generate()
    crt = CRT.selfsign(
        csr=CSR.new(key, subject, digestmod()),
        issuer_key=key,
        not_before=not_before,
        not_after=not_after,
        serial_number=serial_number,
        basic_constraints=basic_constraints,
    )
    return crt, key
예제 #5
0
def subject_key():
    subject_key = RSA()
    subject_key.generate(key_size=1024)
    return subject_key
예제 #6
0
def issuer_key():
    issuer_key = RSA()
    issuer_key.generate(key_size=1024)
    return issuer_key
예제 #7
0
 def ca0_key(self):
     ca0_key = RSA()
     ca0_key.generate()
     return ca0_key
 def ee0_key(self):
     ee0_key = RSA()
     ee0_key.generate()
     return ee0_key