NtpAuthenticationKey Class
A symmetric key shared by an NTP client and an NTP server, which authenticates the packets they exchange with a message authentication code (MAC), as defined by RFC 5905 and RFC 8573.
public sealed class NtpAuthenticationKeyRemarks
The key identifier and the key must be the same on both sides. With ntpd and chrony, they are a line of the keys file: 1 AES128CMAC 000102030405060708090a0b0c0d0e0f is new NtpAuthenticationKey(1, NtpAuthenticationAlgorithm.AesCmac, Convert.FromHexString("000102030405060708090a0b0c0d0e0f")).
Constructors
| Name | Description |
|---|---|
| NtpAuthenticationKey(uint, NtpAuthenticationAlgorithm, ReadOnlySpan<byte>) | Initializes a new instance of the NtpAuthenticationKey class. |
NtpAuthenticationKey(uint, NtpAuthenticationAlgorithm, ReadOnlySpan<byte>)
NtpAuthenticationKey.csInitializes a new instance of the NtpAuthenticationKey class.
public NtpAuthenticationKey(uint keyId, NtpAuthenticationAlgorithm algorithm, ReadOnlySpan<byte> key)Parameters
keyIduint- The key identifier, sent in every authenticated packet. It cannot be 0, which RFC 5905 reserves.
algorithmNtpAuthenticationAlgorithm- The MAC algorithm.
keyReadOnlySpan<byte>- The secret key.
NtpAuthenticationAlgorithm.AesCmacrequires exactly 16 bytes.
Exceptions
ArgumentOutOfRangeExceptionkeyIdis 0, oralgorithmis not defined.ArgumentExceptionkeyis empty, or does not have the size the algorithm requires.
Properties
| Name | Description |
|---|---|
| Algorithm | Gets the MAC algorithm. |
| Key | Gets the secret key. |
| KeyId | Gets the key identifier. |