Skip to content

Commit

Permalink
Retrieve CIPHER_KEY_SIZE from C++ in Python generate_symmetric_key() (#…
Browse files Browse the repository at this point in the history
…146)

Fixes #139
  • Loading branch information
lvntky authored Jun 14, 2021
1 parent 112c4ff commit 9104af9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion python-package/mc2client/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def generate_keypair(expiration=10 * 365 * 24 * 60 * 60):
logger.info("Generated certificate and outputted to {}".format(cert_path))


def generate_symmetric_key(num_bytes=32):
def generate_symmetric_key():
"""
Generate a new symmetric key and save it path specified by user in config YAML passed to `set_config()`
Expand All @@ -591,6 +591,8 @@ def generate_symmetric_key(num_bytes=32):
num_bytes : int
Number of bytes for key
"""
num_bytes = _LIB.cipher_key_size()

if _CONF.get("general_config") is None:
raise MC2ClientConfigError("Configuration not set")

Expand Down
2 changes: 2 additions & 0 deletions src/c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,5 @@ extern "C" void opaque_decrypt_data(char **encrypted_files,
plaintext_file, key_file);
*result = status;
}

extern "C" size_t cipher_key_size() { return CIPHER_KEY_SIZE; }

0 comments on commit 9104af9

Please sign in to comment.