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

Method authenticate

src/auth/SecureRemotePassword/server/SrpServer.cpp:262–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260
261
262int SrpServer::authenticate(CheckStatusWrapper* status, IServerBlock* sb, IWriter* writerInterface)
263{
264 try
265 {
266 if (!server)
267 {
268 HANDSHAKE_DEBUG(fprintf(stderr, "Srv: SRP phase1\n"));
269
270 if (!sb->getLogin())
271 {
272 return AUTH_CONTINUE;
273 }
274
275 account = sb->getLogin();
276
277 const size_t len = account.length();
278 if (len > SZ_LOGIN)
279 status_exception::raise(Arg::Gds(isc_long_login) << Arg::Num(len) << Arg::Num(SZ_LOGIN));
280
281 unsigned int length;
282 const unsigned char* val = sb->getData(&length);
283 clientPubKey.assign(val, length);
284 dumpBin("Srv: clientPubKey", clientPubKey);
285
286 if (!clientPubKey.hasData())
287 {
288 HANDSHAKE_DEBUG(fprintf(stderr, "Srv: SRP: empty pubkey AUTH_MORE_DATA\n"));
289 return AUTH_MORE_DATA;
290 }
291
292 // load verifier and salt from security database
293 Metadata messages;
294 messages.param->login.set(account.c_str());
295 messages.param->loginNull = 0;
296 messages.data.clear();
297
298 { // instance RAII scope
299 CachedSecurityDatabase::Instance instance;
300
301 // Get database block from cache
302 instances->getInstance(iParameter, instance);
303 secDbName = instance->secureDbName;
304
305 // Create SecurityDatabase if needed
306 if (!instance->secDb)
307 instance->secDb = FB_NEW SecurityDatabase(instance, cryptCallback);
308
309 // Lookup
310 instance->secDb->lookup(messages.param.getData(), messages.data.getData());
311 }
312 HANDSHAKE_DEBUG(fprintf(stderr, "Srv: SRP1: Executed statement\n"));
313
314 verifier.assign(reinterpret_cast<const UCHAR*>(messages.data->verifier.str), messages.data->verifier.length);
315 dumpIt("Srv: verifier", verifier);
316
317 UCharBuffer s;
318 s.assign(reinterpret_cast<const UCHAR*>(messages.data->salt.str), messages.data->salt.length);
319 BigInteger(s).getText(salt);

Callers

nothing calls this directly

Calls 15

raiseFunction · 0.85
GdsClass · 0.85
NumClass · 0.85
BigIntegerClass · 0.85
genServerKeyMethod · 0.80
serverSessionKeyMethod · 0.80
clientProofMethod · 0.80
SecurityDatabaseClass · 0.70
dumpBinFunction · 0.50
dumpItFunction · 0.50
getLoginMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected