-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNtsPacket.java
More file actions
75 lines (64 loc) · 2.43 KB
/
Copy pathNtsPacket.java
File metadata and controls
75 lines (64 loc) · 2.43 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
66
67
68
69
70
71
72
73
74
75
package nts;
import java.io.IOException;
public interface NtsPacket extends NtpV4Packet {
/**
* Build an NTS packet
*
* @param cookie The NTS cookie to use in the packet
* @param num_cookies Number of cookies to request
*/
public void buildRequest(final byte[] cookie, final int num_cookies);
/**
* Resize the buffer to the new size if it is smaller than the current size.
*
* @param newSize The new size of the buffer.
*/
public void resize(int newSize);
/**
* Adds a unique identifier extension field to the NTSv4 packet.
*
* @param unique_identifier_body the unique identifier byte array, must be at least 32 bytes long.
*/
public void addUniqueIdentifierEF(byte[] unique_identifier_body);
/**
* Adds a cookie extension field to the NTSv4 packet.
*
* @param cookie_body a cookie received from the NTS KE process or from a server response.
*/
public void addCookieEF(byte[] cookie_body);
/**
* Adds a cookie placeholder extension filed to the NTSv4 packet
*
* @param existing_cookie The cookie to be replaced
*/
public void addCookiePlaceholderEF(byte[] existing_cookie);
/**
* Constructs all the possible variables that will be used for the authentication and encryption
* extension field. This is done here to avoid unnecessary delays in the time measurement after
* timestamping of the request packet. This should be called after all the Extension Fields and
* other parameters have been added to the packet.
*/
public void prepareAuthAndEncEF();
/**
* Creates the AuthAndEnc EF with the given keys and nonce. This is done after the NTP packet has
* been timestamped. Must be called after prepareAuthAndEncEF() has been called.
*
* @param nonce the nonce to be used for encryption
*/
public void createAuthAndEncEF(byte[] nonce);
/**
* Creates the AuthAndEnc EF with the given keys and a random nonce. This is done after the NTP
* packet has been timestamped. Must be called after prepareAuthAndEncEF() has been called.
*/
public void createAuthAndEncEF();
/** Decrypt and verify a received NTS packet */
public byte[] decryptAndVerify() throws AuthenticationFailureException;
/**
* Validate a response packet given a request packet
*
* @param req - The request packet
* @throws IOException - On failure
*/
public void validate(NtsPacket req)
throws IOException, NtsNakException, AuthenticationFailureException;
}