Package nts
Interface NtsPacket
- All Superinterfaces:
NtpV3Packet,NtpV4Packet
- All Known Implementing Classes:
NtsImpl
-
Field Summary
Fields inherited from interface nts.NtpV3Packet
LI_ALARM_CONDITION, LI_LAST_MINUTE_HAS_59_SECONDS, LI_LAST_MINUTE_HAS_61_SECONDS, LI_NO_WARNING, MODE_BROADCAST, MODE_CLIENT, MODE_CONTROL_MESSAGE, MODE_PRIVATE, MODE_RESERVED, MODE_SERVER, MODE_SYMMETRIC_ACTIVE, MODE_SYMMETRIC_PASSIVE, NTP_MAXCLOCK, NTP_MAXPOLL, NTP_MINCLOCK, NTP_MINPOLL, NTP_PORT, TYPE_DAYTIME, TYPE_ICMP, TYPE_NTP, TYPE_TIME, VERSION_3, VERSION_4 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCookieEF(byte[] cookie_body) Adds a cookie extension field to the NTSv4 packet.voidaddCookiePlaceholderEF(byte[] existing_cookie) Adds a cookie placeholder extension filed to the NTSv4 packetvoidaddUniqueIdentifierEF(byte[] unique_identifier_body) Adds a unique identifier extension field to the NTSv4 packet.voidbuildRequest(byte[] cookie, int num_cookies) Build an NTS packetvoidCreates the AuthAndEnc EF with the given keys and a random nonce.voidcreateAuthAndEncEF(byte[] nonce) Creates the AuthAndEnc EF with the given keys and nonce.byte[]Decrypt and verify a received NTS packetvoidConstructs all the possible variables that will be used for the authentication and encryption extension field.voidValidate a response packet given a request packetMethods inherited from interface nts.NtpV3Packet
buildRequest, getDatagramPacket, getDatagramPacket, getLeapIndicator, getMode, getModeName, getOriginateTimeStamp, getPoll, getPrecision, getReceiveTimeStamp, getReferenceId, getReferenceIdString, getReferenceTimeStamp, getRootDelay, getRootDelayInMillisDouble, getRootDispersion, getRootDispersionInMillis, getRootDispersionInMillisDouble, getStratum, getTransmitTimeStamp, getType, getVersion, setDatagramPacket, setLeapIndicator, setMode, setOriginateTimeStamp, setPoll, setPrecision, setReceiveTimeStamp, setReferenceId, setReferenceTime, setRootDelay, setRootDispersion, setStratum, setTransmitTime, setVersion, validateMethods inherited from interface nts.NtpV4Packet
addExtensionField, addExtensionFields, getExtensionFields, getExtensionFields
-
Method Details
-
buildRequest
void buildRequest(byte[] cookie, int num_cookies) Build an NTS packet- Parameters:
cookie- The NTS cookie to use in the packetnum_cookies- Number of cookies to request
-
addUniqueIdentifierEF
void addUniqueIdentifierEF(byte[] unique_identifier_body) Adds a unique identifier extension field to the NTSv4 packet.- Parameters:
unique_identifier_body- the unique identifier byte array, must be at least 32 bytes long.
-
addCookieEF
void addCookieEF(byte[] cookie_body) Adds a cookie extension field to the NTSv4 packet.- Parameters:
cookie_body- a cookie received from the NTS KE process or from a server response.
-
addCookiePlaceholderEF
void addCookiePlaceholderEF(byte[] existing_cookie) Adds a cookie placeholder extension filed to the NTSv4 packet- Parameters:
existing_cookie- The cookie to be replaced
-
prepareAuthAndEncEF
void prepareAuthAndEncEF()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. -
createAuthAndEncEF
void createAuthAndEncEF(byte[] nonce) 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.- Parameters:
nonce- the nonce to be used for encryption
-
createAuthAndEncEF
void createAuthAndEncEF()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. -
decryptAndVerify
Decrypt and verify a received NTS packet- Throws:
AuthenticationFailureException
-
validate
Validate a response packet given a request packet- Parameters:
req- - The request packet- Throws:
IOException- - On failureNtsNakExceptionAuthenticationFailureException
-