OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_GCM_DRIVER_CRYPTO_ENCRYPTION_HEADER_PARSERS_H_ |
| 6 #define COMPONENTS_GCM_DRIVER_CRYPTO_ENCRYPTION_HEADER_PARSERS_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 namespace gcm { |
| 13 |
| 14 // Structure representing the parsed values from the Encryption HTTP header. |
| 15 // |salt| is stored after having been base64url decoded. |
| 16 struct EncryptionHeaderValues { |
| 17 std::string keyid; |
| 18 std::string salt; |
| 19 uint64_t rs; |
| 20 }; |
| 21 |
| 22 // Parses |input| following the syntax of the Encryption HTTP header. The parsed |
| 23 // values will be stored in the |*values| argument. |
| 24 // |
| 25 // https://tools.ietf.org/html/draft-thomson-http-encryption-01#section-3 |
| 26 // |
| 27 // This header follows the #list syntax from the extended ABNF syntax |
| 28 // defined in section 1.2 of RFC 7230: |
| 29 // |
| 30 // https://tools.ietf.org/html/rfc7230#section-1.2 |
| 31 // |
| 32 // Returns whether the |input| could be successfully parsed, and the resulting |
| 33 // values are now available in the |*values| argument. Does not modify |*values| |
| 34 // unless parsing was successful. |
| 35 bool ParseEncryptionHeader(const std::string& input, |
| 36 std::vector<EncryptionHeaderValues>* values); |
| 37 |
| 38 // Structure representing the parsed values from the Encryption-Key HTTP header. |
| 39 // |key| and |dh| are stored after having been base64url decoded. |
| 40 struct EncryptionKeyHeaderValues { |
| 41 std::string keyid; |
| 42 std::string key; |
| 43 std::string dh; |
| 44 }; |
| 45 |
| 46 // Parses |input| following the syntax of the Encryption-Key HTTP header. The |
| 47 // parsed values will be stored in the |*values| argument. |
| 48 // |
| 49 // https://tools.ietf.org/html/draft-thomson-http-encryption-01#section-4 |
| 50 // |
| 51 // This header follows the #list syntax from the extended ABNF syntax |
| 52 // defined in section 1.2 of RFC 7230: |
| 53 // |
| 54 // https://tools.ietf.org/html/rfc7230#section-1.2 |
| 55 // |
| 56 // Returns whether the |input| could be successfully parsed, and the resulting |
| 57 // values are now available in the |*values| argument. Does not modify |*values| |
| 58 // unless parsing was successful. |
| 59 bool ParseEncryptionKeyHeader(const std::string& input, |
| 60 std::vector<EncryptionKeyHeaderValues>* values); |
| 61 |
| 62 } // namespace gcm |
| 63 |
| 64 #endif // COMPONENTS_GCM_DRIVER_CRYPTO_ENCRYPTION_HEADER_PARSERS_H_ |
OLD | NEW |