If the reserve size returned by AsyncSigner::reserve_size() is fairly close (but not exact) to the size of the Cose_Sign1 structure which c2pa-rs generates, we're seeing CoseSigboxTooSmall errors be returned.
The behavior of this is somewhat weird, and I believe it's because the padding calculation (let mut target_guess = end_size - cur_size - PAD_OFFSET) doesn't accurately account for the size which the header itself will take up once it's DER encoded. Thus it calculates a pad which is too large which then causes the reserve size to be overwhelmed.
I don't believe this should ever be the case - if the reserve size is larger than the size of the eventual Cose_Sign1 structure, this should succeed.
Maybe this is an understanding on my part? But to get this to work correctly, we're having to add in overly big reserve sizes to avoid the issue.
If the reserve size returned by
AsyncSigner::reserve_size()
is fairly close (but not exact) to the size of theCose_Sign1
structure whichc2pa-rs
generates, we're seeingCoseSigboxTooSmall
errors be returned.The behavior of this is somewhat weird, and I believe it's because the padding calculation (
let mut target_guess = end_size - cur_size - PAD_OFFSET
) doesn't accurately account for the size which the header itself will take up once it's DER encoded. Thus it calculates a pad which is too large which then causes the reserve size to be overwhelmed.I don't believe this should ever be the case - if the reserve size is larger than the size of the eventual
Cose_Sign1
structure, this should succeed.Maybe this is an understanding on my part? But to get this to work correctly, we're having to add in overly big reserve sizes to avoid the issue.