diff options
author | Jack Lloyd <[email protected]> | 2019-10-28 06:48:38 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-10-28 06:51:35 -0400 |
commit | f84a03eaace029270d2d026fc3ecf5ba004f0c89 (patch) | |
tree | b8d96422275d9686bb56c532c9bdcd2770f3552b /src/lib/x509 | |
parent | dcb621e23a8ff8f1cb24adc681807a52dc6a49b3 (diff) |
Deprecate DER_Encoder::get_contents_unlocked
It's better to use the version taking the vector in the constructor
as otherwise we store to locked memory then copy out at the end.
Convert all library uses.
Diffstat (limited to 'src/lib/x509')
-rw-r--r-- | src/lib/x509/pkcs10.cpp | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/lib/x509/pkcs10.cpp b/src/lib/x509/pkcs10.cpp index 5e40cb4c3..d35e8994a 100644 --- a/src/lib/x509/pkcs10.cpp +++ b/src/lib/x509/pkcs10.cpp @@ -80,26 +80,17 @@ PKCS10_Request PKCS10_Request::create(const Private_Key& key, if(challenge.empty() == false) { - ASN1_String challenge_str(challenge, DIRECTORY_STRING); - - tbs_req.encode( - Attribute("PKCS9.ChallengePassword", - DER_Encoder().encode(challenge_str).get_contents_unlocked() - ) - ); + std::vector<uint8_t> value; + DER_Encoder(value).encode(ASN1_String(challenge, DIRECTORY_STRING)); + tbs_req.encode(Attribute("PKCS9.ChallengePassword", value)); } - tbs_req.encode( - Attribute("PKCS9.ExtensionRequest", - DER_Encoder() - .start_cons(SEQUENCE) - .encode(extensions) - .end_cons() - .get_contents_unlocked() - ) - ) - .end_explicit() - .end_cons(); + std::vector<uint8_t> extension_req; + DER_Encoder(extension_req).start_cons(SEQUENCE).encode(extensions).end_cons(); + tbs_req.encode(Attribute("PKCS9.ExtensionRequest", extension_req)); + + // end the start_explicit above + tbs_req.end_explicit().end_cons(); const std::vector<uint8_t> req = X509_Object::make_signed(signer.get(), rng, sig_algo, |