tink-java
tink-java copied to clipboard
AES-SIV encryption/decryption has bad performance on small input and when run in many threads in parallel.
This is the same issue as already discussed here for AES-GCM:
https://github.com/tink-crypto/tink/issues/208
AES-SIV currently creates a new cipher object on each call to encryptDeterministically and decryptDeterministically. But creating these objects is expensive, and it requires locks, which make it even worse when done in multiple threads.
AES-SIV is often used to encrypt small values, for example EncryptedSharedPreferences uses it to encrypt keys in key-value pairs, which are typically small.
So we should add the same solution as proposed in https://github.com/tink-crypto/tink/issues/208 and use ThreadLocal ciphers objects.