It's now used for both XTEA and ISAAC keys, and there's nothing
XTEA-specific about it so there's no need to duplicate it.
Signed-off-by: Graham <gpe@openrs2.org>
I think this makes more sense, as we're loading it from the etc
directory, just like etc/config.yaml, and it isn't required by most of
the users of the crypto module.
Signed-off-by: Graham <gpe@openrs2.org>
The master index uses RSA signatures in some builds. As such, we need to
be able to encrypt with a private key and decrypt with a public key.
Signed-off-by: Graham <gpe@openrs2.org>
This will allow us to replace IsaacRandom in the future Netty
encoders/decoders with an implementation suitable for use in a unit
test.
Signed-off-by: Graham <gpe@openrs2.org>
This is useful in the archiving service code, as it can extract them for
insertion into the database without the overhead of creating and then
throwing away an IntArray.
Signed-off-by: Graham <gpe@openrs2.dev>
This already caught some cases of public members that should have been
private and one case where the inferred type was too specific.
Signed-off-by: Graham <gpe@openrs2.dev>
This allows us to make them private (rather than internal) and the type
as a whole is immutable.
It does mean we need to convert the key to an IntArray every time we use
it now. However, I hope that the JVM will be smart enough to inline the
toIntArray() method and also smart enough to realise it doesn't escape,
allowing it to allocate it on the stack rather than the heap.
This commit also adds methods for converting XteaKeys to hex, and
converting from hex/integer arrays to an XteaKey object.
Signed-off-by: Graham <gpe@openrs2.dev>
Unfortunately we can't use the compiler to guarantee k isn't changed,
though making it internal will help. When the JVM (and Kotlin) get value
types, we might be able to improve on this (e.g. by making it an inline
class of four integers).
Signed-off-by: Graham <gpe@openrs2.dev>
This commit updates the tests to ensure all combinations of 0-7 bytes of
leading/trailing blocks of unencrypted bytes work correctly with all
test vectors.
Signed-off-by: Graham <gpe@openrs2.dev>