MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / setKey

Method setKey

examples/dbcrypt/DbCrypt.cpp:188–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186}
187
188void 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);

Callers

nothing calls this directly

Calls 9

initMethod · 0.45
getDefaultConfigMethod · 0.45
getStateMethod · 0.45
findMethod · 0.45
releaseMethod · 0.45
getValueMethod · 0.45
getIntValueMethod · 0.45
keyHandleMethod · 0.45
callbackMethod · 0.45

Tested by

no test coverage detected