1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

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 <wk@gnupg.org>
This commit is contained in:
Werner Koch 2020-04-23 09:51:15 +02:00
parent 8dfef5197a
commit 5d015b38eb
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
2 changed files with 111 additions and 2 deletions

View file

@ -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);