| 3 | using namespace Auth; |
| 4 | |
| 5 | template<class SHA>void runTest(int argc, char** argv) |
| 6 | { |
| 7 | Firebird::string salt; |
| 8 | #if SRP_DEBUG > 1 |
| 9 | Firebird::BigInteger s("02E268803000000079A478A700000002D1A6979000000026E1601C000000054F"); |
| 10 | #else |
| 11 | Firebird::BigInteger s; |
| 12 | s.random(128); |
| 13 | #endif |
| 14 | s.getText(salt); |
| 15 | |
| 16 | RemotePassword* server = FB_NEW RemotePasswordImpl<SHA>(); |
| 17 | RemotePassword* client = FB_NEW RemotePasswordImpl<SHA>(); |
| 18 | |
| 19 | const char* account = "SYSDBA"; |
| 20 | const char* password = "masterkey"; |
| 21 | |
| 22 | Firebird::UCharBuffer verifier; |
| 23 | dumpIt("salt", salt); |
| 24 | #if SRP_DEBUG > 0 |
| 25 | fprintf(stderr, "%s %s\n", account, password); |
| 26 | #endif |
| 27 | server->computeVerifier(account, salt, password).getBytes(verifier); |
| 28 | dumpIt("verifier", verifier); |
| 29 | |
| 30 | Firebird::string clientPubKey, serverPubKey; |
| 31 | client->genClientKey(clientPubKey); |
| 32 | fprintf(stderr, "C Pub %d\n", clientPubKey.length()); |
| 33 | server->genServerKey(serverPubKey, verifier); |
| 34 | fprintf(stderr, "S Pub %d\n", serverPubKey.length()); |
| 35 | |
| 36 | Firebird::UCharBuffer key1, key2; |
| 37 | client->clientSessionKey(key1, account, salt.c_str(), argc > 1 ? argv[1] : password, serverPubKey.c_str()); |
| 38 | server->serverSessionKey(key2, clientPubKey.c_str(), verifier); |
| 39 | |
| 40 | Firebird::BigInteger cProof = client->clientProof(account, salt.c_str(), key1); |
| 41 | Firebird::BigInteger sProof = server->clientProof(account, salt.c_str(), key2); |
| 42 | |
| 43 | printf("Proof length = %d\n",cProof.length()); |
| 44 | printf("%s\n", cProof == sProof ? "OK" : "differ"); |
| 45 | |
| 46 | } |
| 47 | |
| 48 | int main(int argc, char** argv) |
| 49 | { |
nothing calls this directly
no test coverage detected