Interface CipherPreferencePolicy
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Picks the transport encryption mode of a voice session out of the ones offered by the voice server.
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull CipherPreferencePolicyMeasures every supported encryption mode on this JVM and prefers the fastest ones.static @NotNull CipherPreferencePolicyThe default policy.static @NotNull CipherPreferencePolicypreferring(@NotNull List<String> preference) @Nullable Stringstatic @NotNull CipherPreferencePolicy
-
Method Details
-
select
@Nullable @Nullable String select(@NotNull @NotNull List<String> offered, @NotNull @NotNull Set<String> supported) - Parameters:
offered- encryption modes offered by the voice server, in the order it sent themsupported- encryption modes implemented by Koe- Returns:
- a mode that is both offered and supported, or null if none of them is acceptable, which fails the connection
-
serverOrder
- Returns:
- a policy which takes the first supported mode in the order the voice server sent them
-
preferring
@NotNull static @NotNull CipherPreferencePolicy preferring(@NotNull @NotNull List<String> preference) - Parameters:
preference- encryption mode names, most preferred first- Returns:
- a policy which takes the first mode from
preferencethat the voice server offers, and falls back toserverOrder()if it offers none of them
-
heuristic
The default policy. Prefers AES-GCM if the JVM reports using hardware AES instructions (HotSpot), and XChaCha20-Poly1305 otherwise, which is several times faster than AES-GCM implemented in software. Never runs a benchmark, seebenchmark()for that.- Returns:
- a policy based on the current JVM and CPU
-
benchmark
Measures every supported encryption mode on this JVM and prefers the fastest ones. Blocks the calling thread for about half a second, so call it once at startup, never on an event loop thread. UseCipherBenchmarkdirectly to configure how long it runs or to store the results.- Returns:
- a policy preferring modes from the fastest to the slowest
- See Also:
-