Index: components/gcm_driver/crypto/encryption_header_parsers.h |
diff --git a/components/gcm_driver/crypto/encryption_header_parsers.h b/components/gcm_driver/crypto/encryption_header_parsers.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0ca82a0e68e9d914f7713f5a9cff9bdfa2b796ea |
--- /dev/null |
+++ b/components/gcm_driver/crypto/encryption_header_parsers.h |
@@ -0,0 +1,43 @@ |
+// 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. |
+ |
+#ifndef COMPONENTS_GCM_DRIVER_CRYPTO_ENCRYPTION_HEADER_PARSERS_H_ |
+#define COMPONENTS_GCM_DRIVER_CRYPTO_ENCRYPTION_HEADER_PARSERS_H_ |
+ |
+#include <stdint.h> |
+#include <string> |
+#include <vector> |
+ |
+namespace gcm { |
+ |
+// Structure representing a parsed and decoded value from the Encryption header. |
+// https://tools.ietf.org/html/draft-thomson-http-encryption-01#section-3 |
+struct EncryptionHeaderValue { |
+ std::string keyid; |
+ std::string salt; |
+ int64_t rs = 4096; |
+}; |
+ |
+// Structure representing a parsed and decoded value from the Encryption-Key |
+// header. |
+// https://tools.ietf.org/html/draft-thomson-http-encryption-01#section-4 |
+struct EncryptionKeyHeaderValue { |
+ std::string keyid; |
+ std::string key; |
+ std::string dh; |
+}; |
+ |
+// Parses |input| following the syntax of the Encryption HTTP header. Returns |
+// whether the |input| could be parsed into |result| successfully. |
+bool ParseEncryptionHeader(const std::string& input, |
+ std::vector<EncryptionHeaderValue>* result); |
+ |
+// Parses |input| following the syntax of the Encryption-Key HTTP header. |
+// Returns whether the |input| could be parsed into |result| successfully. |
+bool ParseEncryptionKeyHeader(const std::string& input, |
+ std::vector<EncryptionKeyHeaderValue>* result); |
+ |
+} // namespace gcm |
+ |
+#endif // COMPONENTS_GCM_DRIVER_CRYPTO_ENCRYPTION_HEADER_PARSERS_H_ |