Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed May 17, 2015
1 parent 67f6ff4 commit 4377a4b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions django_crypto_fields/classes/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
class Keys(object):

def __init__(self):
"""Loads all keys defined in KEY_FILENAMES into KEYS.
If keys do not exist they will be created."""
self.loaded = False
self.rsa_key_info = {}
try:
Expand All @@ -24,7 +27,7 @@ def __init__(self):
self.load_keys()

def load_rsa_key(self, mode, key):
"""Loads an RSA key."""
"""Loads an RSA key into KEYS."""
key_file = KEY_FILENAMES['rsa'][mode][key]
with open(key_file, 'rb') as frsa:
rsa_key = RSA.importKey(frsa.read())
Expand All @@ -34,7 +37,7 @@ def load_rsa_key(self, mode, key):
return key_file

def load_aes_key(self, mode, key):
"""Decrypts and loads an AES key."""
"""Decrypts and loads an AES key into KEYS."""
rsa_key = KEYS['rsa'][mode]['private']
key_file = KEY_FILENAMES['aes'][mode]['private']
with open(key_file, 'rb') as faes:
Expand All @@ -43,7 +46,7 @@ def load_aes_key(self, mode, key):
return key_file

def load_salt_key(self, mode, key):
"""Decrypts and loads a salt key."""
"""Decrypts and loads a salt key into KEYS."""
rsa_key = KEYS['rsa'][mode]['private']
key_file = KEY_FILENAMES['salt'][mode]['private']
with open(key_file, 'rb') as fsalt:
Expand All @@ -52,6 +55,7 @@ def load_salt_key(self, mode, key):
return key_file

def load_keys(self):
"""Loads all keys defined in KEY_FILENAMES."""
sys.stdout.write('/* Loading keys ...\n')
for mode, keys in KEY_FILENAMES['rsa'].items():
for key in keys:
Expand Down

0 comments on commit 4377a4b

Please sign in to comment.