aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/dl_group
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/pubkey/dl_group')
-rw-r--r--src/lib/pubkey/dl_group/dl_group.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/lib/pubkey/dl_group/dl_group.cpp b/src/lib/pubkey/dl_group/dl_group.cpp
index 9bab123cb..6a2d21c8b 100644
--- a/src/lib/pubkey/dl_group/dl_group.cpp
+++ b/src/lib/pubkey/dl_group/dl_group.cpp
@@ -457,37 +457,36 @@ std::vector<uint8_t> DL_Group::DER_encode(Format format) const
if(get_q().is_zero() && (format == ANSI_X9_57 || format == ANSI_X9_42))
throw Encoding_Error("Cannot encode DL_Group in ANSI formats when q param is missing");
+ std::vector<uint8_t> output;
+ DER_Encoder der(output);
+
if(format == ANSI_X9_57)
{
- return DER_Encoder()
- .start_cons(SEQUENCE)
+ der.start_cons(SEQUENCE)
.encode(get_p())
.encode(get_q())
.encode(get_g())
- .end_cons()
- .get_contents_unlocked();
+ .end_cons();
}
else if(format == ANSI_X9_42)
{
- return DER_Encoder()
- .start_cons(SEQUENCE)
+ der.start_cons(SEQUENCE)
.encode(get_p())
.encode(get_g())
.encode(get_q())
- .end_cons()
- .get_contents_unlocked();
+ .end_cons();
}
else if(format == PKCS_3)
{
- return DER_Encoder()
- .start_cons(SEQUENCE)
+ der.start_cons(SEQUENCE)
.encode(get_p())
.encode(get_g())
- .end_cons()
- .get_contents_unlocked();
+ .end_cons();
}
+ else
+ throw Invalid_Argument("Unknown DL_Group encoding " + std::to_string(format));
- throw Invalid_Argument("Unknown DL_Group encoding " + std::to_string(format));
+ return output;
}
/*