]> git.ipfire.org Git - thirdparty/krb5.git/commit
Simplify ASN.1 encoding 751/head
authorGreg Hudson <ghudson@mit.edu>
Wed, 21 Mar 2018 22:17:08 +0000 (18:17 -0400)
committerGreg Hudson <ghudson@mit.edu>
Tue, 27 Mar 2018 18:37:42 +0000 (14:37 -0400)
commit5dd2f6877bb88aa57e6650b26daf0864ae732ae8
tree255bf184e4380de88d951bb968fa07b6998b9c4f
parentc80ce2682015be863c73fbebdaeb919d34930073
Simplify ASN.1 encoding

Like most ASN.1 DER implementations, we encode backwards.  The
existing asn1buf implementation inserts bytes forward into a
resizeable buffer, then reallocates the number of bytes inserted and
reverses them.

Throw out this implementation and replace it with two simple inline
functions in asn1_encode.c, which conditionally insert bytes in
reverse order and unconditionally increment a count.  Make two passes
over the input representation, once to count the encoding size and
once to actually encode it into a precisely allocated buffer.  Remove
all of the explicit length counting from encoding functions; in the
places where we need intermediate lengths, compute them from the
difference in buffer byte count.  Make a few encoding functions return
void as they no longer have error cases.
src/lib/krb5/asn.1/Makefile.in
src/lib/krb5/asn.1/asn1_encode.c
src/lib/krb5/asn.1/asn1_encode.h
src/lib/krb5/asn.1/asn1_k_encode.c
src/lib/krb5/asn.1/asn1buf.c [deleted file]
src/lib/krb5/asn.1/asn1buf.h [deleted file]
src/lib/krb5/asn.1/deps