Repository navigation
Add configurable verification policies + access to system sequoia config #91
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
Open
dralley
wants to merge
2
commits into
wiktor-k:main
Choose a base branch
from
dralley:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+614
−84
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Cryptographic policies | ||
|
|
||
| PySequoia uses the build's default cryptographic policy when reading or using | ||
| certificates, verifying signatures, or decrypting messages. To use a different | ||
| policy, load one from a Sequoia configuration file and pass it to the operation. | ||
| For example, a configuration file can permit legacy SHA-1 certificate signatures | ||
| without permitting SHA-1 data signatures: | ||
|
|
||
| ```toml | ||
| [hash_algorithms] | ||
| sha1.second_preimage_resistance = "always" | ||
| ``` | ||
|
|
||
| ```python | ||
| from pysequoia import Policy, verify | ||
|
|
||
| policy = Policy.from_sequoia_config_file("/path/to/policy.toml") | ||
| result = verify(signed, get_certs_verify, policy=policy) | ||
| ``` | ||
|
|
||
| The policy can also be passed to certificate and secret key readers, such as | ||
| `Cert.from_file` and `Tsk.from_file`, and to `decrypt` and `decrypt_file`. | ||
| `repr(policy)` shows the configuration path or indicates that the policy uses | ||
| the build's default. | ||
|
|
||
| ## Using a system policy configuration | ||
|
|
||
| To use a Sequoia policy managed by the operating system, omit the path: | ||
|
|
||
| ```python | ||
| policy = Policy.from_sequoia_config_file() | ||
| result = verify(signed, get_certs_verify, policy=policy) | ||
| ``` | ||
|
|
||
| With no path, `from_sequoia_config_file` reads the absolute path in | ||
| `SEQUOIA_CRYPTO_POLICY` when that variable is set. Otherwise, it reads | ||
| `/etc/crypto-policies/back-ends/sequoia.config`. | ||
|
|
||
| This default path is a Sequoia convention, not a guarantee across Linux | ||
| distributions. Check that supported distributions provide a config there before | ||
| relying on it. | ||
|
|
||
| Setting `SEQUOIA_CRYPTO_POLICY` to an empty string explicitly selects | ||
| the built-in default policy. A missing or invalid file raises an exception | ||
| instead of falling back to the default policy. | ||
|
|
||
| Distributions can build with the Cargo feature `system-policy-default` to use | ||
| the system policy by default for operations where no policy is passed. The | ||
| configuration is loaded at import time. If the file is missing or invalid, | ||
| the import fails. Ensure `/etc/crypto-policies/back-ends/sequoia.config` exists | ||
| or set `SEQUOIA_CRYPTO_POLICY` to another absolute path. Explicitly passed | ||
| policies still override the default. | ||
|
|
||
| The feature selects a Sequoia policy; it does not change the cryptographic | ||
| backend or load OpenSSL configuration. | ||
|
|
||
| For the security properties and other advanced policy controls, see Sequoia's | ||
| [policy documentation][policy-docs] and its | ||
| [policy configuration format][policy-config]. | ||
|
|
||
| [policy-docs]: https://docs.rs/sequoia-openpgp/latest/sequoia_openpgp/policy/index.html | ||
| [policy-config]: https://docs.rs/sequoia-policy-config/latest/sequoia_policy_config/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I asked this before, but why not just keep a running changelog?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use that file to fill in tag description but maybe a running file would be a better idea. We would have to pre-fill it from tags in a separate PR.