Record Class Keys
java.lang.Object
java.lang.Record
io.github.mahmoudimus.quic.crypto.Keys
- Record Components:
local- the keys for packets this endpoint sendsremote- the keys for packets this endpoint receives
The packet protection keys of one encryption level, from one endpoint's point of view:
local protects what it sends and remote removes protection from what it receives.
Keys come from TLS traffic secrets (fromSecrets(io.github.mahmoudimus.quic.Secrets, boolean)), or for Initial packets from the
client's first Destination Connection ID (initial(io.github.mahmoudimus.quic.QuicVersion, io.github.mahmoudimus.quic.ConnectionId, boolean)). A 1-RTT key update (RFC 9001
section 6) derives the next secrets with nextSecrets(io.github.mahmoudimus.quic.Secrets, io.github.mahmoudimus.quic.QuicVersion) and the next keys with update(io.github.mahmoudimus.quic.Secrets, boolean, io.github.mahmoudimus.quic.QuicVersion), which keeps the header protection keys.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static KeysfromSecrets(Secrets secrets, boolean isServer) QUIC version 1 keys from the traffic secrets the TLS handshake produced.static KeysfromSecrets(Secrets secrets, boolean isServer, QuicVersion version) Keys from the traffic secrets the TLS handshake produced.final inthashCode()Returns a hash code value for this object.static Keysinitial(QuicVersion version, ConnectionId clientDestinationId, boolean isServer) The Initial keys for a client's first Destination Connection ID.static SecretsinitialSecrets(QuicVersion version, ConnectionId clientDestinationId) The Initial secrets for a client's first Destination Connection ID (RFC 9001 section 5.2): HKDF-Extract with the version's salt, then the"client in"and"server in"labels.local()Returns the value of thelocalrecord component.static byte[]nextSecret(CipherSuite suite, byte[] secret, QuicVersion version) The next secret of one direction after a key update.static SecretsnextSecrets(Secrets secrets, QuicVersion version) The secrets after a key update: each secret expanded with the version's"quic ku"label to the hash length (RFC 9001 section 6.1).remote()Returns the value of theremoterecord component.final StringtoString()Returns a string representation of this record class.update(Secrets nextSecrets, boolean isServer, QuicVersion version) The keys of the next key phase: new packet keys from the next secrets, with these header keys, which a key update does not change (RFC 9001 section 6).
-
Constructor Details
-
Keys
Keys from their parts.- Parameters:
local- the keys for packets this endpoint sendsremote- the keys for packets this endpoint receives
-
-
Method Details
-
fromSecrets
QUIC version 1 keys from the traffic secrets the TLS handshake produced.- Parameters:
secrets- the client and server secrets of one levelisServer- whether this endpoint is the server, which picks the local secret- Returns:
- the keys
-
fromSecrets
Keys from the traffic secrets the TLS handshake produced.- Parameters:
secrets- the client and server secrets of one levelisServer- whether this endpoint is the server, which picks the local secretversion- the QUIC version, which picks the HKDF labels- Returns:
- the keys
-
initialSecrets
The Initial secrets for a client's first Destination Connection ID (RFC 9001 section 5.2): HKDF-Extract with the version's salt, then the"client in"and"server in"labels.- Parameters:
version- the QUIC version, which picks the saltclientDestinationId- the Destination Connection ID of the client's first Initial- Returns:
- the secrets, for
CipherSuite.TLS_AES_128_GCM_SHA256
-
initial
The Initial keys for a client's first Destination Connection ID.- Parameters:
version- the QUIC versionclientDestinationId- the Destination Connection ID of the client's first InitialisServer- whether this endpoint is the server- Returns:
- the keys
-
nextSecrets
The secrets after a key update: each secret expanded with the version's"quic ku"label to the hash length (RFC 9001 section 6.1).- Parameters:
secrets- the current 1-RTT secretsversion- the QUIC version, which picks the label- Returns:
- the next secrets, for the same level and suite
-
nextSecret
The next secret of one direction after a key update.- Parameters:
suite- the cipher suitesecret- the current traffic secretversion- the QUIC version, which picks the label- Returns:
- the next traffic secret
-
update
The keys of the next key phase: new packet keys from the next secrets, with these header keys, which a key update does not change (RFC 9001 section 6).- Parameters:
nextSecrets- the secrets fromnextSecrets(io.github.mahmoudimus.quic.Secrets, io.github.mahmoudimus.quic.QuicVersion)isServer- whether this endpoint is the serverversion- the QUIC version, which picks the labels- Returns:
- the keys for the next key phase
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
local
Returns the value of thelocalrecord component.- Returns:
- the value of the
localrecord component
-
remote
Returns the value of theremoterecord component.- Returns:
- the value of the
remoterecord component
-