diff --git a/README.rst b/README.rst index 5a91dff..3e6d959 100644 --- a/README.rst +++ b/README.rst @@ -41,6 +41,7 @@ Usage # encrypt_with_keys and decrypt_with keys functions encryption_salt = '...' # 8 random bytes + hmac_salt = '...' # 8 random bytes encryption_key = rncryptor.make_key(password, encryption_salt) hmac_key = rncryptor.make_key(password, hmac_salt) encrypted_data = rncryptor.encrypt_with_keys(data, hmac_key, encryption_key) diff --git a/rncryptor.py b/rncryptor.py index 83d6bea..664e164 100644 --- a/rncryptor.py +++ b/rncryptor.py @@ -113,12 +113,12 @@ def decrypt(self, data, password): # data doesn't even match the required header + hmac length raise DecryptionError("Invalid length") - version = data[0] + version = data[:1] if not version == b'\x03': # required version is version 3 raise DecryptionError("Unsupported version") - options = data[1] + options = data[1:2] if not options == b'\x01': # when using keys options should be `0` @@ -153,13 +153,13 @@ def decrypt_with_keys(self, data, hmac_key, encryption_key): # data doesn't even match the required header + hmac length raise DecryptionError("Invalid length") - version = data[0] + version = data[:1] if not version == b'\x03': # required version is version 3 raise DecryptionError("Unsupported version") - options = data[1] + options = data[1:2] if not options == b'\x00': # when using keys options should be `0`