Subject: Re: Q: Is possible indefinite form of length encoding in DER?

From: Andrew Farrell <[email-masked]>
Date: Tue, 19 Sep 2000 15:41:56 +0100

ChungKil Kim <[email-masked]> wrote:

>In some S/MIME messages, there are indefinite form of length encoding.
>Is it possible?

>In PKCS specs, only use DER?

An important thing to remember is that although it's often specified
that a signature must be over the DER encoding of an object, it's not
necessarily true that what is transmitted has to be that encoding.

On the ridiculous end of this rule is a certificate in which everything
is indefinite length encoded - perfectly valid AFAIK, as long as you
re-encode before verifying.

On the more practical end, it is often impossible to know when composing
a PKCS#7 SignedData how long the data being signed is. As a result all
the layers surrounding the Content (ContentInfo, SignedData,
EncapsulatedContentInfo) are encoded indefinite length, and the content
itself is encoded as a contructed octet string. The signature is over
the contents octets of the DER encoding, and so it is never necessary
even to count the length of the assembled octetstring. The individual
strings are simply fed to the digests as they appear.

Andrew

---

From: "Kingdon, Kevin" <[email-masked]>
Date: Tue, 19 Sep 2000 10:01:46 -0700

See comments below:

-----Original Message-----
From: Andrew Farrell [mailto:[email-masked]]
Sent: Tuesday, September 19, 2000 7:42 AM
To: [email-masked]
Cc: [email-masked]
Subject: Re: Q: Is possible indefinite form of length encoding in DER? 

<SNIP/>

<KWK>
Further complicating matters is the fact that some commercial products
incorrectly sign the BER encoding. So to validate a signature against a
BER-encoded message, you may have to try validating the with the transmitted
encoding and if that fails try re-coding and validating against the
DER-encoding of the message. (Note that signing BER is flawed if there is a
possibility that an intermediate processor will re-code the BER encoding
into a different but equivalent BER encoding. This usually doesn't happen
with BER, but it is expected to happen with XML-encoded documents. Thus
there is increased emphasis on "canonicalization" procedures for XML digital
signatures.)
</KWK>

<SNIP/>