Skip to content

Commit ee80435

Browse files
authored
Merge pull request #92 from okta/fix_invalid_keys
Don't use OEAP spec workaround if using strongbox.
2 parents 7f7802c + dafb56e commit ee80435

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

library/src/main/java/com/okta/oidc/storage/security/BaseEncryptionManager.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ abstract class BaseEncryptionManager implements EncryptionManager {
5959
protected String mBlockMode;
6060
protected String mEncryptionPadding;
6161
protected String mTransformationString;
62+
protected boolean mIsStrongBoxBacked;
6263

6364
private static final int RSA_KEY_SIZE = 2048;
6465
// RSA doesn't support encryption of lot amount of data.
@@ -227,8 +228,10 @@ private void initEncodeCipher(String keyAlias, int mode) throws GeneralSecurityE
227228
PublicKey unrestricted = KeyFactory.getInstance(key.getAlgorithm())
228229
.generatePublic(new X509EncodedKeySpec(key.getEncoded()));
229230

230-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
231+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !mIsStrongBoxBacked) {
231232
// from https://code.google.com/p/android/issues/detail?id=197719
233+
// This workaround of using the OAEP spec is not compatible when strong box is used.
234+
// Currently the only device is the PIXEL 3.
232235
OAEPParameterSpec spec = new OAEPParameterSpec("SHA-256", "MGF1",
233236
MGF1ParameterSpec.SHA1, PSource.PSpecified.DEFAULT);
234237

library/src/main/java/com/okta/oidc/storage/security/EncryptionManagerAPI23.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ boolean generateKeyPair(Context context, KeyPairGenerator generator, String keyA
8888
// In Android P was introduced new way to persist keystore - StrongBox
8989
// If device doesn't support StrongBox, it will use TEE implementation if present.
9090
builder.setIsStrongBoxBacked(isStrongBoxBacked);
91+
mIsStrongBoxBacked = isStrongBoxBacked;
9192
}
9293

9394
if (seed != null && seed.length > 0) {

0 commit comments

Comments
 (0)