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