Skip to content

Commit 2ffa9e8

Browse files
committed
skip encryption padding when no encryption purpose passed
1 parent 16c21b1 commit 2ffa9e8

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

common/src/main/java/com/microsoft/identity/common/internal/platform/AndroidDevicePopManager.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ private void initialize(@NonNull final Context context,
373373
if (!unnecessaryCryptoPurposesDisabled && enableImport) {
374374
purposes |= KeyProperties.PURPOSE_WRAP_KEY;
375375
}
376-
initialize28(keyPairGenerator, keySize, useStrongbox, trySetAttestationChallenge, purposes);
376+
initialize28(keyPairGenerator, keySize, useStrongbox, trySetAttestationChallenge, purposes, unnecessaryCryptoPurposesDisabled);
377377
}
378378
}
379379

@@ -454,7 +454,8 @@ private void initialize28(@androidx.annotation.NonNull final KeyPairGenerator ke
454454
final int keySize,
455455
final boolean useStrongbox,
456456
final boolean trySetAttestationChallenge,
457-
final int purposes) throws InvalidAlgorithmParameterException {
457+
final int purposes,
458+
final boolean unnecessaryCryptoPurposesDisabled) throws InvalidAlgorithmParameterException {
458459
KeyGenParameterSpec.Builder builder = new KeyGenParameterSpec.Builder(
459460
mKeyManager.getKeyAlias(), purposes)
460461
.setKeySize(keySize)
@@ -465,11 +466,15 @@ private void initialize28(@androidx.annotation.NonNull final KeyPairGenerator ke
465466
KeyProperties.DIGEST_NONE,
466467
KeyProperties.DIGEST_SHA1,
467468
KeyProperties.DIGEST_SHA256
468-
).setEncryptionPaddings(
469-
KeyProperties.ENCRYPTION_PADDING_RSA_OAEP,
470-
KeyProperties.ENCRYPTION_PADDING_RSA_PKCS1
471469
);
472470

471+
if (!unnecessaryCryptoPurposesDisabled) {
472+
builder.setEncryptionPaddings(
473+
KeyProperties.ENCRYPTION_PADDING_RSA_OAEP,
474+
KeyProperties.ENCRYPTION_PADDING_RSA_PKCS1
475+
);
476+
}
477+
473478
if (trySetAttestationChallenge) {
474479
builder = setAttestationChallenge(builder);
475480
}

common4j/src/main/com/microsoft/identity/common/java/platform/AbstractDevicePopManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,14 +885,16 @@ public String mintSignedAccessToken(@Nullable String httpMethod,
885885
@Nullable final String clientClaims) throws ClientException {
886886
final Span span = OTelUtility.createSpan(SpanName.DevicePopMintSignedAccessToken.name());
887887
try (final Scope scope = SpanExtension.makeCurrentSpan(span)) {
888-
return mintSignedHttpRequestInternal(
888+
final String signedAccessToken = mintSignedHttpRequestInternal(
889889
httpMethod,
890890
timestamp,
891891
requestUrl,
892892
accessToken,
893893
nonce,
894894
clientClaims
895895
);
896+
span.setStatus(StatusCode.OK);
897+
return signedAccessToken;
896898
} catch (final Exception exception) {
897899
span.recordException(exception);
898900
span.setStatus(StatusCode.ERROR);

0 commit comments

Comments
 (0)