Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(725)

Unified Diff: net/ssl/token_binding_openssl.cc

Issue 1378613004: Set Token-Binding HTTP header (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tb-tls-ext-new
Patch Set: rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698