Merge pull request #61 from cconlon/sha1alias

JCE: add "SHA1" alias for MessageDigest SHA-1, for interop with Sun
pull/64/head
Daniel Pouzzner 2024-02-10 02:19:59 -05:00 committed by GitHub
commit f14c85b6d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View File

@ -44,6 +44,8 @@ public final class WolfCryptProvider extends Provider {
if (FeatureDetect.ShaEnabled()) {
put("MessageDigest.SHA",
"com.wolfssl.provider.jce.WolfCryptMessageDigestSha");
put("MessageDigest.SHA1",
"com.wolfssl.provider.jce.WolfCryptMessageDigestSha");
put("MessageDigest.SHA-1",
"com.wolfssl.provider.jce.WolfCryptMessageDigestSha");
}

View File

@ -58,12 +58,15 @@ public class WolfCryptMessageDigestShaTest {
assertNotNull(p);
try {
/* Try "SHA" cipher string, for SUN interop */
/* Try "SHA" and "SHA1" cipher strings, for SUN interop */
MessageDigest sha = MessageDigest.getInstance("SHA",
"wolfJCE");
MessageDigest sha1 = MessageDigest.getInstance("SHA-1",
"wolfJCE");
MessageDigest sha1 = MessageDigest.getInstance("SHA1",
"wolfJCE");
MessageDigest shaDash1 = MessageDigest.getInstance("SHA-1",
"wolfJCE");
} catch (NoSuchAlgorithmException e) {
/* if we also detect algo is compiled out, skip tests */
if (FeatureDetect.ShaEnabled() == false) {