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.
On line 350 of
c_monocypher.pyx
there is an unconditional call tocrypto_wipe
. Starting on line 155 the definition ofwipe
includes a comment that says: "WARNING: this violates the Python memory model and may result in corrupted data. Ensure that the data to wipe is the only active reference!"""While developing a cryptographic protocol that optionally uses very short passwords, we appear to have encountered this issue. We outlined this finding in our comments but we only seem to trigger it for passwords with a length that is less than two bytes: https://codeberg.org/rendezvous/reunion/src/branch/main/reunion/primitives.py#L17 We additionally make a copy of the original password for use over long periods of time.
We would prefer to not corrupt memory for the single password cases in our protocol, if that is indeed happening. We would also prefer not to need to make a copy of the original passphrase to work around this specific use case as erasing the password in memory is problematic for long running protocol runs.
This change optionally allows a caller to avoid
argon2i_32
callingwipe
orcrypto_wipe
internally by passing the optional value_wipe=False
when usingargon2i_32
. By default the original behavior is retained (e.g.:_wipe=True
andwipe
is called byargon2i_32
). This change would only impact callers who want to disable wiping.