hbs/oss — pull request #2 by gidouin (2013-07-05 00:03:40+00:00)
Title: AES 256 keys were exposed as AES 192 keys

This Pull Request is comprised of 2 proposed bugfixes.

* bugfix in GetSecretServlet (major)

Secrets are prefixed with a nonce before being wrapped by the master key and stored. The nonce is removed when unwrapping (in CryptoHelper.unwrapBlob).

When the temporary AES Key is used to wrap to secret bytes to be returned to the client, the 8-byte nonce was REMOVED AGAIN: The 64 most significant bits of the secret being excluded.

When the secret is an AES-256 key (as generated with GenSecret), a smaller key comprised of the lowest 192 bits is returned... which is still a valid AES key, so no exception was thrown when calling OSS or using the key.

When the secret was externally pushed by PutSecret, the result is garbled or an ArrayIndexOutOfBoundsException occurs.

The proposed fix, server-side, return the whole secret as intented. /!\ Existing secret will be seen different on the client side. If an application was already using the truncated AES key, it is easy to recover the previous 192 bits from the full key with `java.util.Arrays.copyOfRange(secret, 8, 32)` for instance.

* bugfix in CryptoHelper.sshSignatureBlogSign()

NullPointerException when the PrivateKey in the second parameter is an RSA private key, as `tns` is never assigned a value.