Changeset - c1e15819a020
[Not reviewed]
0 2 0
Branko Majic (branko) - 4 years ago 2020-07-13 13:29:11
branko@majic.rs
GC-37: Drop the deprecated/unused generate_private_key function.
2 files changed with 0 insertions and 26 deletions:
0 comments (0 inline, 0 general)
gimmecert/crypto.py
Show inline comments
 
@@ -94,32 +94,12 @@ class KeyGenerator:
 
                backend=cryptography.hazmat.backends.default_backend()
 
            )
 

	
 
        return private_key
 

	
 

	
 
def generate_private_key():
 
    """
 
    Generates a 2048-bit RSA private key.
 

	
 
    :returns: RSA private key.
 
    :rtype: cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey
 
    """
 

	
 
    rsa_public_exponent = 65537
 
    key_size = 2048
 

	
 
    private_key = cryptography.hazmat.primitives.asymmetric.rsa.generate_private_key(
 
        public_exponent=rsa_public_exponent,
 
        key_size=key_size,
 
        backend=cryptography.hazmat.backends.default_backend()
 
    )
 

	
 
    return private_key
 

	
 

	
 
def get_dn(name):
 
    """
 
    Generates a DN (distinguished name) using the passed-in name. The
 
    resulting DN will consist out of a single CN field, whose value
 
    will be set to the passed-in name. For example, if you pass-in
 
    name "My Name", the resulting DN will be "CN=My Name".
tests/test_crypto.py
Show inline comments
 
@@ -29,18 +29,12 @@ from dateutil.relativedelta import relativedelta
 
import gimmecert.crypto
 

	
 
import pytest
 
from freezegun import freeze_time
 

	
 

	
 
def test_generate_private_key_returns_private_key():
 
    private_key = gimmecert.crypto.generate_private_key()
 

	
 
    assert isinstance(private_key, cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey)
 

	
 

	
 
def test_get_dn():
 
    dn = gimmecert.crypto.get_dn('My test')
 
    assert isinstance(dn, cryptography.x509.Name)
 
    assert len(dn) == 1
 
    assert isinstance(list(dn)[0], cryptography.x509.NameAttribute)
 
    assert list(dn)[0].oid == cryptography.x509.oid.NameOID.COMMON_NAME
0 comments (0 inline, 0 general)