Closed juergw closed 5 months ago
This is now fixed in the new release 1.14, https://github.com/tink-crypto/tink-java/releases/tag/v1.14.0. This release also contains other performance improvements for AES-SIV, and AES-CMAC, for example https://github.com/tink-crypto/tink-java/commit/862ecfcf1506bcb4d9c1cd91a77a1aea6b7b4fc8 and https://github.com/tink-crypto/tink-java/commit/ff90fb9ac681bcf4e52ca59a2d424c71dad5a8f2.
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.