-
Notifications
You must be signed in to change notification settings - Fork 143
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
Secure Cell passphrase API: PyThemis #596
Commits on Feb 28, 2020
-
SCell passphrase API in PyThemis
Add support for passphrase API by extending SCellSeal construction API. It is possible to add via Python's __new__ special method which may return an instance of a diffrent class (typically, more appropriate subclass). We introduce a SCellSealPassphrase subclass with the same API but different implementation of "encrypt" and "decrypt" methods. To make things easier we also add a SecureCellError to provide more contexts in exceptions without making error messages too long. Initially a different syntax was planned: SCellSeal.with_passphrase('a secret') SCellSeal.with_key(binary_master_key) It had a noble idea of maintaining similarity with other languages which do not have named arguments. However, after updating tests and examples this syntax came off as unnatural and non-Pythonic.
Configuration menu - View commit details
-
Copy full SHA for add0916 - Browse repository at this point
Copy the full SHA add0916View commit details -
Those are mostly straighforward. Also, update existing tests for master key API and ensure that positional arguments to Secure Cell constuctors are interpreted as keys, not passphrases. Another change is update of tests to use a proper master key instead of a fixed password with master key API.
Configuration menu - View commit details
-
Copy full SHA for 324d69f - Browse repository at this point
Copy the full SHA 324d69fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7398539 - Browse repository at this point
Copy the full SHA 7398539View commit details -
Update Secure Cell code examples
The main showcase has been reworked completely to demonstrate API. Other examples got cosmetic updates to avoid using 'passwords' when in fact they work with master keys.
Configuration menu - View commit details
-
Copy full SHA for ef61241 - Browse repository at this point
Copy the full SHA ef61241View commit details -
Configuration menu - View commit details
-
Copy full SHA for ab64a4f - Browse repository at this point
Copy the full SHA ab64a4fView commit details -
Optional "encoding=" argument for passphrases
Instead of forcing the users to do '.encode(...)' calls themselves, adhere to standard Python practice of accepting an "encoding" argument with specified default encoding.
Configuration menu - View commit details
-
Copy full SHA for 90c0299 - Browse repository at this point
Copy the full SHA 90c0299View commit details -
Use "six" library for Python 2/3 compatibility
Instead of writing type hacks, use a compatibility library. This should make it easier to convert PyThemis into Python 3-only when we decide to drop Python 2 compatibility. We will need to replace all "six" calls with native equivalents.
Configuration menu - View commit details
-
Copy full SHA for fb59724 - Browse repository at this point
Copy the full SHA fb59724View commit details
Commits on Mar 2, 2020
-
Configuration menu - View commit details
-
Copy full SHA for e308226 - Browse repository at this point
Copy the full SHA e308226View commit details
Commits on Mar 5, 2020
-
Configuration menu - View commit details
-
Copy full SHA for 05be732 - Browse repository at this point
Copy the full SHA 05be732View commit details -
Raise warnings for possible misuse of master key API
Raise warnings instead of exceptions when we suspect that master key API is misused with strings. Since we're not introducing a new API, it would be rude to break Existing Code with unannounced exceptions. Howerver, we cannot pass on the possible misuse either. Master key API should not be used with strings. Currently, if you pass a Unicode string, it will be encoded in some internal encoding (usually UTF-8, but this may not be the case on Windows). Master key API should not be used with human-readable strings due to security concerns. Produce a warning when we see master key API to be used with types that we previously allowed but no longer recommend. Provide suggestions on what API should be used instead. This warns the user of possible misuse (if they pay attention to warnings) and does not break production code, which will keep the old behavior of misusing strings as master keys.
Configuration menu - View commit details
-
Copy full SHA for 591c4be - Browse repository at this point
Copy the full SHA 591c4beView commit details