-
Notifications
You must be signed in to change notification settings - Fork 56
Avoid reading input files to memory #158
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
Comments
I agree that we should avoid reading inputs fully into memory, although I think we're actually limited by our dependencies in terms of actually doing this. For example, we use cryptography's We could maybe work/hack around that by using |
oh I did not realize that -- this is disappointing from cryptography (I suppose the actual process still works with chunks at a time). If it's an upstream issue then I'm fine with closing this as well: I expected this to be an easy fix not an issue with a dependency. |
I'm okay with keeping it open for now! I think we should investigate the feasibility of using |
One of the cryptography maintainers pointed out to me that ECDSA signing is defined by signing over the digest of the input rather than the full input, and that cryptography's API's actually supports pre-hashing the input and passing that in instead of the full As a result, this should actually be possible: we can stream the input into the digest function instead, and then pass Relevant APIs: https://cryptography.io/en/latest/hazmat/primitives/asymmetric/utils/#cryptography.hazmat.primitives.asymmetric.utils.Prehashed |
Closes #158. Signed-off-by: William Woodruff <[email protected]>
Doing this in #329. |
* sigstore: stream input into signing Closes #158. Signed-off-by: William Woodruff <[email protected]> * _utils: ignore some mypy errors See: python/typing#659 Signed-off-by: William Woodruff <[email protected]> * test_sign: fix signing test Signed-off-by: William Woodruff <[email protected]> * test_utils: test correctness of our digest streaming Signed-off-by: William Woodruff <[email protected]> * sigstore, test: stream verification as well Signed-off-by: William Woodruff <[email protected]> * _utils: document the security properties of sha256_streaming Signed-off-by: William Woodruff <[email protected]> Signed-off-by: William Woodruff <[email protected]>
The API uses
bytes
as type for all file contents. This is fine for certs and signatures, but the input files can be arbitrarily large: the API should not force reading input files to memory all at once.The text was updated successfully, but these errors were encountered: