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

crypto._PassphraseHelper: pass non-callable passphrase using callback #947

Merged
merged 2 commits into from
Oct 13, 2020
Merged

crypto._PassphraseHelper: pass non-callable passphrase using callback #947

merged 2 commits into from
Oct 13, 2020

Conversation

huwcbjones
Copy link
Contributor

Fixes #945

Before this PR, we would pass a bytes passphrase as a null terminated string.
This causes issue when a randomly generated key's first byte is null because OpenSSL rightly determines the key length is 0.
This PR modifies the passphrase helper to pass the passphrase via the callback and adds tests to prevent regression.

Fixes #945

Before this commit, we would pass a bytes passphrase as a null terminated string.
This causes issue when a randomly generated key's first byte is null because
OpenSSL rightly determines the key length is 0.
This commit modifies the passphrase helper to pass the passphrase via the
 callback
@reaperhulk reaperhulk closed this Oct 12, 2020
@reaperhulk reaperhulk reopened this Oct 12, 2020
@reaperhulk
Copy link
Member

(Close/reopen to see if codecov can sort itself out)

@reaperhulk
Copy link
Member

@huwcbjones Thanks for the PR -- would you mind adding a changelog entry documenting this fix? Otherwise this LGTM.

@huwcbjones
Copy link
Contributor Author

@reaperhulk Have added an update in the changelog

@reaperhulk reaperhulk merged commit cdd6696 into pyca:master Oct 13, 2020
@huwcbjones huwcbjones deleted the issue/945 branch October 13, 2020 08:32
netbsd-srcmastr referenced this pull request in NetBSD/pkgsrc Dec 19, 2020
Changes:
20.0.1 (2020-12-15)
-------------------
Backward-incompatible changes:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Deprecations:
^^^^^^^^^^^^^

Changes:
^^^^^^^^
- Fixed compatibility with OpenSSL 1.1.0.

20.0.0 (2020-11-27)
-------------------
Backward-incompatible changes:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- The minimum ``cryptography`` version is now 3.2.
- Remove deprecated ``OpenSSL.tsafe`` module.
- Removed deprecated ``OpenSSL.SSL.Context.set_npn_advertise_callback``, ``OpenSSL.SSL.Context.set_npn_select_callback``, and ``OpenSSL.SSL.Connection.get_next_proto_negotiated``.
- Drop support for Python 3.4
- Drop support for OpenSSL 1.0.1 and 1.0.2

Deprecations:
^^^^^^^^^^^^^
- Deprecated ``OpenSSL.crypto.loads_pkcs7`` and ``OpenSSL.crypto.loads_pkcs12``.

Changes:
^^^^^^^^
- Added a new optional ``chain`` parameter to ``OpenSSL.crypto.X509StoreContext()``
  where additional untrusted certificates can be specified to help chain building.
  `#948 <https://github.com/pyca/pyopenssl/pull/948>`_
- Added ``OpenSSL.crypto.X509Store.load_locations`` to set trusted
  certificate file bundles and/or directories for verification.
  `#943 <https://github.com/pyca/pyopenssl/pull/943>`_
- Added ``Context.set_keylog_callback`` to log key material.
  `#910 <https://github.com/pyca/pyopenssl/pull/910>`_
- Added ``OpenSSL.SSL.Connection.get_verified_chain`` to retrieve the
  verified certificate chain of the peer.
  `#894 <https://github.com/pyca/pyopenssl/pull/894>`_.
- Make verification callback optional in ``Context.set_verify``.
  If omitted, OpenSSL's default verification is used.
  `#933 <https://github.com/pyca/pyopenssl/pull/933>`_
- Fixed a bug that could truncate or cause a zero-length key error due to a
  null byte in private key passphrase in ``OpenSSL.crypto.load_privatekey``
  and ``OpenSSL.crypto.dump_privatekey``.
  `#947 <https://github.com/pyca/pyopenssl/pull/947>`_
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

dump_privatekey truncates key when null byte in passphrase
2 participants