From bd9a03d4989159db04c95ffe60b0c3220ccc1434 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Tue, 2 Dec 2025 17:18:53 -0600 Subject: [PATCH] asn1: Add ASN1_MALLOC_ENCODE_SAVE() macro --- lib/asn1/asn1-common.h | 7 +++++++ lib/asn1/gen.c | 7 +++++++ lib/asn1/pkinit.opt | 1 + 3 files changed, 15 insertions(+) create mode 100644 lib/asn1/pkinit.opt diff --git a/lib/asn1/asn1-common.h b/lib/asn1/asn1-common.h index 7797eed49..c137dbbfb 100644 --- a/lib/asn1/asn1-common.h +++ b/lib/asn1/asn1-common.h @@ -75,6 +75,13 @@ enum asn1_print_flags { } \ } while (0) +#define ASN1_MALLOC_ENCODE_SAVE(T, S, L, R) \ + do { \ + der_free_octet_string(&(S)->_save); \ + ASN1_MALLOC_ENCODE(T, (S)->_save.data, \ + (S)->_save.length, (S), (L), (R)); \ + } while (0) + #ifdef _WIN32 #ifndef ASN1_LIB #define ASN1EXP __declspec(dllimport) diff --git a/lib/asn1/gen.c b/lib/asn1/gen.c index 55ec5f647..2fa394657 100644 --- a/lib/asn1/gen.c +++ b/lib/asn1/gen.c @@ -273,6 +273,13 @@ init_generate (const char *filename, const char *base) " } \\\n" " } while (0)\n\n", headerfile); + fputs("#define ASN1_MALLOC_ENCODE_SAVE(T, S, L, R) \\\n" + " do { \\\n" + " der_free_octet_string(&(S)->_save); \\\n" + " ASN1_MALLOC_ENCODE(T, (S)->_save.data, \\\n" + " (S)->_save.length, (S), (L), (R)); \\\n" + " } while (0)\n\n", + headerfile); fputs("#ifdef _WIN32\n" "#ifndef ASN1_LIB\n" "#define ASN1EXP __declspec(dllimport)\n" diff --git a/lib/asn1/pkinit.opt b/lib/asn1/pkinit.opt new file mode 100644 index 000000000..a55ecc331 --- /dev/null +++ b/lib/asn1/pkinit.opt @@ -0,0 +1 @@ +--sequence=TD_DH_PARAMETERS