Skip to content

Commit 491c722

Browse files
committed
Replace setter override in category with initializer without category
1 parent ef6cd82 commit 491c722

File tree

8 files changed

+38
-96
lines changed

8 files changed

+38
-96
lines changed

IdentityCore/IdentityCore.xcodeproj/project.pbxproj

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -752,9 +752,6 @@
752752
728209D026FEA0F600B5F018 /* MSIDKeyOperationUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 728209CF26FEA0F600B5F018 /* MSIDKeyOperationUtil.m */; };
753753
728209D126FEA0F600B5F018 /* MSIDKeyOperationUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 728209CF26FEA0F600B5F018 /* MSIDKeyOperationUtil.m */; };
754754
728209D62702AF8900B5F018 /* MSIDBackgroundTaskManagerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 728209D32702AE9300B5F018 /* MSIDBackgroundTaskManagerTests.m */; };
755-
728ABACC2E5A3B4E00FCE434 /* MSIDWPJKeyPairWithCert+TransportKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 728ABACB2E5A3B2800FCE434 /* MSIDWPJKeyPairWithCert+TransportKey.h */; };
756-
728ABACE2E5A41A800FCE434 /* MSIDWPJKeyPairWithCert+TransportKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 728ABACD2E5A418F00FCE434 /* MSIDWPJKeyPairWithCert+TransportKey.m */; };
757-
728ABACF2E5A41A800FCE434 /* MSIDWPJKeyPairWithCert+TransportKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 728ABACD2E5A418F00FCE434 /* MSIDWPJKeyPairWithCert+TransportKey.m */; };
758755
728D9E4628245DD7001D990F /* MSIDTestSecureEnclaveKeyPairGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 728D9E4528245DD7001D990F /* MSIDTestSecureEnclaveKeyPairGenerator.m */; };
759756
728D9E4728245DD7001D990F /* MSIDTestSecureEnclaveKeyPairGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 728D9E4528245DD7001D990F /* MSIDTestSecureEnclaveKeyPairGenerator.m */; };
760757
728D9E492824A323001D990F /* MSIDPkeyAuthHelperTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 23CA0C5E220A68D400768729 /* MSIDPkeyAuthHelperTests.m */; };
@@ -2683,8 +2680,6 @@
26832680
728209CD26FEA0D800B5F018 /* MSIDKeyOperationUtil.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDKeyOperationUtil.h; sourceTree = "<group>"; };
26842681
728209CF26FEA0F600B5F018 /* MSIDKeyOperationUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDKeyOperationUtil.m; sourceTree = "<group>"; };
26852682
728209D32702AE9300B5F018 /* MSIDBackgroundTaskManagerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBackgroundTaskManagerTests.m; sourceTree = "<group>"; };
2686-
728ABACB2E5A3B2800FCE434 /* MSIDWPJKeyPairWithCert+TransportKey.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MSIDWPJKeyPairWithCert+TransportKey.h"; sourceTree = "<group>"; };
2687-
728ABACD2E5A418F00FCE434 /* MSIDWPJKeyPairWithCert+TransportKey.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "MSIDWPJKeyPairWithCert+TransportKey.m"; sourceTree = "<group>"; };
26882683
728D9E4528245DD7001D990F /* MSIDTestSecureEnclaveKeyPairGenerator.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDTestSecureEnclaveKeyPairGenerator.m; sourceTree = "<group>"; };
26892684
728D9E4828247D4C001D990F /* MSIDTestSecureEnclaveKeyPairGenerator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDTestSecureEnclaveKeyPairGenerator.h; sourceTree = "<group>"; };
26902685
729357E72DD810C70001D03C /* MSIDNonceTokenRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDNonceTokenRequest.h; sourceTree = "<group>"; };
@@ -5213,8 +5208,6 @@
52135208
B2C0747E246B70DC0008D701 /* crypto */ = {
52145209
isa = PBXGroup;
52155210
children = (
5216-
728ABACD2E5A418F00FCE434 /* MSIDWPJKeyPairWithCert+TransportKey.m */,
5217-
728ABACB2E5A3B2800FCE434 /* MSIDWPJKeyPairWithCert+TransportKey.h */,
52185211
B27893792470CAF200627C28 /* mac */,
52195212
B2C0748E246B71470008D701 /* MSIDAssymetricKeyGenerating.h */,
52205213
B2C07490246B735B0008D701 /* MSIDAssymetricKeyKeychainGenerator.h */,
@@ -6182,7 +6175,6 @@
61826175
A07EB427259D0C6B00783943 /* MSIDThrottlingService.h in Headers */,
61836176
9658103120C7E1180025F4A4 /* MSIDWebviewResponse.h in Headers */,
61846177
1E707FDF2407335700716148 /* MSIDBrokerNativeAppOperationResponse.h in Headers */,
6185-
728ABACC2E5A3B4E00FCE434 /* MSIDWPJKeyPairWithCert+TransportKey.h in Headers */,
61866178
B28BDA7F217E964B003E5670 /* MSIDB2CTokenResponse.h in Headers */,
61876179
96B8D57D20946D2600E3F4A6 /* MSIDPkce.h in Headers */,
61886180
B286B9912389DC47007833AD /* MSIDIndividualClaimRequest.h in Headers */,
@@ -7438,7 +7430,6 @@
74387430
23C8981A2C892A3800071482 /* MSIDBrowserNativeMessageGetSupportedContractsResponse.m in Sources */,
74397431
B286B9992389DC9D007833AD /* MSIDSSOExtensionSilentTokenRequest.m in Sources */,
74407432
B2C7089921991D0000D917B8 /* MSIDAADV2BrokerResponse.m in Sources */,
7441-
728ABACE2E5A41A800FCE434 /* MSIDWPJKeyPairWithCert+TransportKey.m in Sources */,
74427433
B20E3CB61FC4FE400029C097 /* MSIDOAuth2Constants.m in Sources */,
74437434
B2BE924D21A2331A00F5AB8C /* MSIDTelemetryAuthorityValidationEvent.m in Sources */,
74447435
B2807FF9204CAFDF00944D89 /* MSIDHelpers.m in Sources */,
@@ -8151,7 +8142,6 @@
81518142
239E3BBF23E1004F00F7A50A /* MSIDClientSDKType.m in Sources */,
81528143
23B39ABD209BD47D000AA905 /* MSIDB2CAuthorityResolver.m in Sources */,
81538144
B2F671E92467A34400649855 /* MSIDAuthorizationCodeResult.m in Sources */,
8154-
728ABACF2E5A41A800FCE434 /* MSIDWPJKeyPairWithCert+TransportKey.m in Sources */,
81558145
23C10A9F2B40D9350063D97C /* MSIDBrowserNativeMessageSignOutResponse.m in Sources */,
81568146
23FB5C2B225517AA002BF1EB /* MSIDIndividualClaimRequestAdditionalInfo.m in Sources */,
81578147
1E707FDD2406FA9200716148 /* MSIDBrokerBrowserOperationResponse.m in Sources */,

IdentityCore/src/MSIDConstants.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,6 @@ extern NSString * _Nonnull const MSID_FLIGHT_IGNORE_COOKIES_IN_DUNA_RESUME;
230230
*/
231231
extern NSString * _Nonnull const MSID_FLIGHT_DISABLE_REMOVE_ACCOUNT_ARTIFACTS;
232232

233+
extern NSString * _Nonnull const MSID_FLIGHT_DISABLE_QUERYING_STK;
234+
233235
#define METHODANDLINE [NSString stringWithFormat:@"%s [Line %d]", __PRETTY_FUNCTION__, __LINE__]

IdentityCore/src/MSIDConstants.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,7 @@
9494
// Making the flight string short to avoid legacy broker url size limit
9595
NSString *const MSID_FLIGHT_DISABLE_REMOVE_ACCOUNT_ARTIFACTS = @"disable_rm_metadata";
9696

97+
NSString *const MSID_FLIGHT_DISABLE_QUERYING_STK = @"disable_querying_stk";
98+
9799

98100
#define METHODANDLINE [NSString stringWithFormat:@"%s [Line %d]", __PRETTY_FUNCTION__, __LINE__]

IdentityCore/src/cache/crypto/MSIDWPJKeyPairWithCert+TransportKey.h

Lines changed: 0 additions & 33 deletions
This file was deleted.

IdentityCore/src/cache/crypto/MSIDWPJKeyPairWithCert+TransportKey.m

Lines changed: 0 additions & 49 deletions
This file was deleted.

IdentityCore/src/cache/crypto/MSIDWPJKeyPairWithCert.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ typedef NS_ENUM(NSInteger, MSIDWPJKeychainAccessGroup)
6363
certificate:(SecCertificateRef)certificate
6464
certificateIssuer:(nullable NSString *)issuer;
6565

66+
- (nullable instancetype)initializePrivateTransportKeyRef:(SecKeyRef)privateTransportKeyRef;
6667
@end
6768

6869
NS_ASSUME_NONNULL_END

IdentityCore/src/cache/crypto/MSIDWPJKeyPairWithCert.m

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ @interface MSIDWPJKeyPairWithCert()
3333
@property (nonatomic) NSString *certificateSubject;
3434
@property (nonatomic) NSString *certificateIssuer;
3535
@property (nonatomic) SecKeyRef privateKeyRef;
36+
@property (nonatomic) SecKeyRef privateTransportKeyRef;
3637

3738
@end
3839

@@ -88,6 +89,30 @@ - (nullable instancetype)initWithPrivateKey:(SecKeyRef)privateKey
8889
return self;
8990
}
9091

92+
- (nullable instancetype)initializePrivateTransportKeyRef:(nonnull SecKeyRef)privateTransportKeyRef
93+
{
94+
if (self && privateTransportKeyRef)
95+
{
96+
if (_privateTransportKeyRef != privateTransportKeyRef)
97+
{
98+
if (_privateTransportKeyRef)
99+
{
100+
CFReleaseNull(_privateTransportKeyRef);
101+
_privateTransportKeyRef = NULL;
102+
}
103+
104+
_privateTransportKeyRef = privateTransportKeyRef;
105+
106+
if (_privateTransportKeyRef)
107+
{
108+
CFRetain(_privateTransportKeyRef);
109+
}
110+
}
111+
}
112+
return self;
113+
}
114+
115+
91116
- (void)dealloc
92117
{
93118
if (_certificateRef)
@@ -104,7 +129,7 @@ - (void)dealloc
104129

105130
if (_privateTransportKeyRef)
106131
{
107-
CFRelease(_privateTransportKeyRef);
132+
CFReleaseNull(_privateTransportKeyRef);
108133
_privateTransportKeyRef = NULL;
109134
}
110135
}

IdentityCore/src/workplacejoin/MSIDWorkPlaceJoinUtilBase.m

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
#import "MSIDWorkPlaceJoinConstants.h"
2828
#import "MSIDWPJKeyPairWithCert.h"
2929
#import "MSIDWPJMetadata.h"
30-
#import "MSIDWPJKeyPairWithCert+TransportKey.h"
30+
#import "MSIDFlightManager.h"
31+
#import "MSIDConstants.h"
3132

3233
static NSString *kWPJPrivateKeyIdentifier = @"com.microsoft.workplacejoin.privatekey\0";
3334
static NSString *kECPrivateKeyTagSuffix = @"-EC";
@@ -381,13 +382,16 @@ + (MSIDWPJKeyPairWithCert *)getWPJKeysWithTenantId:(__unused NSString *)tenantId
381382
{
382383
defaultKeys.keyChainVersion = MSIDWPJKeychainAccessGroupV2;
383384
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, context, @"Returning EC private device key from default registration.");
385+
#if TARGET_OS_IPHONE
386+
bool isQueryingDisabledViaFlight = [MSIDFlightManager.sharedInstance boolForKey:MSID_FLIGHT_DISABLE_QUERYING_STK];
384387
// Query the session transport key only for iOS.
385388
// 1P apps use transport key to decrypt ECDH JWE responses when redeeming bound regular refresh tokens
386389
id keyType = privateKeyAttributes[(__bridge id)kSecAttrKeyType];
387-
if (keyType && [keyType isEqual: (__bridge id)kSecAttrKeyTypeECSECPrimeRandom])
390+
if (!isQueryingDisabledViaFlight && keyType && [keyType isEqual: (__bridge id)kSecAttrKeyTypeECSECPrimeRandom])
388391
{
389-
defaultKeys.privateTransportKeyRef = [self getSessionTransportKeyRefFromSecureEnclaveForTenantId:tenantId context:context];
392+
[defaultKeys initializePrivateTransportKeyRef:[self getSessionTransportKeyRefFromSecureEnclaveForTenantId:tenantId context:context]];
390393
}
394+
#endif
391395
return defaultKeys;
392396
}
393397

0 commit comments

Comments
 (0)