]> git.baikalelectronics.ru Git - kernel.git/commit
ASN.1: Handle 'ANY OPTIONAL' in grammar
authorDavid Howells <dhowells@redhat.com>
Wed, 5 Aug 2015 11:54:46 +0000 (12:54 +0100)
committerDavid Howells <dhowells@redhat.com>
Wed, 5 Aug 2015 12:38:07 +0000 (13:38 +0100)
commitb15e2d1c67ddd09821d70c2070ef9108b61fad21
treefdf3021db1ab8f6d71908b6cc2a2e3afba94fb21
parent55e02290bc1f70a6a97fe00b5ede848a2c1076fd
ASN.1: Handle 'ANY OPTIONAL' in grammar

An ANY object in an ASN.1 grammar that is marked OPTIONAL should be skipped
if there is no more data to be had.

This can be tested by editing X.509 certificates or PKCS#7 messages to
remove the NULL from subobjects that look like the following:

SEQUENCE {
  OBJECT(2a864886f70d01010b);
  NULL();
}

This is an algorithm identifier plus an optional parameter.

The modified DER can be passed to one of:

keyctl padd asymmetric "" @s </tmp/modified.x509
keyctl padd pkcs7_test foo @s </tmp/modified.pkcs7

It should work okay with the patch and produce EBADMSG without.

Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Marcel Holtmann <marcel@holtmann.org>
Reviewed-by: David Woodhouse <David.Woodhouse@intel.com>
include/linux/asn1_ber_bytecode.h
lib/asn1_decoder.c
scripts/asn1_compiler.c