aboutsummaryrefslogtreecommitdiffstats
path: root/SoftHSMv2/src/lib/crypto/BotanUtil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'SoftHSMv2/src/lib/crypto/BotanUtil.cpp')
-rw-r--r--SoftHSMv2/src/lib/crypto/BotanUtil.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/SoftHSMv2/src/lib/crypto/BotanUtil.cpp b/SoftHSMv2/src/lib/crypto/BotanUtil.cpp
index e5da460..c623fed 100644
--- a/SoftHSMv2/src/lib/crypto/BotanUtil.cpp
+++ b/SoftHSMv2/src/lib/crypto/BotanUtil.cpp
@@ -144,3 +144,22 @@ Botan::PointGFp BotanUtil::byteString2ECPoint(const ByteString& byteString, cons
return Botan::OS2ECP(&repr[0], repr.size(), ecGroup.get_curve());
}
#endif
+
+#ifdef WITH_EDDSA
+// Convert a Botan OID to a ByteString
+ByteString BotanUtil::oid2ByteString(const Botan::OID& oid)
+{
+ const Botan::secure_vector<Botan::byte>& der = Botan::DER_Encoder().encode(oid).get_contents();
+ return ByteString(&der[0], der.size());
+}
+
+// Convert a ByteString to a Botan OID
+Botan::OID BotanUtil::byteString2Oid(const ByteString& byteString)
+{
+ Botan::OID oid;
+ Botan::BER_Decoder(byteString.const_byte_str(), byteString.size())
+ .decode(oid)
+ .verify_end();
+ return oid;
+}
+#endif