diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 911e2e7d..569d7159 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -118,6 +118,8 @@ 5AE459001C34118500E3BB47 /* SUUpdaterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 14950074195FDF5900BC5B5B /* SUUpdaterTest.m */; }; 5AE459021C34118500E3BB47 /* SUVersionComparisonTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 61227A150DB548B800AB99EA /* SUVersionComparisonTest.m */; }; 5AE7E1111DC81AD3009C2C12 /* AppIcon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 5AE7E10E1DC81ACA009C2C12 /* AppIcon.icns */; }; + 5AF04877214D2E5F00B5789F /* SUSignatures.h in Headers */ = {isa = PBXBuildFile; fileRef = 5AF04875214D2E5F00B5789F /* SUSignatures.h */; }; + 5AF04878214D2E5F00B5789F /* SUSignatures.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AF04876214D2E5F00B5789F /* SUSignatures.m */; }; 5AF6C74F1AEA46D10014A3AB /* test.pkg in Resources */ = {isa = PBXBuildFile; fileRef = 5AF6C74E1AEA46D10014A3AB /* test.pkg */; }; 5AF6C7541AEA49840014A3AB /* SUInstallerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AF6C74C1AEA40760014A3AB /* SUInstallerTest.m */; }; 5AF9DC3C1981DBEE001EA135 /* SUDSAVerifierTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */; }; @@ -644,6 +646,8 @@ 5AE13FBC1E0DA39B000D2C2C /* libbz2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libbz2.tbd; path = usr/lib/libbz2.tbd; sourceTree = SDKROOT; }; 5AE7E10E1DC81ACA009C2C12 /* AppIcon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = AppIcon.icns; sourceTree = ""; }; 5AEF45D9189D1CC90030D7DC /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Sparkle.strings; sourceTree = ""; }; + 5AF04875214D2E5F00B5789F /* SUSignatures.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SUSignatures.h; sourceTree = ""; }; + 5AF04876214D2E5F00B5789F /* SUSignatures.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SUSignatures.m; sourceTree = ""; }; 5AF6C74C1AEA40760014A3AB /* SUInstallerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUInstallerTest.m; sourceTree = ""; }; 5AF6C74E1AEA46D10014A3AB /* test.pkg */ = {isa = PBXFileReference; lastKnownFileType = file; path = test.pkg; sourceTree = ""; }; 5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUDSAVerifierTest.m; sourceTree = ""; }; @@ -1091,6 +1095,7 @@ 089C1665FE841158C02AAC07 /* Framework Resources */, 618FA6DB0DB485440026945C /* Installation */, 61B5F8F309C4CE5900B25A18 /* Other Sources */, + 5AF04874214D2E2800B5789F /* Signatures */, 6101354A0DD25B7F0049ACDF /* Unarchiving */, 61F83F6E0DBFE07A006FDD30 /* Update Control */, 61299B3A09CB056100B7442F /* User Interface */, @@ -1166,6 +1171,15 @@ path = generate_appcast; sourceTree = ""; }; + 5AF04874214D2E2800B5789F /* Signatures */ = { + isa = PBXGroup; + children = ( + 5AF04875214D2E5F00B5789F /* SUSignatures.h */, + 5AF04876214D2E5F00B5789F /* SUSignatures.m */, + ); + name = Signatures; + sourceTree = ""; + }; 5D06E8D90FD68C95005AE3F6 /* Binary Delta */ = { isa = PBXGroup; children = ( @@ -1443,6 +1457,7 @@ 723B25301CEAB3A600909873 /* bscommon.h in Headers */, 611142E910FB1BE5009810AA /* bspatch.h in Headers */, 61299B3609CB04E000B7442F /* Sparkle.h in Headers */, + 5AF04877214D2E5F00B5789F /* SUSignatures.h in Headers */, 61B5FC0D09C4FC8200B25A18 /* SUAppcast.h in Headers */, 61B5FC7009C51F4A00B25A18 /* SUAppcastItem.h in Headers */, 34074BA71FEAC417001CB3A5 /* SPUDownloaderDeprecated.h in Headers */, @@ -2075,6 +2090,7 @@ 723B252D1CEAB3A600909873 /* bscommon.c in Sources */, 34074B9E1FEABD5A001CB3A5 /* SPUDownloadData.m in Sources */, 5D06E8EB0FD68CE4005AE3F6 /* bspatch.c in Sources */, + 5AF04878214D2E5F00B5789F /* SUSignatures.m in Sources */, 61B5FBB709C4FAFF00B25A18 /* SUAppcast.m in Sources */, 61B5FC6F09C51F4900B25A18 /* SUAppcastItem.m in Sources */, 72316BDF1E0E17910039EFD9 /* SUApplicationInfo.m in Sources */, diff --git a/Sparkle/SUAppcastItem.h b/Sparkle/SUAppcastItem.h index 5c861ddd..c0380dd8 100644 --- a/Sparkle/SUAppcastItem.h +++ b/Sparkle/SUAppcastItem.h @@ -15,13 +15,14 @@ #import #endif #import "SUExport.h" +@class SUSignatures; SU_EXPORT @interface SUAppcastItem : NSObject @property (copy, readonly) NSString *title; @property (copy, readonly) NSString *dateString; @property (copy, readonly) NSString *itemDescription; @property (strong, readonly) NSURL *releaseNotesURL; -@property (copy, readonly) NSString *DSASignature; +@property (strong, readonly) SUSignatures *signatures; @property (copy, readonly) NSString *minimumSystemVersion; @property (copy, readonly) NSString *maximumSystemVersion; @property (strong, readonly) NSURL *fileURL; diff --git a/Sparkle/SUAppcastItem.m b/Sparkle/SUAppcastItem.m index 89e4580a..359a5516 100644 --- a/Sparkle/SUAppcastItem.m +++ b/Sparkle/SUAppcastItem.m @@ -9,7 +9,7 @@ #import "SUAppcastItem.h" #import "SULog.h" #import "SUConstants.h" - +#import "SUSignatures.h" #include "AppKitPrevention.h" @@ -18,7 +18,7 @@ @property (copy, readwrite) NSString *dateString; @property (copy, readwrite) NSString *itemDescription; @property (strong, readwrite) NSURL *releaseNotesURL; -@property (copy, readwrite) NSString *DSASignature; +@property (strong, readwrite) SUSignatures *signatures; @property (copy, readwrite) NSString *minimumSystemVersion; @property (copy, readwrite) NSString *maximumSystemVersion; @property (strong, readwrite) NSURL *fileURL; @@ -34,7 +34,7 @@ @synthesize dateString; @synthesize deltaUpdates; @synthesize displayVersionString; -@synthesize DSASignature; +@synthesize signatures; @synthesize fileURL; @synthesize contentLength = _contentLength; @synthesize infoURL; @@ -156,10 +156,10 @@ self.fileURL = [NSURL URLWithString:fileURLString]; } if (enclosure) { - self.DSASignature = [enclosure objectForKey:SUAppcastAttributeDSASignature]; + self.signatures = [[SUSignatures alloc] initWithDsa:[enclosure objectForKey:SUAppcastAttributeDSASignature] ed:nil]; self.osString = [enclosure objectForKey:SUAppcastAttributeOsType]; } - + self.versionString = newVersion; self.minimumSystemVersion = [dict objectForKey:SUAppcastElementMinimumSystemVersion]; self.maximumSystemVersion = [dict objectForKey:SUAppcastElementMaximumSystemVersion]; diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index fe8c05dc..f470950d 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -366,7 +366,7 @@ // Currently unsafe archives are the only case where we can prevalidate before extraction, but that could change in the future BOOL needsPrevalidation = [[unarchiver class] unsafeIfArchiveIsNotValidated]; - self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:self.downloadPath dsaSignature:self.updateItem.DSASignature host:self.host performingPrevalidation:needsPrevalidation]; + self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:self.downloadPath signatures:self.updateItem.signatures host:self.host performingPrevalidation:needsPrevalidation]; success = self.updateValidator.canValidate; } diff --git a/Sparkle/SUSignatures.h b/Sparkle/SUSignatures.h new file mode 100644 index 00000000..5c54e6d3 --- /dev/null +++ b/Sparkle/SUSignatures.h @@ -0,0 +1,21 @@ +// +// SUSignatures.h +// Sparkle +// +// Created by Kornel on 15/09/2018. +// Copyright © 2018 Sparkle Project. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface SUSignatures : NSObject { +} +@property (nullable) NSString *dsaSignature; + +- (instancetype)initWithDsa:(NSString * _Nullable)dsa ed:(NSString * _Nullable)ed; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Sparkle/SUSignatures.m b/Sparkle/SUSignatures.m new file mode 100644 index 00000000..8c4dce6e --- /dev/null +++ b/Sparkle/SUSignatures.m @@ -0,0 +1,23 @@ +// +// SUSignatures.m +// Sparkle +// +// Created by Kornel on 15/09/2018. +// Copyright © 2018 Sparkle Project. All rights reserved. +// + +#import "SUSignatures.h" +#import + +@implementation SUSignatures +@synthesize dsaSignature; + +- (instancetype)initWithDsa:(NSString * _Nullable)maybeDsa ed:(NSString * _Nullable)maybeEd25519 +{ + self = [super init]; + if (self) { + self.dsaSignature = maybeDsa; + } + return self; +} +@end diff --git a/Sparkle/SUUpdateValidator.h b/Sparkle/SUUpdateValidator.h index 0a5f14c6..040b1220 100644 --- a/Sparkle/SUUpdateValidator.h +++ b/Sparkle/SUUpdateValidator.h @@ -9,11 +9,12 @@ #import @class SUHost; +@class SUSignatures; @interface SUUpdateValidator : NSObject // Pass YES to performingPrevalidation if archive validation must be done immediately, before extraction -- (instancetype)initWithDownloadPath:(NSString *)downloadPath dsaSignature:(NSString *)dsaSignature host:(SUHost *)host performingPrevalidation:(BOOL)performingPrevalidation; +- (instancetype)initWithDownloadPath:(NSString *)downloadPath signatures:(SUSignatures *)signatures host:(SUHost *)host performingPrevalidation:(BOOL)performingPrevalidation; // Indicates whether we can perform (post) validation later @property (nonatomic, readonly) BOOL canValidate; diff --git a/Sparkle/SUUpdateValidator.m b/Sparkle/SUUpdateValidator.m index e00652ef..e6dcffed 100644 --- a/Sparkle/SUUpdateValidator.m +++ b/Sparkle/SUUpdateValidator.m @@ -12,7 +12,7 @@ #import "SUInstaller.h" #import "SUHost.h" #import "SULog.h" - +#import "SUSignatures.h" #include "AppKitPrevention.h" @@ -20,7 +20,7 @@ @property (nonatomic, readonly) SUHost *host; @property (nonatomic, readonly) BOOL prevalidatedDsaSignature; -@property (nonatomic, readonly) NSString *dsaSignature; +@property (nonatomic, readonly) SUSignatures *signatures; @property (nonatomic, readonly) NSString *downloadPath; @end @@ -30,10 +30,10 @@ @synthesize host = _host; @synthesize canValidate = _canValidate; @synthesize prevalidatedDsaSignature = _prevalidatedDsaSignature; -@synthesize dsaSignature = _dsaSignature; +@synthesize signatures = _signatures; @synthesize downloadPath = _downloadPath; -- (instancetype)initWithDownloadPath:(NSString *)downloadPath dsaSignature:(NSString *)dsaSignature host:(SUHost *)host performingPrevalidation:(BOOL)performingPrevalidation +- (instancetype)initWithDownloadPath:(NSString *)downloadPath signatures:(SUSignatures *)signatures host:(SUHost *)host performingPrevalidation:(BOOL)performingPrevalidation { self = [super init]; if (self != nil) { @@ -41,6 +41,7 @@ BOOL prevalidatedDsaSignature; if (performingPrevalidation) { NSString *publicDSAKey = host.publicDSAKey; + NSString *dsaSignature = signatures.dsaSignature; if (publicDSAKey == nil) { prevalidatedDsaSignature = NO; @@ -64,7 +65,7 @@ _canValidate = canValidate; _prevalidatedDsaSignature = prevalidatedDsaSignature; _downloadPath = [downloadPath copy]; - _dsaSignature = [dsaSignature copy]; + _signatures = [signatures copy]; _host = host; } return self; @@ -74,7 +75,7 @@ { assert(self.canValidate); - NSString *DSASignature = self.dsaSignature; + NSString *DSASignature = self.signatures.dsaSignature; NSString *publicDSAKey = self.host.publicDSAKey; NSString *downloadPath = self.downloadPath; SUHost *host = self.host;