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_encrypter.h" | 5 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" |
6 | 6 |
7 #include <pk11pub.h> | 7 #include <pk11pub.h> |
8 #include <secerr.h> | 8 #include <secerr.h> |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 202 |
203 *out_len = output_len + Aes128Gcm12Encrypter::kAuthTagSize; | 203 *out_len = output_len + Aes128Gcm12Encrypter::kAuthTagSize; |
204 return SECSuccess; | 204 return SECSuccess; |
205 } | 205 } |
206 | 206 |
207 } // namespace | 207 } // namespace |
208 | 208 |
209 Aes128Gcm12Encrypter::Aes128Gcm12Encrypter() | 209 Aes128Gcm12Encrypter::Aes128Gcm12Encrypter() |
210 : AeadBaseEncrypter(CKM_AES_GCM, My_Encrypt, kKeySize, kAuthTagSize, | 210 : AeadBaseEncrypter(CKM_AES_GCM, My_Encrypt, kKeySize, kAuthTagSize, |
211 kNoncePrefixSize) { | 211 kNoncePrefixSize) { |
212 COMPILE_ASSERT(kKeySize <= kMaxKeySize, key_size_too_big); | 212 static_assert(kKeySize <= kMaxKeySize, "key size too big"); |
213 COMPILE_ASSERT(kNoncePrefixSize <= kMaxNoncePrefixSize, | 213 static_assert(kNoncePrefixSize <= kMaxNoncePrefixSize, |
214 nonce_prefix_size_too_big); | 214 "nonce prefix size too big"); |
215 ignore_result(g_gcm_support_checker.Get()); | 215 ignore_result(g_gcm_support_checker.Get()); |
216 } | 216 } |
217 | 217 |
218 Aes128Gcm12Encrypter::~Aes128Gcm12Encrypter() {} | 218 Aes128Gcm12Encrypter::~Aes128Gcm12Encrypter() {} |
219 | 219 |
220 void Aes128Gcm12Encrypter::FillAeadParams(StringPiece nonce, | 220 void Aes128Gcm12Encrypter::FillAeadParams(StringPiece nonce, |
221 StringPiece associated_data, | 221 StringPiece associated_data, |
222 size_t auth_tag_size, | 222 size_t auth_tag_size, |
223 AeadParams* aead_params) const { | 223 AeadParams* aead_params) const { |
224 aead_params->len = sizeof(aead_params->data.gcm_params); | 224 aead_params->len = sizeof(aead_params->data.gcm_params); |
225 CK_GCM_PARAMS* gcm_params = &aead_params->data.gcm_params; | 225 CK_GCM_PARAMS* gcm_params = &aead_params->data.gcm_params; |
226 gcm_params->pIv = | 226 gcm_params->pIv = |
227 reinterpret_cast<CK_BYTE*>(const_cast<char*>(nonce.data())); | 227 reinterpret_cast<CK_BYTE*>(const_cast<char*>(nonce.data())); |
228 gcm_params->ulIvLen = nonce.size(); | 228 gcm_params->ulIvLen = nonce.size(); |
229 gcm_params->pAAD = | 229 gcm_params->pAAD = |
230 reinterpret_cast<CK_BYTE*>(const_cast<char*>(associated_data.data())); | 230 reinterpret_cast<CK_BYTE*>(const_cast<char*>(associated_data.data())); |
231 gcm_params->ulAADLen = associated_data.size(); | 231 gcm_params->ulAADLen = associated_data.size(); |
232 gcm_params->ulTagBits = auth_tag_size * 8; | 232 gcm_params->ulTagBits = auth_tag_size * 8; |
233 } | 233 } |
234 | 234 |
235 } // namespace net | 235 } // namespace net |
OLD | NEW |