Re: [PATCH v2 2/9] lib/asn1_encoder: Add asn1_encode_integer_bytes()

From: David Laight

Date: Wed Nov 25 2026 - 16:33:45 EST


On Wed, 25 Nov 2026 17:38:55 +0200
Jarkko Sakkinen <jarkko@xxxxxxxxxx> wrote:

> On Wed, Nov 25, 2026 at 09:19:21AM +0000, David Laight wrote:
> > On Tue, 24 Nov 2026 21:40:36 +0200
> > Jarkko Sakkinen <jarkko@xxxxxxxxxx> wrote:
> >
> > > Add a helper encoding a positive integer from a byte array in big-endian
> > > format.
> >
> > Interesting...
> > You allow for integer values longer than 127 bytes but don't allow for the
> > much more common likelyhood of the encoding being 'implicit'.
>
> This is the first thing I wrote in 2024 and have not touched since
> without further feedback :-)

I wrote an ASN.1 encoder/decoder for a tcap library a few years back.
Pretty much everything was implicit and some of the tags exceed 5 bits.
About the only things that needed multi-byte lengths were constructed.
Oh - and you can't fit in a maximal length SMS if you use the indefinite
length for constructed items between 128 and 255 bytes, you have to use
the two-byte encoding.

There were a few functions for 'add item to buffer', but I didn't need
this one.

David

>
>
> >
> > David
>
>
> Br, Jarkko