mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-28 18:28:23 -05:00
ASN.1: Add a helper for parsing AlgorithmIdentifier
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
parent
f7f2843c45
commit
8006742fa3
@ -325,3 +325,27 @@ int asn1_get_sequence(const u8 *buf, size_t len, struct asn1_hdr *hdr,
|
||||
*next = hdr->payload + hdr->length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int asn1_get_alg_id(const u8 *buf, size_t len, struct asn1_oid *oid,
|
||||
const u8 **params, size_t *params_len, const u8 **next)
|
||||
{
|
||||
const u8 *pos = buf, *end = buf + len;
|
||||
struct asn1_hdr hdr;
|
||||
|
||||
/*
|
||||
* AlgorithmIdentifier ::= SEQUENCE {
|
||||
* algorithm OBJECT IDENTIFIER,
|
||||
* parameters ANY DEFINED BY algorithm OPTIONAL}
|
||||
*/
|
||||
if (asn1_get_sequence(pos, end - pos, &hdr, next) < 0 ||
|
||||
asn1_get_oid(hdr.payload, hdr.length, oid, &pos) < 0)
|
||||
return -1;
|
||||
|
||||
if (params && params_len) {
|
||||
*params = pos;
|
||||
*params_len = hdr.payload + hdr.length - pos;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -68,6 +68,8 @@ int asn1_oid_equal(const struct asn1_oid *a, const struct asn1_oid *b);
|
||||
int asn1_get_integer(const u8 *buf, size_t len, int *integer, const u8 **next);
|
||||
int asn1_get_sequence(const u8 *buf, size_t len, struct asn1_hdr *hdr,
|
||||
const u8 **next);
|
||||
int asn1_get_alg_id(const u8 *buf, size_t len, struct asn1_oid *oid,
|
||||
const u8 **params, size_t *params_len, const u8 **next);
|
||||
|
||||
extern struct asn1_oid asn1_sha1_oid;
|
||||
extern struct asn1_oid asn1_sha256_oid;
|
||||
|
Loading…
Reference in New Issue
Block a user