| 186 | } |
| 187 | |
| 188 | void DbCrypt::setKey(CheckStatusWrapper* status, unsigned int length, IKeyHolderPlugin** sources, |
| 189 | const char* keyName) |
| 190 | { |
| 191 | status->init(); |
| 192 | |
| 193 | if (key != 0) |
| 194 | return; |
| 195 | |
| 196 | strncpy(savedKeyName, (keyName ? keyName : ""), sizeof(savedKeyName)); |
| 197 | savedKeyName[sizeof(savedKeyName) - 1] = 0; |
| 198 | |
| 199 | IConfig* def = config->getDefaultConfig(status); |
| 200 | if (status->getState() & Firebird::IStatus::STATE_ERRORS) |
| 201 | return; |
| 202 | |
| 203 | IConfigEntry* confEntry = def->find(status, "Auto"); |
| 204 | if (status->getState() & Firebird::IStatus::STATE_ERRORS) |
| 205 | { |
| 206 | def->release(); |
| 207 | return; |
| 208 | } |
| 209 | |
| 210 | if (confEntry) |
| 211 | { |
| 212 | char v = *(confEntry->getValue()); |
| 213 | confEntry->release(); |
| 214 | if (v == '1' || v == 'y' || v == 'Y' || v == 't' || v == 'T') |
| 215 | { |
| 216 | confEntry = def->find(status, "Value"); |
| 217 | def->release(); |
| 218 | if (confEntry) |
| 219 | { |
| 220 | v = confEntry->getIntValue(); |
| 221 | confEntry->release(); |
| 222 | if (v) |
| 223 | { |
| 224 | key = v; |
| 225 | return; |
| 226 | } |
| 227 | } |
| 228 | key = 0x5a; |
| 229 | return; |
| 230 | } |
| 231 | def->release(); |
| 232 | } |
| 233 | |
| 234 | for (unsigned n = 0; n < length; ++n) |
| 235 | { |
| 236 | ICryptKeyCallback* callback = sources[n]->keyHandle(status, savedKeyName); |
| 237 | if (status->getState() & Firebird::IStatus::STATE_ERRORS) |
| 238 | return; |
| 239 | |
| 240 | if (callback && callback->callback(0, NULL, 1, &key) == 1) |
| 241 | return; |
| 242 | } |
| 243 | |
| 244 | key = 0; |
| 245 | noKeyError(status); |
nothing calls this directly
no test coverage detected