diff options
author | Werner Koch <[email protected]> | 2020-04-23 07:51:15 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2020-04-23 07:51:15 +0000 |
commit | 5d015b38eb9f828acf522fa89e4944f3b343678c (patch) | |
tree | 8a3debe73942a0b6659736ccc04b5f7616d52039 /common/tlv.h | |
parent | sm: Support import of PKCS#12 encoded ECC private keys. (diff) | |
download | gnupg-5d015b38eb9f828acf522fa89e4944f3b343678c.tar.gz gnupg-5d015b38eb9f828acf522fa89e4944f3b343678c.zip |
common: Add functions to help create DER objects.
* common/tlv.c (put_tlv_to_membuf): New.
(get_tlv_length): New.
* common/tlv.h: Include membuf.h.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'common/tlv.h')
-rw-r--r-- | common/tlv.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/common/tlv.h b/common/tlv.h index ba4ea2e42..0c915e63f 100644 --- a/common/tlv.h +++ b/common/tlv.h @@ -30,6 +30,7 @@ #ifndef SCD_TLV_H #define SCD_TLV_H 1 +#include "membuf.h" enum tlv_tag_class { CLASS_UNIVERSAL = 0, @@ -86,13 +87,20 @@ const unsigned char *find_tlv_unchecked (const unsigned char *buffer, size_t length, int tag, size_t *nbytes); +/* 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); + /* 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. */ gpg_error_t parse_ber_header (unsigned char const **buffer, size_t *size, - int *r_class, int *r_tag, - int *r_constructed, + int *r_class, int *r_tag, + int *r_constructed, int *r_ndef, size_t *r_length, size_t *r_nhdr); |