Throw exception if decryption/encryption fails
Previously, in the case of a failure during encryption or decryption
in AAA, the system would only log an error and return insered string.
This could lead user to believe that the operation was successful,
resulting in them receiving unencrypted/undecrypted data.
Also is possible that IllegalArgumentException is thrown which is also
wrong.
This patch simplifies things by throwing GeneralSecurityException, as
that is quite a natural thing to do.
In terms of IAEs -- this relates to String encoding and not encryption,
so we solve this by simply not providing String-based services, forcing
users to deal with translation themselves.
Since we are in the area, also convert unit tests to JUnit5, as they are
extremely simplistic.
Also make the service null-hostile, as that it almost is -- encrypt path
would throw IAE on null bytes, this turns it into a NPE and guards the
decrypt path the same way.
Finally we take care of the asymmetry in encrypt/descrypt when we do not
have a key -- simply by refusing to start it we fail to initialize.
JIRA: AAA-266
Change-Id: I4c9078e293fe5b98f0e6b69568ca10a75a4fbe07
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Yaroslav Lastivka <yaroslav.lastivka@pantheon.tech>