-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTesting.java
More file actions
65 lines (53 loc) · 1.96 KB
/
Testing.java
File metadata and controls
65 lines (53 loc) · 1.96 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
58
59
60
61
62
63
64
65
import java.util.Scanner;
// Testing class for part 3 of Homework 5
// Robert Bell Spring 2020
public class Testing {
public static void main(String args[]) {
// Instantiate elements
Alice alice = new Alice();
Bob bob = new Bob();
// Timing Elements
double HMACTimeRaw = 0.0;
double HMACTimeAvg = 0.0;
double SIGGenRaw = 0.0;
double SIGGenAvg = 0.0;
double SIGTimeRaw = 0.0;
double SIGTimeAvg = 0.0;
double timeGet = 0.0;
// get Message
Scanner input = new Scanner(System.in);
System.out.println("Input a 7 byte message...");
String message = input.nextLine();
// Implement SHA-256 HMAC in Alice/Bob
alice.ExportSymKey("key.txt");
bob.CollectSymKey("key.txt");
// Run this exchange 100 times
// Using message from commandline
for (int i = 0; i < 100; i++) {
timeGet = System.currentTimeMillis();
alice.SendHMACMessage("mactext.txt", message);
bob.RetrieveHMAC("mactext.txt", message.length());
bob.AuthenticateHMAC();
HMACTimeRaw += System.currentTimeMillis() - timeGet;
}
HMACTimeAvg = HMACTimeRaw / 100.0;
// Implement SHA-256 HMAC in Alice/Bob
alice.ExportPublicKey("ApubKey.txt");
bob.CollectAsymKey("ApubKey.txt");
// Run this exchange 100 times
// Using message from commandline
for (int i = 0; i < 100; i++) {
timeGet = System.currentTimeMillis();
alice.SendSIGMessage("sigtext.txt", message);
SIGGenRaw += System.currentTimeMillis() - timeGet;
bob.retrieveSIGMessage("sigtext.txt", message.length());
bob.AuthenticateSIG();
SIGTimeRaw += System.currentTimeMillis() - timeGet;
}
SIGTimeAvg = SIGTimeRaw / 100.0;
SIGGenAvg = SIGGenRaw / 100.0;
System.out.println("The average time fo HMAC is: " + HMACTimeAvg + "ms");
System.out.println("The average time fo Signature Generation is: " + SIGGenAvg + "ms");
System.out.println("The average time fo Signature Verification is: " + SIGTimeAvg + "ms");
}
}