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 #include "components/gcm_driver/crypto/gcm_message_cryptographer.h" | 5 #include "components/gcm_driver/crypto/gcm_message_cryptographer.h" |
6 | 6 |
7 #include <openssl/aead.h> | |
8 #include <stddef.h> | 7 #include <stddef.h> |
9 #include <stdint.h> | 8 #include <stdint.h> |
10 | 9 |
11 #include <algorithm> | 10 #include <algorithm> |
12 #include <sstream> | 11 #include <sstream> |
13 | 12 |
14 #include "base/logging.h" | 13 #include "base/logging.h" |
15 #include "base/numerics/safe_math.h" | 14 #include "base/numerics/safe_math.h" |
16 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
17 #include "base/sys_byteorder.h" | 16 #include "base/sys_byteorder.h" |
18 #include "crypto/hkdf.h" | 17 #include "crypto/hkdf.h" |
| 18 #include "third_party/boringssl/src/include/openssl/aead.h" |
19 | 19 |
20 namespace gcm { | 20 namespace gcm { |
21 namespace { | 21 namespace { |
22 | 22 |
23 // Size, in bytes, of the nonce for a record. This must be at least the size | 23 // Size, in bytes, of the nonce for a record. This must be at least the size |
24 // of a uint64_t, which is used to indicate the record sequence number. | 24 // of a uint64_t, which is used to indicate the record sequence number. |
25 const uint64_t kNonceSize = 12; | 25 const uint64_t kNonceSize = 12; |
26 | 26 |
27 // The default record size as defined by draft-thomson-http-encryption. | 27 // The default record size as defined by draft-thomson-http-encryption. |
28 const size_t kDefaultRecordSize = 4096; | 28 const size_t kDefaultRecordSize = 4096; |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 0 /* subkey_secret_bytes_to_generate */); | 298 0 /* subkey_secret_bytes_to_generate */); |
299 | 299 |
300 // draft-thomson-http-encryption defines that the result should be XOR'ed with | 300 // draft-thomson-http-encryption defines that the result should be XOR'ed with |
301 // the record's sequence number, however, Web Push encryption is limited to a | 301 // the record's sequence number, however, Web Push encryption is limited to a |
302 // single record per draft-ietf-webpush-encryption. | 302 // single record per draft-ietf-webpush-encryption. |
303 | 303 |
304 return hkdf.client_write_key().as_string(); | 304 return hkdf.client_write_key().as_string(); |
305 } | 305 } |
306 | 306 |
307 } // namespace gcm | 307 } // namespace gcm |
OLD | NEW |