-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
57 lines (48 loc) · 2.22 KB
/
Test.java
File metadata and controls
57 lines (48 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.math.BigInteger;
public class Test {
public static void main(String[] args) {
try {
SRP_Client client = new SRP_Client();
SRP_Server server = new SRP_Server();
String password = "Password";
// Generating User
String username = "Alex";
BigInteger salt = server.genSalt();
BigInteger verifier = server.genVerifier(salt, password);
// Server will contain {username, salt, verifier} and compute public private
// value
server.setUser(username, salt, verifier);
server.computePublicPrivatePair();
// Client will enter {username, passwoord} and compute public private value
client.setUser(username, password);
client.computePublicPrivatePair();
// Client will send username and public value to server
server.setClientPublic(client.A);
// Server in response will send salt and it's public value
client.setSalt(server.salt);
client.setServerPublic(server.B);
// Both will now compute their sessionKey.
server.computeSessionKey();
client.computeSessionKey();
// Both client and server will compute key verifier
client.computeSessionKeyVerifier();
server.computeSessionKeyVerifier();
// Client will send his key verifier to Server
boolean server_response = server.verifySessionKey(client.M);
if (server_response) {
// Server will send his key verifer to Client
boolean client_response = client.verifySessionKey(server.M);
if (client_response) {
System.out.println("Client and Server are mutually authenticated.");
} else {
System.out
.println("Client found Server's proof to be incorrect. Client will reject authentication.");
}
} else {
System.out.println(" Server found Client's proof to be incorrect. Server will reject authentication.");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}