I’m aware of this function, which is in this repository (https://github.com/marcins/cf-google-authenticator/blob/master/authenticator/GoogleAuthenticator.cfc), and as far as I’m concerned, I don’t feel comfortable having to add exceptions to the server that might increase the attack surface by using the configuration
--add-opens=java.base/some.package.name=ALL-UNNAMED
Instead, I changed the function by using ColdFusion’s native functions that do the same thing. Specifically, the GeneratePBKDFKey function is what we need (https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-e-g/generatepbkdfkey.html).
Here’s the code with the changes:
public string function generateKey(required string password, string salt = "", numeric iterationCount = 128, numeric keySizeBits = 80)
{
// Se salt non fornito, generiamo 16 byte casuali
if (Len(arguments.salt) == 0) {
arguments.salt = generateRandomString();
}
else if (Len(salt) != 16) {
throw(message="Salt must be 16 bytes", errorCode="GoogleAuthenticator.BadSalt");
}
var derivedKey = GeneratePBKDFKey("PBKDF2WithHmacSHA1" , arguments.password, arguments.salt, arguments.iterationCount, arguments.keySizeBits);
return Base32encode(binaryDecode(derivedKey, "base64"));
}
Hope this helps.
Best regards,
Salvatore