Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarBasem committed Feb 8, 2021
1 parent f059ece commit 77d8d28
Showing 1 changed file with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import java.security.Key;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.ProviderException;
import java.security.UnrecoverableKeyException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -390,20 +389,20 @@ public void generateKeyAndStoreUnderAlias(@NonNull final String alias,

Key secretKey = null;

// multi-threaded usage is possible
synchronized (_syncStrongbox) {
if (null == isStrongboxAvailable || isStrongboxAvailable.get()) {
if (null == isStrongboxAvailable) isStrongboxAvailable = new AtomicBoolean(false);

try {
secretKey = tryGenerateStrongBoxSecurityKey(alias);

isStrongboxAvailable.set(true);
} catch (GeneralSecurityException | ProviderException ex) {
Log.w(LOG_TAG, "StrongBox security storage is not available.", ex);
}
}
}
// // multi-threaded usage is possible
// synchronized (_syncStrongbox) {
// if (null == isStrongboxAvailable || isStrongboxAvailable.get()) {
// if (null == isStrongboxAvailable) isStrongboxAvailable = new AtomicBoolean(false);
//
// try {
// secretKey = tryGenerateStrongBoxSecurityKey(alias);
//
// isStrongboxAvailable.set(true);
// } catch (GeneralSecurityException | ProviderException ex) {
// Log.w(LOG_TAG, "StrongBox security storage is not available.", ex);
// }
// }
// }

// If that is not possible, we generate the key in a regular way
// (it still might be generated in hardware, but not in StrongBox)
Expand Down

0 comments on commit 77d8d28

Please sign in to comment.