Graham
bba220aebc
Add SHA-1 extension method to ByteBuf
...
Similar to the existing Whirlpool extension method.
Signed-off-by: Graham <gpe@openrs2.org>
1 year ago
Graham
650e298bc9
Add CREATE_ACCOUNT packet
...
Signed-off-by: Graham <gpe@openrs2.org>
2 years ago
Graham
4604bc8b81
Add assisted injection extension
2 years ago
Graham
03e6c3dd81
Annotate crypto methods with @Jvm{Overloads,Static}
...
Signed-off-by: Graham <gpe@openrs2.org>
3 years ago
Graham
cf6e7cf8e7
Add methods for reading RSA keys from memory
...
Signed-off-by: Graham <gpe@openrs2.org>
3 years ago
Graham
7eae597892
Move RsaKeyProvider to the config module
...
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>
4 years ago
Graham
b37e4d0d0b
Use alternatives for most methods deprecated in Kotlin 1.5
...
Signed-off-by: Graham <gpe@openrs2.org>
4 years ago
Graham
9e8d1fca1c
Use type-safe project accessors
...
Signed-off-by: Graham <gpe@openrs2.org>
4 years ago
Graham
6498d39306
Add Gradle 7 version catalog
...
Signed-off-by: Graham <gpe@openrs2.org>
4 years ago
Graham
3d09c4d90a
Make XteaKey a data class
...
It needs a hashCode/equals implementation as it's used in sets.
Signed-off-by: Graham <gpe@openrs2.org>
4 years ago
Graham
31db959a46
Add XteaKeyDeserializer
...
Signed-off-by: Graham <gpe@openrs2.org>
4 years ago
Graham
359891c01e
Convert all test objects to classes
...
This is required for IDEA to display the run test icon in the gutter.
Signed-off-by: Graham <gpe@openrs2.org>
4 years ago
Graham
5e6afb88f6
Improve RSA method naming
...
Signed-off-by: Graham <gpe@openrs2.org>
4 years ago
Graham
98d25539b9
Combine RSA encrypt and decrypt methods into a single crypt method
...
This allows us to speed up master index signing with the CRT.
Signed-off-by: Graham <gpe@openrs2.org>
4 years ago
Graham
ed7eb10411
Relax isPrivate checks in the encrypt/decrypt methods
...
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>
4 years ago
Graham
e9e7b7848d
Add constant for the RSA magic byte
...
Signed-off-by: Graham <gpe@openrs2.org>
4 years ago
Graham
46b311c5ad
Add XteaKey Jackson serializer
...
Signed-off-by: Graham <gpe@openrs2.org>
4 years ago
Graham
f1c3c65811
Use upper case hex digits in golden ratio constant
...
Signed-off-by: Graham <gpe@openrs2.org>
4 years ago
Graham
1e3257acf7
Use consistent case for Unicode escapes in the Whirlpool S-box
...
Signed-off-by: Graham <gpe@openrs2.org>
4 years ago
Graham
f90b9df505
Replace Paths.get() with Path.of()
...
Paths.get() may be deprecated in a future release.
Signed-off-by: Graham <gpe@openrs2.org>
4 years ago
Graham
c70cfcfb30
Add ByteBuf.whirlpool() extension method
...
Signed-off-by: Graham <gpe@openrs2.org>
4 years ago
Graham
6f815b6334
Move return outside try block
...
Signed-off-by: Graham <gpe@openrs2.org>
4 years ago
Graham
a86f000f88
Add StreamCipher interface and a NopStreamCipher implementation
...
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>
4 years ago
Graham
76977303b2
Add shorthand methods for creating ByteBufs from ByteArrays and Strings
...
Signed-off-by: Graham <gpe@openrs2.org>
4 years ago
Graham
f143eef142
Move Kotlin files from src/{main,test}/java to src/{main,test}/kotlin
...
Signed-off-by: Graham <gpe@openrs2.org>
4 years ago
Graham
ce5b76ef0f
Rename dev.openrs2 package to org.openrs2
...
Signed-off-by: Graham <gpe@openrs2.org>
4 years ago
Graham
d755d486d6
Add initial cache and XTEA key archiving service
...
Signed-off-by: Graham <gpe@openrs2.dev>
4 years ago
Graham
0e7e8f2d7d
Make the individual components of an XteaKey public
...
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>
4 years ago
Graham
2c7abdc7ff
Use bufferedReader() extension method
...
Signed-off-by: Graham <gpe@openrs2.dev>
4 years ago
Graham
9aaa095b02
Use DIGESTBYTES to set the size of the output ByteArray
...
Signed-off-by: Graham <gpe@openrs2.dev>
4 years ago
Graham
380cc95d31
Make DIGESTBYTES public
...
Signed-off-by: Graham <gpe@openrs2.dev>
4 years ago
Graham
192d5b9e8d
Resolve inspections
...
Signed-off-by: Graham <gpe@openrs2.dev>
4 years ago
Graham
232ba32bbd
Enable explicit API mode
...
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>
4 years ago
Graham
e7ad4b92ff
Group test files by test
...
Signed-off-by: Graham <gpe@openrs2.dev>
4 years ago
Graham
3f59e1764c
Store individual XteaKey components separately
...
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>
4 years ago
Graham
1eb423fbf6
Mark sbox as const
...
Signed-off-by: Graham <gpe@openrs2.dev>
4 years ago
Graham
95c97b8399
Add XteaKey inline class with ZERO "constant" and isZero method
...
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>
4 years ago
Graham
ce4de919b8
Use infix version of shl
...
Signed-off-by: Graham <gpe@openrs2.dev>
4 years ago
Graham
1a0b7c1d33
Add Whirlpool implementation
...
This is a fairly direct port of the public domain Java reference
implementation to Kotlin.
Signed-off-by: Graham <gpe@openrs2.dev>
4 years ago
Graham
ba67f32d42
Format XteaTest
...
Signed-off-by: Graham <gpe@openrs2.dev>
4 years ago
Graham
e0708458f9
Add use extension method for releasing reference-counted objects
...
Signed-off-by: Graham <gpe@openrs2.dev>
4 years ago
Graham
4da1c5c3cf
Fix XTEA en/decryption if the index is not a multiple of the block size
...
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>
4 years ago
Graham
7218855eb7
Fix en/decryption of XTEA messages not a multiple of the block size
...
Reported by Scu11.
Signed-off-by: Graham <gpe@openrs2.dev>
4 years ago
Graham
c3715d7320
Add useTempFile extension methods
...
Signed-off-by: Graham <gpe@openrs2.dev>
4 years ago
Graham
8370ad104e
Write files atomically
...
Signed-off-by: Graham <gpe@openrs2.dev>
4 years ago
Graham
ea82565cd6
Update Bouncy Castle
...
The provider and PKIX jars seem to be versioned independently.
Signed-off-by: Graham <gpe@openrs2.dev>
5 years ago
Graham
35fea8f293
Remove redundant substring() call
...
parseUnsignedInt() is capable of parsing a substring itself.
Signed-off-by: Graham <gpe@openrs2.dev>
5 years ago
Graham
676be4a0cb
Add XTEA implementation
...
Signed-off-by: Graham <gpe@openrs2.dev>
5 years ago
Graham
7fc8c4e078
Add ISAAC cipher implementation
...
Signed-off-by: Graham <gpe@openrs2.dev>
5 years ago
Graham
ccf7056a93
Use private companion objects where possible
...
Signed-off-by: Graham <gpe@openrs2.dev>
5 years ago