]> git.karo-electronics.de Git - karo-tx-linux.git/commit
X.509: Add simple ASN.1 grammar compiler
authorDavid Howells <dhowells@redhat.com>
Fri, 21 Sep 2012 22:31:13 +0000 (23:31 +0100)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 28 Sep 2012 05:14:54 +0000 (14:44 +0930)
commit54ddd23d78bacad3a8b94c656576a1da0bbd9cde
tree27c62bded59eda491109e5d966f4d4734b856de7
parent72990fc3057e5fb2dce45008f7bed6fa0aceff06
X.509: Add simple ASN.1 grammar compiler

Add a simple ASN.1 grammar compiler.  This produces a bytecode output that can
be fed to a decoder to inform the decoder how to interpret the ASN.1 stream it
is trying to parse.

Action functions can be specified in the grammar by interpolating:

({ foo })

after a type, for example:

SubjectPublicKeyInfo ::= SEQUENCE {
algorithm AlgorithmIdentifier,
subjectPublicKey BIT STRING ({ do_key_data })
}

The decoder is expected to call these after matching this type and parsing the
contents if it is a constructed type.

The grammar compiler does not currently support the SET type (though it does
support SET OF) as I can't see a good way of tracking which members have been
encountered yet without using up extra stack space.

Currently, the grammar compiler will fail if more than 256 bytes of bytecode
would be produced or more than 256 actions have been specified as it uses
8-bit jump values and action indices to keep space usage down.

Signed-off-by: David Howells <dhowells@redhat.com>
include/linux/asn1.h [new file with mode: 0644]
include/linux/asn1_ber_bytecode.h [new file with mode: 0644]
init/Kconfig
scripts/.gitignore
scripts/Makefile
scripts/Makefile.build
scripts/asn1_compiler.c [new file with mode: 0644]