Index: net/ssl/token_binding_openssl.cc |
diff --git a/net/ssl/token_binding_openssl.cc b/net/ssl/token_binding_openssl.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c2aecf219dd640908985ab859ef1ed6f1987bec7 |
--- /dev/null |
+++ b/net/ssl/token_binding_openssl.cc |
@@ -0,0 +1,42 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "net/ssl/token_binding.h" |
+ |
+#include <openssl/bytestring.h> |
+#include <openssl/mem.h> |
+ |
+#include "net/base/net_errors.h" |
+ |
+namespace net { |
+ |
+int BuildTokenBindingMessageFromTokenBindings( |
+ const std::vector<std::string>& token_bindings, |
+ std::string* out) { |
+ CBB tb_message, tb_messages; |
+ uint8_t* out_data; |
+ size_t out_len; |
mattm
2015/10/01 01:53:01
move these down to where they are first used
nharper
2015/10/01 20:25:46
Done.
|
+ if (!CBB_init(&tb_message, 0) || |
+ !CBB_add_u16_length_prefixed(&tb_message, &tb_messages)) { |
+ CBB_cleanup(&tb_message); |
+ return ERR_FAILED; |
+ } |
+ for (const std::string& token_binding : token_bindings) { |
+ if (!CBB_add_bytes(&tb_messages, reinterpret_cast<uint8*>(const_cast<char*>( |
+ token_binding.data())), |
+ token_binding.size())) { |
+ CBB_cleanup(&tb_message); |
+ return ERR_FAILED; |
+ } |
+ } |
+ if (!CBB_finish(&tb_message, &out_data, &out_len)) { |
+ CBB_cleanup(&tb_message); |
+ return ERR_FAILED; |
+ } |
+ out->assign(reinterpret_cast<char*>(out_data), out_len); |
+ OPENSSL_free(out_data); |
+ return OK; |
+} |
+ |
+} // namespace net |