]> www.infradead.org Git - users/jedix/linux-maple.git/commit
lib: Add ASN.1 encoder
authorJames Bottomley <James.Bottomley@HansenPartnership.com>
Wed, 27 Jan 2021 19:06:13 +0000 (11:06 -0800)
committerJarkko Sakkinen <jarkko@kernel.org>
Fri, 9 Apr 2021 05:58:30 +0000 (08:58 +0300)
commit68a04ef0f938bc9d58b4313da063daacc55ebef8
tree6b9022bfa1f257b607ec2ff5f049ef7b61fd37f4
parentf47e81ef4f773f96c7152f9d1127e4c4f85b7e62
lib: Add ASN.1 encoder

We have a need in the TPM2 trusted keys to return the ASN.1 form of the TPM
key blob so it can be operated on by tools outside of the kernel.  The
specific tools are the openssl_tpm2_engine, openconnect and the Intel
tpm2-tss-engine.  To do that, we have to be able to read and write the same
binary key format the tools use.  The current ASN.1 decoder does fine for
reading, but we need pieces of an ASN.1 encoder to write the key blob in
binary compatible form.

For backwards compatibility, the trusted key reader code will still accept
the two TPM2B quantities that it uses today, but the writer will only
output the ASN.1 form.

The current implementation only encodes the ASN.1 bits we actually need.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Reviewed-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Tested-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
include/linux/asn1_encoder.h [new file with mode: 0644]
lib/Kconfig
lib/Makefile
lib/asn1_encoder.c [new file with mode: 0644]