Skip to main content

We've discovered a #Regression in the behavior of Crypto.generateDigest() in #Winter19.

 

To reproduce this, run tests against the following two Apex Classes, the first on API version 43 and the second on API version 44. We'd expect that a change in the exception message to be part of the API contract, so the fact that version 43 no longer behaves as it used to seems like a #BUG:

 

@isTest

public class CryptoGenerateDigest43_Test {

    @isTest

    public static void test() {

        try {

            Crypto.generateDigest('INVALID', Blob.valueOf(''));

        } catch (System.SecurityException e) {

            System.assertEquals('INVALID MessageDigest not available', e.getMessage());

        }

    }

}

 

@isTest

public class CryptoGenerateDigest44_Test {

    @isTest

    public static void test() {

        try {

            Crypto.generateDigest('INVALID', Blob.valueOf(''));

        } catch (System.SecurityException e) {

            System.assertEquals('no such algorithm: INVALID for provider SC', e.getMessage());

        }

    }

}

 

It looks like the underlying implementation of Crypto.generateDigest() delegates to the Java backend, but the java.security.NoSuchAlgorithmException message is now propagated directly even in older API versions.

 

We've filed this issue with support as case ID 5000M00000mQPatQAG

0/9000