Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace sha1prng secure random with recommended algorithm #3314

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.amazonaws.mobileconnectors.cognitoidentityprovider;

import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;

Expand Down Expand Up @@ -4040,7 +4041,11 @@ protected MessageDigest initialValue() {

static {
try {
SECURE_RANDOM = SecureRandom.getInstance("SHA1PRNG");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
SECURE_RANDOM = SecureRandom.getInstanceStrong();
} else {
SECURE_RANDOM = new SecureRandom();
}

final MessageDigest messageDigest = THREAD_MESSAGE_DIGEST.get();
messageDigest.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,11 @@ protected MessageDigest initialValue() {

static {
try {
SECURE_RANDOM = SecureRandom.getInstance("SHA1PRNG");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
SECURE_RANDOM = SecureRandom.getInstanceStrong();
} else {
SECURE_RANDOM = new SecureRandom();
}
} catch (final NoSuchAlgorithmException e) {
throw new ExceptionInInitializerError(e);
}
Expand All @@ -360,7 +364,7 @@ public BigInteger getVerifier() {
/**
* Helps to start the SRP validation of the device.
* @param deviceGroupKey REQUIRED: Group assigned to the device.
* @param deviceKey REQUIRED: Unique identifier assigned to the device.
* @param deviceKey REQUIRED: Unique identifier assigned to the device.
* @param password REQUIRED: The device password.
*/
public deviceSRP(String deviceGroupKey, String deviceKey, String password) {
Expand Down