OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "net/quic/crypto/aes_128_gcm_12_decrypter.h" | 5 #include "net/quic/crypto/aes_128_gcm_12_decrypter.h" |
6 | 6 |
7 #include <openssl/evp.h> | 7 #include <openssl/evp.h> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 | 10 |
11 using base::StringPiece; | 11 using base::StringPiece; |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 | 14 |
15 namespace { | |
16 | |
17 const size_t kKeySize = 16; | |
18 const size_t kNoncePrefixSize = 4; | 15 const size_t kNoncePrefixSize = 4; |
19 const size_t kAESNonceSize = 12; | 16 const size_t kAESNonceSize = 12; |
20 | 17 |
21 } // namespace | |
22 | |
23 Aes128Gcm12Decrypter::Aes128Gcm12Decrypter() {} | 18 Aes128Gcm12Decrypter::Aes128Gcm12Decrypter() {} |
24 | 19 |
25 Aes128Gcm12Decrypter::~Aes128Gcm12Decrypter() {} | 20 Aes128Gcm12Decrypter::~Aes128Gcm12Decrypter() {} |
26 | 21 |
27 // static | 22 // static |
28 bool Aes128Gcm12Decrypter::IsSupported() { return true; } | 23 bool Aes128Gcm12Decrypter::IsSupported() { return true; } |
29 | 24 |
30 bool Aes128Gcm12Decrypter::SetKey(StringPiece key) { | 25 bool Aes128Gcm12Decrypter::SetKey(StringPiece key) { |
31 DCHECK_EQ(key.size(), sizeof(key_)); | 26 DCHECK_EQ(key.size(), sizeof(key_)); |
32 if (key.size() != sizeof(key_)) { | 27 if (key.size() != sizeof(key_)) { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 StringPiece Aes128Gcm12Decrypter::GetKey() const { | 138 StringPiece Aes128Gcm12Decrypter::GetKey() const { |
144 return StringPiece(reinterpret_cast<const char*>(key_), sizeof(key_)); | 139 return StringPiece(reinterpret_cast<const char*>(key_), sizeof(key_)); |
145 } | 140 } |
146 | 141 |
147 StringPiece Aes128Gcm12Decrypter::GetNoncePrefix() const { | 142 StringPiece Aes128Gcm12Decrypter::GetNoncePrefix() const { |
148 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_), | 143 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_), |
149 kNoncePrefixSize); | 144 kNoncePrefixSize); |
150 } | 145 } |
151 | 146 |
152 } // namespace net | 147 } // namespace net |
OLD | NEW |