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 <algorithm> | 7 #include <algorithm> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 std::stringstream info_stream; | 48 std::stringstream info_stream; |
49 info_stream << "Content-Encoding: " << content_encoding << '\x00'; | 49 info_stream << "Content-Encoding: " << content_encoding << '\x00'; |
50 | 50 |
51 switch (label) { | 51 switch (label) { |
52 case GCMMessageCryptographer::Label::P256: | 52 case GCMMessageCryptographer::Label::P256: |
53 info_stream << "P-256" << '\x00'; | 53 info_stream << "P-256" << '\x00'; |
54 break; | 54 break; |
55 } | 55 } |
56 | 56 |
57 uint16_t local_len = base::HostToNet16(recipient_public_key.size()); | 57 uint16_t local_len = |
| 58 base::HostToNet16(static_cast<uint16_t>(recipient_public_key.size())); |
58 info_stream.write(reinterpret_cast<char*>(&local_len), sizeof(local_len)); | 59 info_stream.write(reinterpret_cast<char*>(&local_len), sizeof(local_len)); |
59 info_stream << recipient_public_key; | 60 info_stream << recipient_public_key; |
60 | 61 |
61 uint16_t peer_len = base::HostToNet16(sender_public_key.size()); | 62 uint16_t peer_len = |
| 63 base::HostToNet16(static_cast<uint16_t>(sender_public_key.size())); |
62 info_stream.write(reinterpret_cast<char*>(&peer_len), sizeof(peer_len)); | 64 info_stream.write(reinterpret_cast<char*>(&peer_len), sizeof(peer_len)); |
63 info_stream << sender_public_key; | 65 info_stream << sender_public_key; |
64 | 66 |
65 return info_stream.str(); | 67 return info_stream.str(); |
66 } | 68 } |
67 | 69 |
68 } // namespace | 70 } // namespace |
69 | 71 |
70 const size_t GCMMessageCryptographer::kAuthenticationTagBytes = 16; | 72 const size_t GCMMessageCryptographer::kAuthenticationTagBytes = 16; |
71 const size_t GCMMessageCryptographer::kSaltSize = 16; | 73 const size_t GCMMessageCryptographer::kSaltSize = 16; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 0 /* subkey_secret_bytes_to_generate */); | 231 0 /* subkey_secret_bytes_to_generate */); |
230 | 232 |
231 // draft-thomson-http-encryption defines that the result should be XOR'ed with | 233 // draft-thomson-http-encryption defines that the result should be XOR'ed with |
232 // the record's sequence number, however, Web Push encryption is limited to a | 234 // the record's sequence number, however, Web Push encryption is limited to a |
233 // single record per draft-ietf-webpush-encryption. | 235 // single record per draft-ietf-webpush-encryption. |
234 | 236 |
235 return hkdf.client_write_key().as_string(); | 237 return hkdf.client_write_key().as_string(); |
236 } | 238 } |
237 | 239 |
238 } // namespace gcm | 240 } // namespace gcm |
OLD | NEW |