OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CRYPTO_MOCK_KEYCHAIN_MAC_H_ | 5 #ifndef CRYPTO_MOCK_KEYCHAIN_MAC_H_ |
6 #define CRYPTO_MOCK_KEYCHAIN_MAC_H_ | 6 #define CRYPTO_MOCK_KEYCHAIN_MAC_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 UInt32 accountNameLength, | 144 UInt32 accountNameLength, |
145 const char* accountName, | 145 const char* accountName, |
146 UInt32 pathLength, | 146 UInt32 pathLength, |
147 const char* path, | 147 const char* path, |
148 UInt16 port, | 148 UInt16 port, |
149 SecProtocolType protocol, | 149 SecProtocolType protocol, |
150 SecAuthenticationType authenticationType) const; | 150 SecAuthenticationType authenticationType) const; |
151 // Initializes storage for keychain data at |key|. | 151 // Initializes storage for keychain data at |key|. |
152 void InitializeKeychainData(unsigned int key) const; | 152 void InitializeKeychainData(unsigned int key) const; |
153 // Sets the data and length of |tag| in the item-th test item. | 153 // Sets the data and length of |tag| in the item-th test item. |
154 void SetTestDataBytes(int item, UInt32 tag, const void* data, size_t length); | 154 void SetTestDataBytes(unsigned int item, UInt32 tag, |
| 155 const void* data, size_t length); |
155 // Sets the data and length of |tag| in the item-th test item based on | 156 // Sets the data and length of |tag| in the item-th test item based on |
156 // |value|. The null-terminator will not be included; the Keychain Services | 157 // |value|. The null-terminator will not be included; the Keychain Services |
157 // docs don't indicate whether it is or not, so clients should not assume | 158 // docs don't indicate whether it is or not, so clients should not assume |
158 // that it will be. | 159 // that it will be. |
159 void SetTestDataString(int item, UInt32 tag, const char* value); | 160 void SetTestDataString(unsigned int item, UInt32 tag, const char* value); |
160 // Sets the data of the corresponding attribute of the item-th test item to | 161 // Sets the data of the corresponding attribute of the item-th test item to |
161 // |value|. Assumes that the space has alread been allocated, and the length | 162 // |value|. Assumes that the space has alread been allocated, and the length |
162 // set. | 163 // set. |
163 void SetTestDataPort(int item, UInt32 value); | 164 void SetTestDataPort(unsigned int item, UInt32 value); |
164 void SetTestDataProtocol(int item, SecProtocolType value); | 165 void SetTestDataProtocol(unsigned int item, SecProtocolType value); |
165 void SetTestDataAuthType(int item, SecAuthenticationType value); | 166 void SetTestDataAuthType(unsigned int item, SecAuthenticationType value); |
166 void SetTestDataNegativeItem(int item, Boolean value); | 167 void SetTestDataNegativeItem(unsigned int item, Boolean value); |
167 void SetTestDataCreator(int item, OSType value); | 168 void SetTestDataCreator(unsigned int item, OSType value); |
168 // Sets the password data and length for the item-th test item. | 169 // Sets the password data and length for the item-th test item. |
169 void SetTestDataPasswordBytes(int item, const void* data, size_t length); | 170 void SetTestDataPasswordBytes(unsigned int item, const void* data, size_t leng
th); |
170 // Sets the password for the item-th test item. As with SetTestDataString, | 171 // Sets the password for the item-th test item. As with SetTestDataString, |
171 // the data will not be null-terminated. | 172 // the data will not be null-terminated. |
172 void SetTestDataPasswordString(int item, const char* value); | 173 void SetTestDataPasswordString(unsigned int item, const char* value); |
173 | 174 |
174 // Returns the address of the attribute in attribute_list with tag |tag|. | 175 // Returns the address of the attribute in attribute_list with tag |tag|. |
175 static SecKeychainAttribute* AttributeWithTag( | 176 static SecKeychainAttribute* AttributeWithTag( |
176 const SecKeychainAttributeList& attribute_list, | 177 const SecKeychainAttributeList& attribute_list, |
177 UInt32 tag); | 178 UInt32 tag); |
178 | 179 |
179 static const int kDummySearchRef = 1000; | 180 static const unsigned int kDummySearchRef = 1000; |
180 | 181 |
181 typedef struct KeychainPasswordData { | 182 typedef struct KeychainPasswordData { |
182 KeychainPasswordData() : data(NULL), length(0) {} | 183 KeychainPasswordData() : data(NULL), length(0) {} |
183 void* data; | 184 void* data; |
184 UInt32 length; | 185 UInt32 length; |
185 } KeychainPasswordData; | 186 } KeychainPasswordData; |
186 | 187 |
187 // Mutable because the MockKeychain API requires its internal keychain storage | 188 // Mutable because the MockKeychain API requires its internal keychain storage |
188 // to be modifiable by users of this class. | 189 // to be modifiable by users of this class. |
189 mutable std::map<unsigned int, SecKeychainAttributeList> keychain_attr_list_; | 190 mutable std::map<unsigned int, SecKeychainAttributeList> keychain_attr_list_; |
(...skipping 26 matching lines...) Expand all Loading... |
216 // and |ItemFreeContent|. | 217 // and |ItemFreeContent|. |
217 mutable unsigned int password_data_count_; | 218 mutable unsigned int password_data_count_; |
218 | 219 |
219 // Records the password being set when |AddGenericPassword()| gets called. | 220 // Records the password being set when |AddGenericPassword()| gets called. |
220 mutable std::string add_generic_password_; | 221 mutable std::string add_generic_password_; |
221 }; | 222 }; |
222 | 223 |
223 } // namespace crypto | 224 } // namespace crypto |
224 | 225 |
225 #endif // CRYPTO_MOCK_KEYCHAIN_MAC_H_ | 226 #endif // CRYPTO_MOCK_KEYCHAIN_MAC_H_ |
OLD | NEW |