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 <nss.h> | 7 #include <nss.h> |
8 #include <pk11pub.h> | 8 #include <pk11pub.h> |
9 #include <secerr.h> | 9 #include <secerr.h> |
10 | 10 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 // static | 98 // static |
99 PK11_DecryptFunction GcmSupportChecker::pk11_decrypt_func_ = NULL; | 99 PK11_DecryptFunction GcmSupportChecker::pk11_decrypt_func_ = NULL; |
100 | 100 |
101 // static | 101 // static |
102 CK_MECHANISM_TYPE GcmSupportChecker::aes_key_mechanism_ = CKM_AES_GCM; | 102 CK_MECHANISM_TYPE GcmSupportChecker::aes_key_mechanism_ = CKM_AES_GCM; |
103 | 103 |
104 base::LazyInstance<GcmSupportChecker>::Leaky g_gcm_support_checker = | 104 base::LazyInstance<GcmSupportChecker>::Leaky g_gcm_support_checker = |
105 LAZY_INSTANCE_INITIALIZER; | 105 LAZY_INSTANCE_INITIALIZER; |
106 | 106 |
107 const size_t kKeySize = 16; | |
108 const size_t kNoncePrefixSize = 4; | 107 const size_t kNoncePrefixSize = 4; |
109 const size_t kAESNonceSize = 12; | 108 const size_t kAESNonceSize = 12; |
110 | 109 |
111 // Calls PK11_Decrypt if it's available. Otherwise, emulates CKM_AES_GCM using | 110 // Calls PK11_Decrypt if it's available. Otherwise, emulates CKM_AES_GCM using |
112 // CKM_AES_CTR and the GaloisHash class. | 111 // CKM_AES_CTR and the GaloisHash class. |
113 SECStatus My_Decrypt(PK11SymKey* key, | 112 SECStatus My_Decrypt(PK11SymKey* key, |
114 CK_MECHANISM_TYPE mechanism, | 113 CK_MECHANISM_TYPE mechanism, |
115 SECItem* param, | 114 SECItem* param, |
116 unsigned char* out, | 115 unsigned char* out, |
117 unsigned int* out_len, | 116 unsigned int* out_len, |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 StringPiece Aes128Gcm12Decrypter::GetKey() const { | 377 StringPiece Aes128Gcm12Decrypter::GetKey() const { |
379 return StringPiece(reinterpret_cast<const char*>(key_), sizeof(key_)); | 378 return StringPiece(reinterpret_cast<const char*>(key_), sizeof(key_)); |
380 } | 379 } |
381 | 380 |
382 StringPiece Aes128Gcm12Decrypter::GetNoncePrefix() const { | 381 StringPiece Aes128Gcm12Decrypter::GetNoncePrefix() const { |
383 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_), | 382 return StringPiece(reinterpret_cast<const char*>(nonce_prefix_), |
384 kNoncePrefixSize); | 383 kNoncePrefixSize); |
385 } | 384 } |
386 | 385 |
387 } // namespace net | 386 } // namespace net |
OLD | NEW |