API Reference¶
Reference implementation of the Gemina specification.
For more details see the section Description.
The initialization vector for CBC, the keys, and the salt for HMAC
are created with os.urandom()
.
The key
argument for the functions encrypt_with_key()
,
decrypt_with_key()
, and verify_with_key()
should be created
with create_secret_key()
.
Overview¶
Raised if data could not be decrypted. |
|
Version enum. |
|
Create a secret key. |
|
Decrypt data using a secret key. |
|
Decrypt data using a password. |
|
Encrypt data using a secret key. |
|
Encrypt data using a password. |
|
Verify the encrypted data. |
|
Verify the encrypted data. |
- class gemina.Version(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Version enum.
- V1 = b'\x8a'¶
version 1
- V2 = b'\x8b'¶
version 2
- V3 = b'\x8c'¶
version 3
- V4 = b'\x8d'¶
version 4
- V5 = b'\x8e'¶
version 5
- gemina.create_secret_key(*, version=<Version.V1>)[source]¶
Create a secret key.
It can be used with the functions
encrypt_with_key()
,decrypt_with_key()
, andverify_with_key()
.- Returns:
secret key
- Return type:
- gemina.decrypt_with_key(key, data)[source]¶
Decrypt data using a secret key.
The data must have been encrypted with
encrypt_with_key()
.- Parameters:
- Returns:
decrypted data
- Return type:
- Raises:
TypeError – if
key
ordata
are notbytes
ValueError – if size of
key
is not correctDecryptError – if data could not be decrypted
- gemina.decrypt_with_password(password, data)[source]¶
Decrypt data using a password.
The data must have been encrypted with
encrypt_with_password()
.- Parameters:
- Returns:
decrypted data
- Return type:
- Raises:
TypeError – if
password
ordata
are notbytes
DecryptError – if data could not be decrypted
- gemina.encrypt_with_key(key, data, *, version=<Version.V1>)[source]¶
Encrypt data using a secret key.
- Parameters:
- Returns:
encrypted data
- Return type:
- Raises:
TypeError – if
key
ordata
are notbytes
ValueError – if size of
key
is not correct
- gemina.encrypt_with_password(password, data, *, version=<Version.V1>)[source]¶
Encrypt data using a password.
The data will be encrypted with a key derived from the password and signed.
- gemina.verify_with_key(key, data)[source]¶
Verify the encrypted data.
This function verifies the authenticity and the integrity of the data with the given key. This is also done during decryption.
The data must have been encrypted with
encrypt_with_key()
.- Parameters:
- Returns:
True
if secret key, authenticity and integrity are okay- Return type:
- Raises:
TypeError – if
key
ordata
are notbytes
ValueError – if size of
key
is not correct
- gemina.verify_with_password(password, data)[source]¶
Verify the encrypted data.
This function verifies the authenticity and the integrity of the data with the key derived from the password. This is also done during decryption.
The data must have been encrypted with
encrypt_with_password()
.