From: "Jarkko Sakkinen" <jarkko@kernel.org>
To: "James Bottomley" <James.Bottomley@HansenPartnership.com>,
<linux-integrity@vger.kernel.org>
Cc: <keyrings@vger.kernel.org>, "David Howells" <dhowells@redhat.com>
Subject: Re: [PATCH 3/3] lib: asn1_encode: remove obsolete asn1_encode_oid
Date: Fri, 24 May 2024 16:36:36 +0300 [thread overview]
Message-ID: <D1HWYD30PATS.2RPJ8RD2CU67O@kernel.org> (raw)
In-Reply-To: <20240524125955.20739-4-James.Bottomley@HansenPartnership.com>
On Fri May 24, 2024 at 3:59 PM EEST, James Bottomley wrote:
> This has been replaced by encode_OID from the OID_registry. To use,
> consumers must make sure the OID is present in enum OID in
> oid_registry.h and then use encode_OID with the enum.
>
> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
> ---
> include/linux/asn1_encoder.h | 3 --
> lib/asn1_encoder.c | 91 ------------------------------------
> 2 files changed, 94 deletions(-)
>
> diff --git a/include/linux/asn1_encoder.h b/include/linux/asn1_encoder.h
> index 08cd0c2ad34f..5f8cf47ede59 100644
> --- a/include/linux/asn1_encoder.h
> +++ b/include/linux/asn1_encoder.h
> @@ -13,9 +13,6 @@ 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 *
> diff --git a/lib/asn1_encoder.c b/lib/asn1_encoder.c
> index 0fd3c454a468..c0db3cbebe89 100644
> --- a/lib/asn1_encoder.c
> +++ b/lib/asn1_encoder.c
> @@ -85,97 +85,6 @@ asn1_encode_integer(unsigned char *data, const unsigned char *end_data,
> }
> EXPORT_SYMBOL_GPL(asn1_encode_integer);
>
> -/* calculate the base 128 digit values setting the top bit of the first octet */
> -static int asn1_encode_oid_digit(unsigned char **_data, int *data_len, u32 oid)
> -{
> - unsigned char *data = *_data;
> - int start = 7 + 7 + 7 + 7;
> - int ret = 0;
> -
> - if (*data_len < 1)
> - return -EINVAL;
> -
> - /* quick case */
> - if (oid == 0) {
> - *data++ = 0x80;
> - (*data_len)--;
> - goto out;
> - }
> -
> - while (oid >> start == 0)
> - start -= 7;
> -
> - while (start > 0 && *data_len > 0) {
> - u8 byte;
> -
> - byte = oid >> start;
> - oid = oid - (byte << start);
> - start -= 7;
> - byte |= 0x80;
> - *data++ = byte;
> - (*data_len)--;
> - }
> -
> - if (*data_len > 0) {
> - *data++ = oid;
> - (*data_len)--;
> - } else {
> - ret = -EINVAL;
> - }
> -
> - out:
> - *_data = data;
> - return ret;
> -}
> -
> -/**
> - * asn1_encode_oid() - encode an oid to ASN.1
> - * @data: position to begin encoding at
> - * @end_data: end of data pointer, points one beyond last usable byte in @data
> - * @oid: array of oids
> - * @oid_len: length of oid array
> - *
> - * this encodes an OID up to ASN.1 when presented as an array of OID values
> - */
> -unsigned char *
> -asn1_encode_oid(unsigned char *data, const unsigned char *end_data,
> - u32 oid[], int oid_len)
> -{
> - int data_len = end_data - data;
> - unsigned char *d = data + 2;
> - int i, ret;
> -
> - if (WARN(oid_len < 2, "OID must have at least two elements"))
> - return ERR_PTR(-EINVAL);
> -
> - if (WARN(oid_len > 32, "OID is too large"))
> - return ERR_PTR(-EINVAL);
> -
> - if (IS_ERR(data))
> - return data;
> -
> -
> - /* need at least 3 bytes for tag, length and OID encoding */
> - if (data_len < 3)
> - return ERR_PTR(-EINVAL);
> -
> - data[0] = _tag(UNIV, PRIM, OID);
> - *d++ = oid[0] * 40 + oid[1];
> -
> - data_len -= 3;
> -
> - for (i = 2; i < oid_len; i++) {
> - ret = asn1_encode_oid_digit(&d, &data_len, oid[i]);
> - if (ret < 0)
> - return ERR_PTR(ret);
> - }
> -
> - data[1] = d - data - 2;
> -
> - return d;
> -}
> -EXPORT_SYMBOL_GPL(asn1_encode_oid);
> -
> /**
> * asn1_encode_length() - encode a length to follow an ASN.1 tag
> * @data: pointer to encode at
Obvious change but I skip R-y's before the first patch has been
fixed (no use for anyone to tag them).
BR, Jarkko
prev parent reply other threads:[~2024-05-24 13:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-24 12:59 [PATCH 0/3] replace asn1_encode_oid with encode_OID James Bottomley
2024-05-24 12:59 ` [PATCH 1/3] lib/oid_registry: add ability to ASN.1 encode OIDs James Bottomley
2024-05-24 13:34 ` Jarkko Sakkinen
2024-05-24 14:02 ` James Bottomley
2024-05-24 14:26 ` Jarkko Sakkinen
2024-05-24 14:28 ` Jarkko Sakkinen
2024-05-27 3:49 ` Ben Boeckel
2024-05-24 12:59 ` [PATCH 2/3] KEYS: trusted: use encode_OID for OID encoding James Bottomley
2024-05-24 13:35 ` Jarkko Sakkinen
2024-05-24 12:59 ` [PATCH 3/3] lib: asn1_encode: remove obsolete asn1_encode_oid James Bottomley
2024-05-24 13:36 ` Jarkko Sakkinen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D1HWYD30PATS.2RPJ8RD2CU67O@kernel.org \
--to=jarkko@kernel.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=dhowells@redhat.com \
--cc=keyrings@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.