Open qmfrederik opened 7 years ago
@peterdettman I hope this gives you a bit more background for PR #66. The subclass I've described above works for me (from a fork of BouncyCastle with #66 applied); if there's a better way to achieve this happy to find out.
Reading the title, this makes no sense. DER by definition does not support indefinite length encoding. Do do that you need to use BER.
@jimsch Thanks for the feedback, updated the title and description to hopefully be more precise.
Gist is that I'd like to control how objects are BER-encoded. In this case, I want to deviate from DER encoding in a very specify way for compatibility reasons.
A BER octet string is composed of DER encoded octet strings as children. From my reading it appears that there may be a limit in some circumstances of 1000 bytes for the DER encoded sequence. However if you create the BER octet string from a sequence then that limitation does not exist. This only seems to be used in GenerateOctets, but I don't know where that is being used. I don't generally use BouncyCastle for this purpose. Instead I use my own libraries.
@jimsch - I found my issue; I was using BER object wrapped in DER sequence or other DER wrapper, and it did not behave the way I thought it should have. When I changed everything on up to use BER it started working. Thanks!
This is a continuation of the discussion in #66.
I use Bouncy Castle to digitally sign iOS applications. I've noticed that validation of iOS apps fails (crashes) on the device if the signature contains BER-encoded sequences where i) a length which exceeds
0x1000
and ii) they are encoded using fixed-length encoding.I can't control iOS; hence I need to be able to control how sequences are encoded and be able to use variable-length encoding.
Currently, the BouncyCastle exposes no method (that I'm aware of) that enables me to control how objects are encoded.
Hence, the gist of this issue is that I'd like to control that.
I've been able to workaround this by enabling subclassing of the
DerObjectStream
class and implementing a subclass as shown below; and PR #66 was submitted to enable that scenario.