diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2022-09-16 07:45:09 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2022-09-16 07:45:09 +0900 |
commit | 1e860c1f8b2b0b48617f2ca664aa9acf2fafc8d3 (patch) | |
tree | a945f12e0ecb03e7c1db7db427f469b46f5c71f9 /common/tlv.h | |
parent | 0fca6c1d0d6088ff4558a6ffc3bc220998699392 (diff) | |
download | gpg2-1e860c1f8b2b0b48617f2ca664aa9acf2fafc8d3.tar.gz gpg2-1e860c1f8b2b0b48617f2ca664aa9acf2fafc8d3.tar.bz2 gpg2-1e860c1f8b2b0b48617f2ca664aa9acf2fafc8d3.zip |
Imported Upstream version 2.2.37upstream/2.2.37
Diffstat (limited to 'common/tlv.h')
-rw-r--r-- | common/tlv.h | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/common/tlv.h b/common/tlv.h index 0894e5d..51a0ef4 100644 --- a/common/tlv.h +++ b/common/tlv.h @@ -73,6 +73,11 @@ enum tlv_tag_type { }; +struct tlv_builder_s; +typedef struct tlv_builder_s *tlv_builder_t; + +/*-- tlv.c --*/ + /* Locate a TLV encoded data object in BUFFER of LENGTH and return a pointer to value as well as its length in NBYTES. Return NULL if it was not found or if the object does not fit into the buffer. */ @@ -88,7 +93,6 @@ const unsigned char *find_tlv_unchecked (const unsigned char *buffer, size_t length, int tag, size_t *nbytes); - /* ASN.1 BER parser: Parse BUFFER of length SIZE and return the tag and the length part from the TLV triplet. Update BUFFER and SIZE on success. */ @@ -114,5 +118,26 @@ gpg_error_t parse_sexp (unsigned char const **buf, size_t *buflen, int *depth, unsigned char const **tok, size_t *toklen); +/*-- tlv-builder.c --*/ + +tlv_builder_t tlv_builder_new (int use_secure); +void tlv_builder_add_ptr (tlv_builder_t tb, int class, int tag, + void *value, size_t valuelen); +void tlv_builder_add_val (tlv_builder_t tb, int class, int tag, + const void *value, size_t valuelen); +void tlv_builder_add_tag (tlv_builder_t tb, int class, int tag); +void tlv_builder_add_end (tlv_builder_t tb); +gpg_error_t tlv_builder_finalize (tlv_builder_t tb, + void **r_obj, size_t *r_objlen); + +/* Wite a TLV header to MEMBUF. */ +void put_tlv_to_membuf (membuf_t *membuf, int class, int tag, + int constructed, size_t length); + +/* Count the length of a to be constructed TLV. */ +size_t get_tlv_length (int class, int tag, int constructed, size_t length); + + + #endif /* SCD_TLV_H */ |