Class ServerKey
Each key is 256-bit AES material used with AES-GCM (Galois/Counter Mode), which provides confidentiality AND authenticity in a single pass: the 128-bit GCM authentication tag is a keyed MAC computed under the AES key, so any tampering with the ciphertext is detected on decrypt. A fresh random 96-bit nonce is generated for every encryption and is carried in the output, so identical plaintexts never produce identical ciphertext.
The wire layout of an encoded parameter is the byte sequence nonce(12) || ciphertext || tag(16), then base64url without padding (RFC 4648 §5: - and _, no =), which is safe to place directly in a cookie value or URL with no further escaping. The client never sees the key - only these opaque blobs.
This class replaced an earlier AES-CBC scheme that used a fixed IV and an unkeyed SHA-256 of the ciphertext as an integrity check. That check authenticated nothing (an attacker could recompute the hash over modified ciphertext) and the constant IV leaked plaintext equality. GCM removes both weaknesses. There is deliberately no CBC decryption fallback: no previously issued blob needs to survive.
- Author:
- Christopher Mindus
Method Summary
Method Details
getFingerPrint
Gets the fingerprint of this key for use with the client. The fingerprint identifies WHICH server key encrypted a value so the correct key can be selected on decrypt; it is not itself security-load-bearing (the GCM tag provides authentication).The digest algorithm is whichever
{@link ServerSecurityManager#digest(byte[])}selects - the first available of SHA-512, SHA-384, SHA-256, SHA1, MD5 - which is SHA-512 on every modern JVM. This JavaDoc previously claimed SHA-256, which was wrong.The returned form is STANDARD base64 and is therefore not URL- or cookie-safe on its own;
ServerSecurityManagertranslates it to base64url for the wire and back again for the key-map lookup.- Returns:
- The fingerprint is a message digest base64 encoded string.
equals
hashCode
toString