SharpZipLib icon indicating copy to clipboard operation
SharpZipLib copied to clipboard

Experiment with using ITaggedData for AES extra data handling

Open Numpsy opened this issue 5 years ago • 5 comments

This is an experiment to use the ITaggedData machinery for handling the AES extra data, too see how it might effect things, and to think if it might be useful for #443 (to have the extra data handling in a central place).

Notes:

  1. It changes the TagID property on ITaggedData from short to ushort to accomodate the 0x9901 value for the AES extra data. Some of the other apis use int rather than short so that might be more consistent, not sure if other places could be changed to keep it working with short though.

  2. Not sure if using ZipHelperStream to unpack the data instead of reading array values is more extra overhead than would be ideal, though i think the read functions in ZipExtraData might already do more size checks than they really need to, so perhaps it could be tuned in general?

  3. Similar on the GetData() side - building the fixed 7 byte array with a temporary stream and 7 calls to write byte is perhaps not the optimal approach there.

I certify that I own, and have sufficient rights to contribute, all source code and related material intended to be compiled or integrated with the source code for the SharpZipLib open source product (the "Contribution"). My Contribution is licensed under the MIT License.

Numpsy avatar May 30 '20 22:05 Numpsy

I am currently going through the ExtraFields/ITaggedData for ArchiveDiag and have added some extensions and an Enum with the known IDs. I'm thinking about doing some changes to the API to make it a bit more useful, but that should not affect this too much.

piksel avatar Jun 23 '20 19:06 piksel

it was initially just to see if it's a reasonable approach to sharing the AES extra data code (rather than just having some other helper functions), rather than a concrete thing, so no problem.

(as far as the shape of the api goes, see my comment about possibly not being terribly efficient, though I don't know what the scope is for changing the interface vs. public API breaks)

Numpsy avatar Jun 23 '20 22:06 Numpsy

Codecov Report

Merging #470 (9bd70bd) into master (b5b1a92) will increase coverage by 0.33%. The diff coverage is 94.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #470      +/-   ##
==========================================
+ Coverage   73.07%   73.40%   +0.33%     
==========================================
  Files          68       68              
  Lines        8305     8322      +17     
==========================================
+ Hits         6069     6109      +40     
+ Misses       2236     2213      -23     
Impacted Files Coverage Δ
src/ICSharpCode.SharpZipLib/Zip/ZipExtraData.cs 79.23% <92.85%> (+2.90%) :arrow_up:
src/ICSharpCode.SharpZipLib/Zip/ZipEntry.cs 91.11% <100.00%> (+0.20%) :arrow_up:
src/ICSharpCode.SharpZipLib/Zip/ZipOutputStream.cs 91.94% <100.00%> (-0.10%) :arrow_down:
...ode.SharpZipLib/Zip/Compression/DeflaterHuffman.cs 97.87% <0.00%> (+6.07%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b5b1a92...9bd70bd. Read the comment docs.

codecov[bot] avatar Oct 04 '21 19:10 codecov[bot]

Just trying to remember what state this was left in...

Any thoughts on the type of TagID, given the comments in the op and in #657 ?

Numpsy avatar Oct 06 '21 09:10 Numpsy

I think it should definitely be ushort (or even byte[2], but that's a bit less convenient to use).

piksel avatar Oct 06 '21 13:10 piksel