OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/quic/crypto/chacha20_poly1305_encrypter.h" |
| 6 |
| 7 // This is a bodge to allow this code to be compiled against system NSS |
| 8 // headers. |
| 9 #if defined(USE_NSS) |
| 10 #define CKM_NSS_CHACHA20_POLY1305 (CKM_NSS + 26) |
| 11 #endif |
| 12 |
| 13 using base::StringPiece; |
| 14 |
| 15 namespace net { |
| 16 |
| 17 namespace { |
| 18 |
| 19 const size_t kKeySize = 32; |
| 20 const size_t kNoncePrefixSize = 0; |
| 21 |
| 22 } // namespace |
| 23 |
| 24 ChaCha20Poly1305Encrypter::ChaCha20Poly1305Encrypter() |
| 25 : AeadBaseEncrypter(CKM_NSS_CHACHA20_POLY1305, kKeySize, kAuthTagSize, |
| 26 kNoncePrefixSize) { |
| 27 COMPILE_ASSERT(kKeySize <= kMaxKeySize, key_size_too_big); |
| 28 COMPILE_ASSERT(kNoncePrefixSize <= kMaxNoncePrefixSize, |
| 29 nonce_prefix_size_too_big); |
| 30 } |
| 31 |
| 32 ChaCha20Poly1305Encrypter::~ChaCha20Poly1305Encrypter() {} |
| 33 |
| 34 // static |
| 35 bool ChaCha20Poly1305Encrypter::IsSupported() { |
| 36 #if defined(USE_NSS) |
| 37 // System NSS doesn't support ChaCha20+Poly1305 yet. |
| 38 return false; |
| 39 #else |
| 40 // TODO(wtc): return true when FillAeadParams is implemented. |
| 41 return false; |
| 42 #endif |
| 43 } |
| 44 |
| 45 void ChaCha20Poly1305Encrypter::FillAeadParams(StringPiece nonce, |
| 46 StringPiece associated_data, |
| 47 size_t auth_tag_size, |
| 48 AeadParams* aead_params) const { |
| 49 // TODO(wtc): implement this. |
| 50 } |
| 51 |
| 52 } // namespace net |
OLD | NEW |