mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-28 20:02:17 +00:00
![James Bottomley](/assets/img/avatar_default.png)
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>
32 lines
1,006 B
C
32 lines
1,006 B
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
|
|
#ifndef _LINUX_ASN1_ENCODER_H
|
|
#define _LINUX_ASN1_ENCODER_H
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/asn1.h>
|
|
#include <linux/asn1_ber_bytecode.h>
|
|
#include <linux/bug.h>
|
|
|
|
#define asn1_oid_len(oid) (sizeof(oid)/sizeof(u32))
|
|
unsigned char *
|
|
asn1_encode_integer(unsigned char *data, const unsigned char *end_data,
|
|
s64 integer);
|
|
unsigned char *
|
|
asn1_encode_oid(unsigned char *data, const unsigned char *end_data,
|
|
u32 oid[], int oid_len);
|
|
unsigned char *
|
|
asn1_encode_tag(unsigned char *data, const unsigned char *end_data,
|
|
u32 tag, const unsigned char *string, int len);
|
|
unsigned char *
|
|
asn1_encode_octet_string(unsigned char *data,
|
|
const unsigned char *end_data,
|
|
const unsigned char *string, u32 len);
|
|
unsigned char *
|
|
asn1_encode_sequence(unsigned char *data, const unsigned char *end_data,
|
|
const unsigned char *seq, int len);
|
|
unsigned char *
|
|
asn1_encode_boolean(unsigned char *data, const unsigned char *end_data,
|
|
bool val);
|
|
|
|
#endif
|