aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/gost_3410
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-05-22 11:04:15 -0400
committerJack Lloyd <[email protected]>2018-05-22 11:04:15 -0400
commit3789138906cecbcc5e33bb0d5784e6b576171080 (patch)
tree147c442020bec8ad6effe62727fdb6b300d0f7f7 /src/lib/pubkey/gost_3410
parentcd0bcd90817ece3e4fcba32e06a372580bbe3008 (diff)
DER improvements
Let DER_Encoder write to a user specified vector instead of only to an internal vector. This allows encoding to a std::vector without having to first write to a locked vector and then copying out the result. Add ASN1_Object::BER_encode convenience method. Replaces X509_Object::BER_encode which had the same logic but was restricted to a subtype. This replaces many cases where DER_Encoder was just used to encode a single object (X509_DN, AlgorithmIdentifier, etc).
Diffstat (limited to 'src/lib/pubkey/gost_3410')
-rw-r--r--src/lib/pubkey/gost_3410/gost_3410.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/lib/pubkey/gost_3410/gost_3410.cpp b/src/lib/pubkey/gost_3410/gost_3410.cpp
index 1d1b0d75e..d6e8874ab 100644
--- a/src/lib/pubkey/gost_3410/gost_3410.cpp
+++ b/src/lib/pubkey/gost_3410/gost_3410.cpp
@@ -35,16 +35,19 @@ std::vector<uint8_t> GOST_3410_PublicKey::public_key_bits() const
std::swap(bits[part_size+i], bits[2*part_size-1-i]);
}
- return DER_Encoder().encode(bits, OCTET_STRING).get_contents_unlocked();
+ std::vector<uint8_t> output;
+ DER_Encoder(output).encode(bits, OCTET_STRING);
+ return output;
}
AlgorithmIdentifier GOST_3410_PublicKey::algorithm_identifier() const
{
- std::vector<uint8_t> params =
- DER_Encoder().start_cons(SEQUENCE)
+ std::vector<uint8_t> params;
+
+ DER_Encoder(params)
+ .start_cons(SEQUENCE)
.encode(domain().get_curve_oid())
- .end_cons()
- .get_contents_unlocked();
+ .end_cons();
return AlgorithmIdentifier(get_oid(), params);
}