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

Use streams when calculating digest of data file #54

Open
Martsim opened this issue Nov 25, 2018 · 2 comments
Open

Use streams when calculating digest of data file #54

Martsim opened this issue Nov 25, 2018 · 2 comments

Comments

@Martsim
Copy link

Martsim commented Nov 25, 2018

Currently there is an upper limit to the size of signable data files, related to the servers available memory.

The problem is, that in byte[] org.digidoc4j.DataFile.calculateDigestInternal(DigestAlgorithm digestAlgorithm), the digest calculation function uses getBytes - internally, the whole datafile is loaded to memory, which is inefficient.

A more efficient solution would be to use the byte[] eu.europa.esig.dss.digest(final DigestAlgorithm digestAlgo, final InputStream inputStream).
In this case, the digest is calculated over a stream. Internally, they use a 4096 byte buffer.

Attached is a zip of patch of possible fix (generated using git diff on develop branch).
digidoc4j_datafile_streams.zip

Required where:

  • low memory sysems
  • Systems with large files
  • Systems with large numbers of parallel users

Best regards,
Mart Simisker

@naare
Copy link
Contributor

naare commented Jan 8, 2019

This proposal has been added to backlog for further analysis.

@naare
Copy link
Contributor

naare commented Jun 1, 2022

We have released Digidoc4j 5.0.0 where we have improved the stream usage in Digidoc4J side. However DSS 5.9 still uses byte arrays internally meaning that the maximum data file size is limited to 2GB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants