Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tiny functions added/implemented ( #139 ) #146

Merged
merged 5 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions 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,7 @@ def generate_symmetric_key(num_bytes=32):
num_bytes : int
Number of bytes for key
"""

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

Expand All @@ -603,7 +604,7 @@ def generate_symmetric_key(num_bytes=32):
)
return

key = AESGCM.generate_key(bit_length=num_bytes * 8)
key = AESGCM.generate_key(bit_length= _LIB.cipher_key_size() * 8)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please create a variable num_bytes and set it to _LIB.cipher_key_size() for clarity? This will add one more line but should make things easier to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of course I'm doing it right now

with open(symmetric_key_path, "wb") as symm_key:
symm_key.write(key)

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}