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 19 matching lines...) Expand all Loading... | |
30 // Note that while this class is not responsible for creating or storing the | 30 // Note that while this class is not responsible for creating or storing the |
31 // actual keys, it uses a key derivation function for the actual message | 31 // actual keys, it uses a key derivation function for the actual message |
32 // encryption/decryption, thus allowing for the safe re-use of keys in multiple | 32 // encryption/decryption, thus allowing for the safe re-use of keys in multiple |
33 // messages provided that a cryptographically-strong random salt is used. | 33 // messages provided that a cryptographically-strong random salt is used. |
34 class GCMMessageCryptographer { | 34 class GCMMessageCryptographer { |
35 public: | 35 public: |
36 // Salt size, in bytes, that will be used together with the key to create a | 36 // Salt size, in bytes, that will be used together with the key to create a |
37 // unique content encryption key for a given message. | 37 // unique content encryption key for a given message. |
38 static const size_t kSaltSize; | 38 static const size_t kSaltSize; |
39 | 39 |
40 // Label of the encryption group used to calculate the shared secret. | 40 // Creates a new cryptographer, identifying the group used forthe key |
johnme
2017/01/10 18:10:52
s/forthe/for the/
Peter Beverloo
2017/01/10 18:11:52
Done.
| |
41 enum class Label { | 41 // agreement, and the public keys of both the recipient and sender. |
42 P256 | 42 GCMMessageCryptographer(const base::StringPiece& recipient_public_key, |
43 }; | |
44 | |
45 // Creates a new cryptographer with |label|, identifying the group used for | |
46 // the key agreement, and the public keys of both the recipient and sender. | |
47 GCMMessageCryptographer(Label label, | |
48 const base::StringPiece& recipient_public_key, | |
49 const base::StringPiece& sender_public_key, | 43 const base::StringPiece& sender_public_key, |
50 const std::string& auth_secret); | 44 const std::string& auth_secret); |
51 | 45 |
52 ~GCMMessageCryptographer(); | 46 ~GCMMessageCryptographer(); |
53 | 47 |
54 // Encrypts |plaintext| using the |ikm| and the |salt|, both of which must be | 48 // Encrypts |plaintext| using the |ikm| and the |salt|, both of which must be |
55 // 16 octets in length. The |plaintext| will be written to a single record, | 49 // 16 octets in length. The |plaintext| will be written to a single record, |
56 // and will include a 16 octet authentication tag. The encrypted result will | 50 // and will include a 16 octet authentication tag. The encrypted result will |
57 // be written to |ciphertext|, the record size to |record_size|. This | 51 // be written to |ciphertext|, the record size to |record_size|. This |
58 // implementation does not support prepending padding to the |plaintext|. | 52 // implementation does not support prepending padding to the |plaintext|. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 bool allow_empty_auth_secret_for_tests_ = false; | 111 bool allow_empty_auth_secret_for_tests_ = false; |
118 | 112 |
119 void set_allow_empty_auth_secret_for_tests(bool value) { | 113 void set_allow_empty_auth_secret_for_tests(bool value) { |
120 allow_empty_auth_secret_for_tests_ = value; | 114 allow_empty_auth_secret_for_tests_ = value; |
121 } | 115 } |
122 }; | 116 }; |
123 | 117 |
124 } // namespace gcm | 118 } // namespace gcm |
125 | 119 |
126 #endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_MESSAGE_CRYPTOGRAPHER_H_ | 120 #endif // COMPONENTS_GCM_DRIVER_CRYPTO_GCM_MESSAGE_CRYPTOGRAPHER_H_ |
OLD | NEW |