SUSignatures

This commit is contained in:
Kornel
2018-09-15 15:54:08 +01:00
parent 8b88183c7d
commit 8ad1f57672
8 changed files with 77 additions and 14 deletions
+16
View File
@@ -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 = "<group>"; };
5AEF45D9189D1CC90030D7DC /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Sparkle.strings; sourceTree = "<group>"; };
5AF04875214D2E5F00B5789F /* SUSignatures.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SUSignatures.h; sourceTree = "<group>"; };
5AF04876214D2E5F00B5789F /* SUSignatures.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SUSignatures.m; sourceTree = "<group>"; };
5AF6C74C1AEA40760014A3AB /* SUInstallerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUInstallerTest.m; sourceTree = "<group>"; };
5AF6C74E1AEA46D10014A3AB /* test.pkg */ = {isa = PBXFileReference; lastKnownFileType = file; path = test.pkg; sourceTree = "<group>"; };
5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUDSAVerifierTest.m; sourceTree = "<group>"; };
@@ -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 = "<group>";
};
5AF04874214D2E2800B5789F /* Signatures */ = {
isa = PBXGroup;
children = (
5AF04875214D2E5F00B5789F /* SUSignatures.h */,
5AF04876214D2E5F00B5789F /* SUSignatures.m */,
);
name = Signatures;
sourceTree = "<group>";
};
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 */,
+2 -1
View File
@@ -15,13 +15,14 @@
#import <Foundation/Foundation.h>
#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;
+5 -5
View File
@@ -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];
+1 -1
View File
@@ -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;
}
+21
View File
@@ -0,0 +1,21 @@
//
// SUSignatures.h
// Sparkle
//
// Created by Kornel on 15/09/2018.
// Copyright © 2018 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
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
+23
View File
@@ -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 <assert.h>
@implementation SUSignatures
@synthesize dsaSignature;
- (instancetype)initWithDsa:(NSString * _Nullable)maybeDsa ed:(NSString * _Nullable)maybeEd25519
{
self = [super init];
if (self) {
self.dsaSignature = maybeDsa;
}
return self;
}
@end
+2 -1
View File
@@ -9,11 +9,12 @@
#import <Foundation/Foundation.h>
@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;
+7 -6
View File
@@ -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;