RustCrypto / formats

Cryptography-related format encoders/decoders: DER, PEM, PKCS, PKIX
229 stars 122 forks source link

serdect: `slice::deserialize_hex_or_bin` needs to return the amount of deserialized data #1322

Open tarcieri opened 6 months ago

tarcieri commented 6 months ago

This is tracking a regression from #1112, where slice::deserialize_hex_or_bin was changed to return Result<(), D::Error> instead of Result<&[u8], D::Error>.

Notably this API is intended for use cases where the amount of deserialized data can vary, and may be shorter than the provided buffer parameter. The ability to handle messages shorter than buffer has been lost.

See https://github.com/RustCrypto/formats/pull/1112#discussion_r1446473939

fjarri commented 6 months ago

Ah, my bad, didn't realize from the docstring it was a part of the contract, and I don't think there was a test for it either. But the functionality does sound necessary now that I think about it.