Debian Codegraph @

src/test/bnetsrp3_test.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 1999,2001 Ross Combs ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18 #include "common/setup_before.h"
19 #include <cstdio>
20 #include <cassert>
21 #include "common/xalloc.h"
22 #include "common/util.h"
23 #include "common/bnetsrp3.h"
24 #include "common/setup_after.h"
25
26 using namespace pvpgn;
27
28 int main()
29 {
30 const unsigned char salt[] = { 0xB3, 0x46, 0x25, 0x10, 0x1D, 0xEA, 0x80, 0xB9, 0x92, 0xEB, 0x50, 0x4E, 0x84, 0x00, 0x06, 0xA1,
31 0x7E, 0x77, 0x58, 0x66, 0x73, 0x89, 0x27, 0xF7, 0x14, 0x90, 0x2D, 0xA6, 0x3F, 0xCC, 0xF8, 0x52 };
32 BnetSRP3 nls1("regen", "bogen");
33 nls1.setSalt(BigInt(salt, 32));
34
35 BigInt v = nls1.getVerifier();
36 BigInt s = nls1.getSalt();
37 BnetSRP3 nls2("power", s);
38
39 //output= (char *)xmalloc(40*3+1);
40
41 //s.getData(data,32);
42 //str_to_hex(output,(const char*)data,32);
43 //std::printf("salt: %s\n",output);
44
45 //v.getData(data,32,4,false);
46 //str_to_hex(output,(const char*)data,32);
47 //std::printf("verifier: %s\n",output);
48
49 BigInt A = nls1.getClientSessionPublicKey();
50 //A.getData(data,32,4,false);
51 //str_to_hex(output,(const char*)data,32);
52 //std::printf("A: %s\n",output);
53
54 BigInt B = nls2.getServerSessionPublicKey(v);
55 //B.getData(data,32,4,false);
56 //str_to_hex(output,(const char*)data,32);
57 //std::printf("B: %s\n",output);
58
59 BigInt K1 = nls1.getHashedClientSecret(B);
60 //K1.getData(data,40,4,false);
61 //str_to_hex(output,(const char*)data,40);
62 //std::printf("K1: %s\n",output);
63
64 BigInt K2 = nls2.getHashedServerSecret(A, v);
65 //K2.getData(data,40,4,false);
66 //str_to_hex(output,(const char*)data,40);
67 //std::printf("K2: %s\n",output);
68
69 assert(K1 == K2);
70
71 //BigInt M1 = nls2.getClientPasswordProof(A, B, K1);
72 //M1.getData(data,20,4,false);
73 //str_to_hex(output,(const char*)data,20);
74 //std::printf("M1: %s\n",output);
75
76 //BigInt M2 = nls1.getServerPasswordProof(A, M1, K2);
77 //M2.getData(data,20,4,false);
78 //str_to_hex(output,(const char*)data,20);
79 //std::printf("M2: %s\n",output);
80
81 return 0;
82 }
83