| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef COMPONENTS_GCM_DRIVER_CRYPTO_GCM_MESSAGE_CRYPTOGRAPHER_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_CRYPTO_GCM_MESSAGE_CRYPTOGRAPHER_H_ |
| 6 #define COMPONENTS_GCM_DRIVER_CRYPTO_GCM_MESSAGE_CRYPTOGRAPHER_H_ | 6 #define COMPONENTS_GCM_DRIVER_CRYPTO_GCM_MESSAGE_CRYPTOGRAPHER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 FRIEND_TEST_ALL_PREFIXES(GCMMessageCryptographerTest, InvalidRecordPadding); | 76 FRIEND_TEST_ALL_PREFIXES(GCMMessageCryptographerTest, InvalidRecordPadding); |
| 77 FRIEND_TEST_ALL_PREFIXES(GCMMessageCryptographerTest, NonceGeneration); | 77 FRIEND_TEST_ALL_PREFIXES(GCMMessageCryptographerTest, NonceGeneration); |
| 78 friend class GCMMessageCryptographerReferenceTest; | 78 friend class GCMMessageCryptographerReferenceTest; |
| 79 | 79 |
| 80 // Size, in bytes, of the authentication tag included in the messages. | 80 // Size, in bytes, of the authentication tag included in the messages. |
| 81 static const size_t kAuthenticationTagBytes; | 81 static const size_t kAuthenticationTagBytes; |
| 82 | 82 |
| 83 enum Mode { ENCRYPT, DECRYPT }; | 83 enum Mode { ENCRYPT, DECRYPT }; |
| 84 | 84 |
| 85 // Private implementation of the encryption and decryption routines, provided | 85 // Private implementation of the encryption and decryption routines, provided |
| 86 // by either NSS or BoringSSL depending on the platform. | 86 // by BoringSSL. |
| 87 bool EncryptDecryptRecordInternal(Mode mode, | 87 bool EncryptDecryptRecordInternal(Mode mode, |
| 88 const base::StringPiece& input, | 88 const base::StringPiece& input, |
| 89 const base::StringPiece& key, | 89 const base::StringPiece& key, |
| 90 const base::StringPiece& nonce, | 90 const base::StringPiece& nonce, |
| 91 std::string* output) const; | 91 std::string* output) const; |
| 92 | 92 |
| 93 // Derives the pseuro random key (PRK) to use for deriving the content | 93 // Derives the pseuro random key (PRK) to use for deriving the content |
| 94 // encryption key and the nonce. If |auth_secret_| is not the empty string, | 94 // encryption key and the nonce. If |auth_secret_| is not the empty string, |
| 95 // another HKDF will be invoked between the |key| and the |auth_secret_|. | 95 // another HKDF will be invoked between the |key| and the |auth_secret_|. |
| 96 std::string DerivePseudoRandomKey(const base::StringPiece& ikm) const; | 96 std::string DerivePseudoRandomKey(const base::StringPiece& ikm) const; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 117 bool allow_empty_auth_secret_for_tests_ = false; | 117 bool allow_empty_auth_secret_for_tests_ = false; |
| 118 | 118 |
| 119 void set_allow_empty_auth_secret_for_tests(bool value) { | 119 void set_allow_empty_auth_secret_for_tests(bool value) { |
| 120 allow_empty_auth_secret_for_tests_ = value; | 120 allow_empty_auth_secret_for_tests_ = value; |
| 121 } | 121 } |
| 122 }; | 122 }; |
| 123 | 123 |
| 124 } // namespace gcm | 124 } // namespace gcm |
| 125 | 125 |
| 126 #endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_MESSAGE_CRYPTOGRAPHER_H_ | 126 #endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_MESSAGE_CRYPTOGRAPHER_H_ |
| OLD | NEW |