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 #include <pk11pub.h> |
| 8 |
| 9 #include "base/logging.h" |
| 10 |
| 11 using base::StringPiece; |
| 12 |
| 13 namespace net { |
| 14 |
| 15 namespace { |
| 16 |
| 17 const size_t kKeySize = 32; |
| 18 const size_t kNoncePrefixSize = 0; |
| 19 |
| 20 } // namespace |
| 21 |
| 22 #if defined(USE_NSS) |
| 23 |
| 24 // System NSS doesn't support ChaCha20+Poly1305 yet. |
| 25 |
| 26 ChaCha20Poly1305Encrypter::ChaCha20Poly1305Encrypter() |
| 27 : AeadBaseEncrypter(CKM_INVALID_MECHANISM, NULL, kKeySize, |
| 28 kAuthTagSize, kNoncePrefixSize) { |
| 29 NOTIMPLEMENTED(); |
| 30 } |
| 31 |
| 32 ChaCha20Poly1305Encrypter::~ChaCha20Poly1305Encrypter() {} |
| 33 |
| 34 // static |
| 35 bool ChaCha20Poly1305Encrypter::IsSupported() { |
| 36 return false; |
| 37 } |
| 38 |
| 39 void ChaCha20Poly1305Encrypter::FillAeadParams(StringPiece nonce, |
| 40 StringPiece associated_data, |
| 41 size_t auth_tag_size, |
| 42 AeadParams* aead_params) const { |
| 43 NOTIMPLEMENTED(); |
| 44 } |
| 45 |
| 46 #else // defined(USE_NSS) |
| 47 |
| 48 ChaCha20Poly1305Encrypter::ChaCha20Poly1305Encrypter() |
| 49 : AeadBaseEncrypter(CKM_NSS_CHACHA20_POLY1305, PK11_Encrypt, kKeySize, |
| 50 kAuthTagSize, kNoncePrefixSize) { |
| 51 COMPILE_ASSERT(kKeySize <= kMaxKeySize, key_size_too_big); |
| 52 COMPILE_ASSERT(kNoncePrefixSize <= kMaxNoncePrefixSize, |
| 53 nonce_prefix_size_too_big); |
| 54 } |
| 55 |
| 56 ChaCha20Poly1305Encrypter::~ChaCha20Poly1305Encrypter() {} |
| 57 |
| 58 // static |
| 59 bool ChaCha20Poly1305Encrypter::IsSupported() { |
| 60 // TODO(wtc): return true when FillAeadParams is implemented. |
| 61 return false; |
| 62 } |
| 63 |
| 64 void ChaCha20Poly1305Encrypter::FillAeadParams(StringPiece nonce, |
| 65 StringPiece associated_data, |
| 66 size_t auth_tag_size, |
| 67 AeadParams* aead_params) const { |
| 68 // TODO(wtc): implement this. |
| 69 NOTIMPLEMENTED(); |
| 70 } |
| 71 |
| 72 #endif // defined(USE_NSS) |
| 73 |
| 74 } // namespace net |
OLD | NEW |