mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Compare commits
31
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca0b95d1cf | ||
|
|
a3125fc5d1 | ||
|
|
0458fc1119 | ||
|
|
73de6c9e91 | ||
|
|
431810c1e8 | ||
|
|
ae7ac44ce0 | ||
|
|
af28a4da83 | ||
|
|
c5af81cfaa | ||
|
|
650c7d8eab | ||
|
|
d2d594b681 | ||
|
|
2ad654764a | ||
|
|
f4fefd8ebc | ||
|
|
9863b8439c | ||
|
|
4043263e48 | ||
|
|
747250d0d8 | ||
|
|
06f4a5e52c | ||
|
|
1f6113eae4 | ||
|
|
d4b498c94d | ||
|
|
f765ea6c72 | ||
|
|
6c05c09161 | ||
|
|
262fac60ad | ||
|
|
9f53310253 | ||
|
|
a819fbbfa9 | ||
|
|
08f55bce01 | ||
|
|
51f26f4ae1 | ||
|
|
58d568727b | ||
|
|
6c56b0a9f0 | ||
|
|
ae1c516afb | ||
|
|
1de486956a | ||
|
|
ad78f264fa | ||
|
|
9ed93dd592 |
No files matched your search
@@ -41,3 +41,5 @@ Carthage/Build
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
.idea/
|
||||
@@ -1,3 +0,0 @@
|
||||
[submodule "ed25519"]
|
||||
path = ed25519
|
||||
url = https://github.com/orlp/ed25519
|
||||
@@ -4,17 +4,14 @@
|
||||
* Add delegate callbacks for fininshed download and extraction related events (Csaba Horony)
|
||||
* Don't check for updates if Do Not Disturb is on (Kornel)
|
||||
* Expose `CodesigningVerifier`, add codesign info API (sunuslee)
|
||||
* Improve 'read-only' error message (#1192) (Adrian Thomas)
|
||||
* Threading fixes:
|
||||
* Fix potential hang with `dispatch_sync` to main thread (Brian Bergstrand)
|
||||
* Fix closeCheckingWindow called from background thread (Alexey Martemyanov)
|
||||
* Improve 'read-only' error message (#1192) (Adrian Thomas)
|
||||
* New Spanish localisation (Ken Arroyo Ohori)
|
||||
* Updated Finnish language resources (Jason Pollack)
|
||||
* Hungarian localization (Csaba Horony)
|
||||
* Log more information about authentication requests (Kornel)
|
||||
* Explicitly specify types to silence "Messaging unqualified id" warning that's new in Xcode 10. Removed __has_feature(objc_generics) check and use generisc to help silence the warnings. (Kent Sutherland)
|
||||
* Fix binary delta creation on network drives (sagecook)
|
||||
* Fix compilation issues on Xcode 10 with new build system (Leo Natan)
|
||||
|
||||
# 1.19.0
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Common
|
||||
|
||||
SPARKLE_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle
|
||||
SPARKLE_RELAUNCH_TOOL_NAME = Autoupdate
|
||||
SPARKLE_BUNDLE_IDENTIFIER = com.binaryage.sparkle
|
||||
SPARKLE_RELAUNCH_TOOL_NAME = Updater
|
||||
SPARKLE_FILEOP_TOOL_NAME = fileop
|
||||
|
||||
SPARKLE_APPEND_VERSION_NUMBER = 1
|
||||
@@ -16,9 +16,9 @@ SPARKLE_AUTOMATED_DOWNGRADES = 0
|
||||
SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
|
||||
|
||||
SPARKLE_VERSION_MAJOR = 1
|
||||
SPARKLE_VERSION_MINOR = 21
|
||||
SPARKLE_VERSION_MINOR = 20
|
||||
SPARKLE_VERSION_PATCH = 0
|
||||
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
|
||||
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)b1
|
||||
|
||||
CURRENT_PROJECT_VERSION = $(SPARKLE_VERSION)
|
||||
ALWAYS_SEARCH_USER_PATHS = NO
|
||||
@@ -26,7 +26,7 @@ ENABLE_STRICT_OBJC_MSGSEND = YES
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = YES
|
||||
GCC_INLINES_ARE_PRIVATE_EXTERN = YES
|
||||
ARCHS = $(ARCHS_STANDARD)
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.7
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.9
|
||||
PRODUCT_NAME = ${TARGET_NAME}
|
||||
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier}
|
||||
|
||||
@@ -88,4 +88,4 @@ CLANG_ENABLE_MODULES[sdk=macosx10.8] = NO
|
||||
WARNING_CFLAGS_EXTRA = -Wno-custom-atomic-properties -Wno-implicit-atomic-properties
|
||||
|
||||
// Turn on all warnings, then disable a few which are almost impossible to avoid
|
||||
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-arc-repeated-use-of-weak -Wno-auto-import -Wno-gnu-zero-variadic-macro-arguments $(WARNING_CFLAGS_EXTRA)
|
||||
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-arc-repeated-use-of-weak -Wno-auto-import -Wno-gnu-zero-variadic-macro-arguments -Wno-dollar-in-identifier-extension $(WARNING_CFLAGS_EXTRA)
|
||||
@@ -1,7 +0,0 @@
|
||||
// Generate Appcast only
|
||||
|
||||
#include "ConfigSwift.xcconfig"
|
||||
|
||||
SWIFT_OBJC_BRIDGING_HEADER = generate_keys/Bridging-Header.h
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11
|
||||
PRODUCT_NAME = generate_keys
|
||||
@@ -1,4 +0,0 @@
|
||||
// Generate Appcast Debug
|
||||
|
||||
#include "ConfigGenerateKeys.xcconfig"
|
||||
#include "ConfigSwiftDebug.xcconfig"
|
||||
@@ -1,4 +0,0 @@
|
||||
// Generate Appcast Release
|
||||
|
||||
#include "ConfigGenerateKeys.xcconfig"
|
||||
#include "ConfigSwiftRelease.xcconfig"
|
||||
@@ -19,8 +19,6 @@ if [ "$ACTION" = "" ] ; then
|
||||
cp -R "$SRCROOT/bin" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp "$CONFIGURATION_BUILD_DIR/BinaryDelta" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp "$CONFIGURATION_BUILD_DIR/generate_appcast" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp "$CONFIGURATION_BUILD_DIR/generate_keys" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp "$CONFIGURATION_BUILD_DIR/sign_update" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
|
||||
@@ -29,8 +27,6 @@ if [ "$ACTION" = "" ] ; then
|
||||
if [ "$CONFIGURATION" = "Release" ] ; then
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/BinaryDelta.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/generate_appcast.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/generate_keys.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/sign_update.dSYM" "$CONFIGURATION_BUILD_DIR/staging/bin"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle Test App.app.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
cp -R "$CONFIGURATION_BUILD_DIR/Sparkle.framework.dSYM" "$CONFIGURATION_BUILD_DIR/staging"
|
||||
fi
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
http://you.com/app/2.0.html
|
||||
</sparkle:releaseNotesLink>
|
||||
<pubDate>Wed, 09 Jan 2006 19:20:11 +0000</pubDate>
|
||||
<!-- Sparkle 1.21+ uses sparkle::edSignature="ed25519" instead of sparkle::dsaSignature="deprecated DSA" -->
|
||||
<enclosure url="http://you.com/app/Your%20Great%20App%202.0.zip" sparkle:version="2.0" length="1623481" type="application/octet-stream" sparkle:dsaSignature="BAFJW4B6B1K1JyW30nbkBwainOzrN6EQuAh" />
|
||||
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
@@ -21,7 +20,6 @@
|
||||
http://you.com/app/1.5.html
|
||||
</sparkle:releaseNotesLink>
|
||||
<pubDate>Wed, 01 Jan 2006 12:20:11 +0000</pubDate>
|
||||
<!-- Sparkle 1.21+ uses sparkle::edSignature="ed25519" instead of sparkle::dsaSignature="deprecated DSA" -->
|
||||
<enclosure url="http://you.com/app/Your%20Great%20App%201.5.zip" sparkle:version="1.5" length="1472893" type="application/octet-stream" sparkle:dsaSignature="234818feCa1JyW30nbkBwainOzrN6EQuAh" />
|
||||
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
@@ -33,7 +31,6 @@
|
||||
http://you.com/app/1.4.html
|
||||
</sparkle:releaseNotesLink>
|
||||
<pubDate>Wed, 25 Dec 2005 12:20:11 +0000</pubDate>
|
||||
<!-- Sparkle 1.21+ uses sparkle::edSignature="ed25519" instead of sparkle::dsaSignature="deprecated DSA" -->
|
||||
<enclosure url="http://you.com/app/Your%20Great%20App%201.4.zip" sparkle:version="241" sparkle:shortVersionString="1.4" sparkle:dsaSignature="MC0CFBfeCa1JyW30nbkBwainOzrN6EQuAh=" length="1472349" type="application/octet-stream" />
|
||||
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
|
||||
</item>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Sparkle"
|
||||
s.version = "1.20.0"
|
||||
s.version = "1.20.0b1"
|
||||
s.summary = "A software update framework for macOS"
|
||||
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
|
||||
s.homepage = "http://sparkle-project.org"
|
||||
|
||||
+167
-433
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0920"
|
||||
LastUpgradeVersion = "1020"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -26,7 +26,6 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
@@ -56,7 +55,6 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = ""
|
||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||
language = ""
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0920"
|
||||
LastUpgradeVersion = "1020"
|
||||
version = "2.0">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -26,7 +26,6 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
@@ -56,7 +55,6 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = ""
|
||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||
language = ""
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
|
||||
@@ -1,16 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0920"
|
||||
LastUpgradeVersion = "1020"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "726B2B5C1C645FC900388755"
|
||||
BuildableName = "UI Tests.xctest"
|
||||
BlueprintName = "UI Tests"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
@@ -31,13 +46,21 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "726B2B5C1C645FC900388755"
|
||||
BuildableName = "UI Tests.xctest"
|
||||
BlueprintName = "UI Tests"
|
||||
ReferencedContainer = "container:Sparkle.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0920"
|
||||
LastUpgradeVersion = "1020"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -26,7 +26,6 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
@@ -46,7 +45,6 @@
|
||||
buildConfiguration = "Release"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
language = ""
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
|
||||
Vendored
+1
-2
@@ -15,14 +15,13 @@
|
||||
#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 (strong, readonly) SUSignatures *signatures;
|
||||
@property (copy, readonly) NSString *DSASignature;
|
||||
@property (copy, readonly) NSString *minimumSystemVersion;
|
||||
@property (copy, readonly) NSString *maximumSystemVersion;
|
||||
@property (strong, readonly) NSURL *fileURL;
|
||||
|
||||
Vendored
+5
-5
@@ -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 (strong, readwrite) SUSignatures *signatures;
|
||||
@property (copy, readwrite) NSString *DSASignature;
|
||||
@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 signatures;
|
||||
@synthesize DSASignature;
|
||||
@synthesize fileURL;
|
||||
@synthesize contentLength = _contentLength;
|
||||
@synthesize infoURL;
|
||||
@@ -156,10 +156,10 @@
|
||||
self.fileURL = [NSURL URLWithString:fileURLString];
|
||||
}
|
||||
if (enclosure) {
|
||||
self.signatures = [[SUSignatures alloc] initWithDsa:[enclosure objectForKey:SUAppcastAttributeDSASignature] ed:[enclosure objectForKey:SUAppcastAttributeEDSignature]];
|
||||
self.DSASignature = [enclosure objectForKey:SUAppcastAttributeDSASignature];
|
||||
self.osString = [enclosure objectForKey:SUAppcastAttributeOsType];
|
||||
}
|
||||
|
||||
|
||||
self.versionString = newVersion;
|
||||
self.minimumSystemVersion = [dict objectForKey:SUAppcastElementMinimumSystemVersion];
|
||||
self.maximumSystemVersion = [dict objectForKey:SUAppcastElementMaximumSystemVersion];
|
||||
|
||||
Vendored
+12
-10
@@ -357,20 +357,18 @@
|
||||
id<SUUpdaterPrivate> updater = self.updater;
|
||||
id<SUUnarchiverProtocol> unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:self.host.bundlePath decryptionPassword:updater.decryptionPassword];
|
||||
|
||||
BOOL success = NO;
|
||||
BOOL success;
|
||||
if (!unarchiver) {
|
||||
SULog(SULogLevelError, @"Error: No valid unarchiver for %@!", self.downloadPath);
|
||||
|
||||
success = NO;
|
||||
} else {
|
||||
self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:self.downloadPath signatures:self.updateItem.signatures host:self.host];
|
||||
|
||||
// Currently unsafe archives are the only case where we can prevalidate before extraction, but that could change in the future
|
||||
BOOL needsPrevalidation = [[unarchiver class] mustValidateBeforeExtraction];
|
||||
|
||||
if (needsPrevalidation) {
|
||||
success = [self.updateValidator validateDownloadPath];
|
||||
} else {
|
||||
success = YES;
|
||||
}
|
||||
BOOL needsPrevalidation = [[unarchiver class] unsafeIfArchiveIsNotValidated];
|
||||
|
||||
self.updateValidator = [[SUUpdateValidator alloc] initWithDownloadPath:self.downloadPath dsaSignature:self.updateItem.DSASignature host:self.host performingPrevalidation:needsPrevalidation];
|
||||
|
||||
success = self.updateValidator.canValidate;
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
@@ -434,6 +432,10 @@
|
||||
|
||||
- (void)installWithToolAndRelaunch:(BOOL)relaunch
|
||||
{
|
||||
// TotalFinder-related HACK to prevent relaunch, installer does relaunch automatically
|
||||
// same applies for TotalTerminal and Asepsis
|
||||
relaunch = NO;
|
||||
|
||||
// Perhaps a poor assumption but: if we're not relaunching, we assume we shouldn't be showing any UI either. Because non-relaunching installations are kicked off without any user interaction, we shouldn't be interrupting them.
|
||||
[self installWithToolAndRelaunch:relaunch displayingUserInterface:relaunch];
|
||||
}
|
||||
|
||||
Vendored
+8
-26
@@ -90,15 +90,6 @@ static NSDictionary *infoForFile(FTSENT *ent)
|
||||
INFO_SIZE_KEY: @(size) };
|
||||
}
|
||||
|
||||
static bool isSymLink(const FTSENT *ent)
|
||||
{
|
||||
if (ent->fts_info == FTS_SL)
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool aclExists(const FTSENT *ent)
|
||||
{
|
||||
// macOS does not currently support ACLs for symlinks
|
||||
@@ -263,7 +254,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Creating version %u.%u patch...\n", majorVersion, minorVersion);
|
||||
fprintf(stderr, "Processing source, %s...", [source fileSystemRepresentation]);
|
||||
fprintf(stderr, "Processing %s...", [source fileSystemRepresentation]);
|
||||
}
|
||||
|
||||
FTSENT *ent = 0;
|
||||
@@ -329,7 +320,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nProcessing destination, %s...", [destination fileSystemRepresentation]);
|
||||
fprintf(stderr, "\nProcessing %s...", [destination fileSystemRepresentation]);
|
||||
}
|
||||
|
||||
pathBuffer[0] = 0;
|
||||
@@ -380,7 +371,7 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
// inside an application, and since we don't preserve extended attribitutes anyway
|
||||
|
||||
mode_t permissions = [info[INFO_PERMISSIONS_KEY] unsignedShortValue];
|
||||
if (!isSymLink(ent) && !IS_VALID_PERMISSIONS(permissions)) {
|
||||
if (!IS_VALID_PERMISSIONS(permissions)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
@@ -448,9 +439,6 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
}
|
||||
|
||||
NSString *temporaryFile = temporaryPatchFile(patchFile);
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nWriting to temporary file %s...", [temporaryFile fileSystemRepresentation]);
|
||||
}
|
||||
xar_t x = xar_open([temporaryFile fileSystemRepresentation], WRITE);
|
||||
if (!x) {
|
||||
if (verbose) {
|
||||
@@ -586,19 +574,13 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF
|
||||
|
||||
xar_close(x);
|
||||
|
||||
NSFileManager *filemgr;
|
||||
filemgr = [NSFileManager defaultManager];
|
||||
|
||||
[filemgr removeItemAtPath: patchFile error: NULL];
|
||||
if ([filemgr moveItemAtPath: temporaryFile toPath: patchFile error: NULL] != YES)
|
||||
{
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Failed to move temporary file, %s, to %s!\n", [temporaryFile fileSystemRepresentation], [patchFile fileSystemRepresentation]);
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
unlink([patchFile fileSystemRepresentation]);
|
||||
link([temporaryFile fileSystemRepresentation], [patchFile fileSystemRepresentation]);
|
||||
unlink([temporaryFile fileSystemRepresentation]);
|
||||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "\nDone!\n");
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
Vendored
+1
-1
@@ -33,7 +33,7 @@
|
||||
return [[path pathExtension] isEqualToString:@"delta"];
|
||||
}
|
||||
|
||||
+ (BOOL)mustValidateBeforeExtraction
|
||||
+ (BOOL)unsafeIfArchiveIsNotValidated
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
Vendored
-3
@@ -41,8 +41,6 @@ extern NSString *const SUSkippedVersionKey;
|
||||
extern NSString *const SUScheduledCheckIntervalKey;
|
||||
extern NSString *const SULastCheckTimeKey;
|
||||
extern NSString *const SUExpectsDSASignatureKey;
|
||||
extern NSString *const SUExpectsEDSignatureKey;
|
||||
extern NSString *const SUPublicEDKeyKey;
|
||||
extern NSString *const SUPublicDSAKeyKey;
|
||||
extern NSString *const SUPublicDSAKeyFileKey;
|
||||
extern NSString *const SUAutomaticallyUpdateKey;
|
||||
@@ -66,7 +64,6 @@ extern NSString *const SURelaunchToolNameKey __attribute__((deprecated("This key
|
||||
|
||||
extern NSString *const SUAppcastAttributeDeltaFrom;
|
||||
extern NSString *const SUAppcastAttributeDSASignature;
|
||||
extern NSString *const SUAppcastAttributeEDSignature;
|
||||
extern NSString *const SUAppcastAttributeShortVersionString;
|
||||
extern NSString *const SUAppcastAttributeVersion;
|
||||
extern NSString *const SUAppcastAttributeOsType;
|
||||
|
||||
Vendored
-3
@@ -33,8 +33,6 @@ NSString *const SUSkippedVersionKey = @"SUSkippedVersion";
|
||||
NSString *const SUScheduledCheckIntervalKey = @"SUScheduledCheckInterval";
|
||||
NSString *const SULastCheckTimeKey = @"SULastCheckTime";
|
||||
NSString *const SUExpectsDSASignatureKey = @"SUExpectsDSASignature";
|
||||
NSString *const SUExpectsEDSignatureKey = @"SUExpectsEDSignatureKey";
|
||||
NSString *const SUPublicEDKeyKey = @"SUPublicEDKey";
|
||||
NSString *const SUPublicDSAKeyKey = @"SUPublicDSAKey";
|
||||
NSString *const SUPublicDSAKeyFileKey = @"SUPublicDSAKeyFile";
|
||||
NSString *const SUAutomaticallyUpdateKey = @"SUAutomaticallyUpdate";
|
||||
@@ -56,7 +54,6 @@ NSString *const SURelaunchToolNameKey = @"SURelaunchToolName";
|
||||
|
||||
NSString *const SUAppcastAttributeDeltaFrom = @"sparkle:deltaFrom";
|
||||
NSString *const SUAppcastAttributeDSASignature = @"sparkle:dsaSignature";
|
||||
NSString *const SUAppcastAttributeEDSignature = @"sparkle:edSignature";
|
||||
NSString *const SUAppcastAttributeShortVersionString = @"sparkle:shortVersionString";
|
||||
NSString *const SUAppcastAttributeVersion = @"sparkle:version";
|
||||
NSString *const SUAppcastAttributeOsType = @"sparkle:os";
|
||||
|
||||
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// SUDSAVerifier.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/16/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
// Includes code by Zach Waldowski on 10/18/13.
|
||||
// Copyright 2014 Big Nerd Ranch. Licensed under MIT.
|
||||
//
|
||||
// Includes code from Plop by Mark Hamlin.
|
||||
// Copyright 2011 Mark Hamlin. Licensed under BSD.
|
||||
//
|
||||
|
||||
#ifndef SUDSAVERIFIER_H
|
||||
#define SUDSAVERIFIER_H
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1090
|
||||
@interface NSData (SUDSAVerifier)
|
||||
- (id)initWithBase64Encoding:(NSString *)base64String;
|
||||
@end
|
||||
#endif
|
||||
|
||||
@interface SUDSAVerifier : NSObject
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString;
|
||||
|
||||
- (instancetype)initWithPublicKeyData:(NSData *)data;
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signature:(NSData *)signature;
|
||||
- (BOOL)verifyStream:(NSInputStream *)stream signature:(NSData *)signature;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
+34
-82
@@ -12,46 +12,43 @@
|
||||
// Copyright 2011 Mark Hamlin. Licensed under BSD.
|
||||
//
|
||||
|
||||
#import "SUSignatureVerifier.h"
|
||||
#import "SUDSAVerifier.h"
|
||||
#import "SULog.h"
|
||||
#import "SUSignatures.h"
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
#import "../ed25519/src/ed25519.h" // run `git submodule update --init` if you get an erorr here
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUSignatureVerifier ()
|
||||
@property (readonly) SUPublicKeys *pubKeys;
|
||||
@end
|
||||
|
||||
@implementation SUSignatureVerifier {
|
||||
@implementation SUDSAVerifier {
|
||||
SecKeyRef _secKey;
|
||||
}
|
||||
|
||||
@synthesize pubKeys = _pubKeys;
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withSignatures:(SUSignatures *)signatures withPublicKeys:(SUPublicKeys *)pkeys
|
||||
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString
|
||||
{
|
||||
SUSignatureVerifier *verifier = [(SUSignatureVerifier *)[self alloc] initWithPublicKeys:pkeys];
|
||||
if (!encodedSignature) {
|
||||
SULog(SULogLevelError, @"There is no DSA signature to check");
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (!path) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
SUDSAVerifier *verifier = [(SUDSAVerifier *)[self alloc] initWithPublicKeyData:[pkeyString dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
|
||||
if (!verifier) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
return [verifier verifyFileAtPath:path signatures:signatures];
|
||||
NSString *strippedSignature = [encodedSignature stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];
|
||||
NSData *signature = [[NSData alloc] initWithBase64Encoding:strippedSignature];
|
||||
return [verifier verifyFileAtPath:path signature:signature];
|
||||
}
|
||||
|
||||
- (instancetype)initWithPublicKeys:(SUPublicKeys *)pubkeys
|
||||
- (instancetype)initWithPublicKeyData:(NSData *)data
|
||||
{
|
||||
self = [super init];
|
||||
_pubKeys = pubkeys;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (SecKeyRef)dsaSecKeyRef {
|
||||
|
||||
NSData *data = [self.pubKeys.dsaPubKey dataUsingEncoding:NSASCIIStringEncoding];
|
||||
if (!self || !data.length) {
|
||||
SULog(SULogLevelError, @"Could not read public DSA key");
|
||||
return nil;
|
||||
@@ -70,84 +67,40 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
SecKeyRef dsaPubKeySecKey = nil;
|
||||
if (format == kSecFormatOpenSSL && itemType == kSecItemTypePublicKey && CFArrayGetCount(items) == 1) {
|
||||
// Seems silly, but we can't quiet the warning about dropping CFTypeRef's const qualifier through
|
||||
// any manner of casting I've tried, including interim explicit cast to void*. The -Wcast-qual
|
||||
// warning is on by default with -Weverything and apparently became more noisy as of Xcode 7.
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wcast-qual"
|
||||
dsaPubKeySecKey = (SecKeyRef)CFRetain(CFArrayGetValueAtIndex(items, 0));
|
||||
_secKey = (SecKeyRef)CFRetain(CFArrayGetValueAtIndex(items, 0));
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
CFRelease(items);
|
||||
return dsaPubKeySecKey;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signatures:(SUSignatures *)signatures
|
||||
- (void)dealloc
|
||||
{
|
||||
if (!path || !path.length) {
|
||||
return NO;
|
||||
if (_secKey) {
|
||||
CFRelease(_secKey);
|
||||
}
|
||||
|
||||
if (!signatures) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSData *dsaSignature = signatures.dsaSignature;
|
||||
NSString *dsaPubKey = self.pubKeys.dsaPubKey;
|
||||
|
||||
const unsigned char *edSignature = signatures.ed25519Signature;
|
||||
const unsigned char *edPubKey = self.pubKeys.ed25519PubKey;
|
||||
|
||||
if (edPubKey && !edSignature) {
|
||||
SULog(SULogLevelDefault, @"There is no ED25519 signature in the update, but the app is capable of verifying them");
|
||||
} if (!edPubKey && edSignature) {
|
||||
SULog(SULogLevelDefault, @"The update has an ED25519 signature, but it won't be used, because the old app doesn't have an ED25519 public key");
|
||||
} else if (edPubKey && edSignature) {
|
||||
NSError *error = nil;
|
||||
NSData *data = [NSData dataWithContentsOfFile:path options:NSDataReadingMappedAlways error:&error];
|
||||
if (!data || !data.length) {
|
||||
SULog(SULogLevelError, @"Failed to load file %@: %@", path, error);
|
||||
return NO;
|
||||
}
|
||||
if (ed25519_verify(edSignature, data.bytes, data.length, edPubKey)) {
|
||||
SULog(SULogLevelDefault, @"OK: ED25519 signature is correct");
|
||||
if (!dsaPubKey) {
|
||||
return YES;
|
||||
} else {
|
||||
SULog(SULogLevelDefault, @"This app has a DSA public key, so a DSA signature is required too");
|
||||
}
|
||||
} else {
|
||||
SULog(SULogLevelError, @"ED25519 signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set.");
|
||||
if (dsaSignature) {
|
||||
SULog(SULogLevelDefault, @"DSA signature won't be checked, because ED25519 verification has already failed");
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dsaSignature) {
|
||||
SULog(SULogLevelError, @"There is no DSA signature in the update");
|
||||
} else if (!dsaPubKey) {
|
||||
SULog(SULogLevelDefault, @"The update has a DSA signature, but it can't be used, because the old app doesn't have a DSA public key");
|
||||
} else {
|
||||
NSInputStream *dataInputStream = [NSInputStream inputStreamWithFileAtPath:path];
|
||||
return [self verifyDSASignatureOfStream:dataInputStream dsaSignature:dsaSignature];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)verifyDSASignatureOfStream:(NSInputStream *)stream dsaSignature:(NSData *)dsaSignature
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signature:(NSData *)signature
|
||||
{
|
||||
if (!stream || !dsaSignature) {
|
||||
SULog(SULogLevelError, @"Invalid arguments to verifyStream");
|
||||
if (!path.length) {
|
||||
return NO;
|
||||
}
|
||||
NSInputStream *dataInputStream = [NSInputStream inputStreamWithFileAtPath:path];
|
||||
return [self verifyStream:dataInputStream signature:signature];
|
||||
}
|
||||
|
||||
SecKeyRef dsaPubKeySecKey = [self dsaSecKeyRef];
|
||||
if (!dsaPubKeySecKey) {
|
||||
- (BOOL)verifyStream:(NSInputStream *)stream signature:(NSData *)signature
|
||||
{
|
||||
if (!stream || !signature) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -163,7 +116,6 @@
|
||||
if (dataDigestTransform) CFRelease(dataDigestTransform);
|
||||
if (dataVerifyTransform) CFRelease(dataVerifyTransform);
|
||||
if (error) CFRelease(error);
|
||||
if (dsaPubKeySecKey) CFRelease(dsaPubKeySecKey);
|
||||
return NO;
|
||||
};
|
||||
|
||||
@@ -180,10 +132,10 @@
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
dataVerifyTransform = SecVerifyTransformCreate(dsaPubKeySecKey, (__bridge CFDataRef)dsaSignature, &error);
|
||||
dataVerifyTransform = SecVerifyTransformCreate(_secKey, (__bridge CFDataRef)signature, &error);
|
||||
#pragma clang diagnostic pop
|
||||
if (!dataVerifyTransform || error) {
|
||||
SULog(SULogLevelError, @"Could not understand format of the signature: %@; Signature data: %@", error, dsaSignature);
|
||||
SULog(SULogLevelError, @"Could not understand format of the signature: %@; Signature data: %@", error, signature);
|
||||
return cleanup();
|
||||
}
|
||||
|
||||
Vendored
+14
-14
@@ -30,7 +30,7 @@
|
||||
return [[path pathExtension] isEqualToString:@"dmg"];
|
||||
}
|
||||
|
||||
+ (BOOL)mustValidateBeforeExtraction
|
||||
+ (BOOL)unsafeIfArchiveIsNotValidated
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
@@ -58,7 +58,7 @@
|
||||
{
|
||||
@autoreleasepool {
|
||||
BOOL mountedSuccessfully = NO;
|
||||
|
||||
|
||||
// get a unique mount point path
|
||||
NSString *mountPoint = nil;
|
||||
NSFileManager *manager;
|
||||
@@ -81,12 +81,12 @@
|
||||
}
|
||||
// Note: this check does not follow symbolic links, which is what we want
|
||||
while ([[NSURL fileURLWithPath:mountPoint] checkResourceIsReachableAndReturnError:NULL]);
|
||||
|
||||
|
||||
NSData *promptData = nil;
|
||||
promptData = [NSData dataWithBytes:"yes\n" length:4];
|
||||
|
||||
|
||||
NSMutableArray *arguments = [@[@"attach", self.archivePath, @"-mountpoint", mountPoint, /*@"-noverify",*/ @"-nobrowse", @"-noautoopen"] mutableCopy];
|
||||
|
||||
|
||||
if (self.decryptionPassword) {
|
||||
NSMutableData *passwordData = [[self.decryptionPassword dataUsingEncoding:NSUTF8StringEncoding] mutableCopy];
|
||||
// From the hdiutil docs:
|
||||
@@ -96,10 +96,10 @@
|
||||
[passwordData appendData:[NSData dataWithBytes:"\0" length:1]];
|
||||
[passwordData appendData:promptData];
|
||||
promptData = passwordData;
|
||||
|
||||
|
||||
[arguments addObject:@"-stdinpass"];
|
||||
}
|
||||
|
||||
|
||||
NSData *output = nil;
|
||||
NSInteger taskResult = -1;
|
||||
@try
|
||||
@@ -132,7 +132,7 @@
|
||||
{
|
||||
goto reportError;
|
||||
}
|
||||
|
||||
|
||||
[notifier notifyProgress:0.5];
|
||||
|
||||
if (taskResult != 0)
|
||||
@@ -142,7 +142,7 @@
|
||||
goto reportError;
|
||||
}
|
||||
mountedSuccessfully = YES;
|
||||
|
||||
|
||||
// Now that we've mounted it, we need to copy out its contents.
|
||||
manager = [[NSFileManager alloc] init];
|
||||
contents = [manager contentsOfDirectoryAtPath:mountPoint error:&error];
|
||||
@@ -159,12 +159,12 @@
|
||||
{
|
||||
NSString *fromPath = [mountPoint stringByAppendingPathComponent:item];
|
||||
NSString *toPath = [[self.archivePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:item];
|
||||
|
||||
|
||||
// We skip any files in the DMG which are not readable.
|
||||
if (![manager isReadableFileAtPath:fromPath]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
itemsCopied += 1.0;
|
||||
[notifier notifyProgress:0.5 + itemsCopied/(totalItems*2.0)];
|
||||
SULog(SULogLevelDefault, @"copyItemAtPath:%@ toPath:%@", fromPath, toPath);
|
||||
@@ -174,10 +174,10 @@
|
||||
goto reportError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[notifier notifySuccess];
|
||||
goto finally;
|
||||
|
||||
|
||||
reportError:
|
||||
[notifier notifyFailureWithError:error];
|
||||
|
||||
@@ -188,7 +188,7 @@
|
||||
task.arguments = @[@"detach", mountPoint, @"-force"];
|
||||
task.standardOutput = [NSPipe pipe];
|
||||
task.standardError = [NSPipe pipe];
|
||||
|
||||
|
||||
@try {
|
||||
[task launch];
|
||||
} @catch (NSException *exception) {
|
||||
|
||||
Vendored
+1
-1
@@ -176,7 +176,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
||||
if (error != NULL) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wcstring-format-directive"
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Failed to run authorization tool %s (error code %d).", toolPath, (int)runStatus] }];
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Failed to run authorization tool %@ (error code %d).", [NSString stringWithCString:toolPath encoding:NSUTF8StringEncoding], (int)runStatus] }];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
return NO;
|
||||
|
||||
Vendored
+1
-4
@@ -7,8 +7,6 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class SUPublicKeys;
|
||||
|
||||
@interface SUHost : NSObject
|
||||
|
||||
@property (strong, readonly) NSBundle *bundle;
|
||||
@@ -18,9 +16,8 @@
|
||||
@property (readonly, copy) NSString *name;
|
||||
@property (readonly, copy) NSString *version;
|
||||
@property (readonly, copy) NSString *displayVersion;
|
||||
@property (readonly) SUPublicKeys *publicKeys;
|
||||
|
||||
@property (getter=isRunningOnReadOnlyVolume, readonly) BOOL runningOnReadOnlyVolume;
|
||||
@property (readonly, copy) NSString *publicDSAKey;
|
||||
@property (readonly, nonatomic, copy) NSString *publicDSAKeyFileKey;
|
||||
|
||||
- (id)objectForInfoDictionaryKey:(NSString *)key;
|
||||
|
||||
Vendored
+1
-12
@@ -10,7 +10,7 @@
|
||||
#import "SUConstants.h"
|
||||
#include <sys/mount.h> // For statfs for isRunningOnReadOnlyVolume
|
||||
#import "SULog.h"
|
||||
#import "SUSignatures.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
@property (nonatomic, readonly) BOOL isMainBundle;
|
||||
@property (copy) NSString *defaultsDomain;
|
||||
@property (assign) BOOL usesStandardUserDefaults;
|
||||
@property (readonly, copy) NSString *publicDSAKey;
|
||||
|
||||
@end
|
||||
|
||||
@@ -110,11 +109,6 @@
|
||||
return (statfs_info.f_flags & MNT_RDONLY) != 0;
|
||||
}
|
||||
|
||||
- (NSString *__nullable)publicEDKey
|
||||
{
|
||||
return [self objectForInfoDictionaryKey:SUPublicEDKeyKey];
|
||||
}
|
||||
|
||||
- (NSString *__nullable)publicDSAKey
|
||||
{
|
||||
// Maybe the key is just a string in the Info.plist.
|
||||
@@ -141,11 +135,6 @@
|
||||
return key;
|
||||
}
|
||||
|
||||
- (SUPublicKeys *)publicKeys
|
||||
{
|
||||
return [[SUPublicKeys alloc] initWithDsa:[self publicDSAKey] ed:[self publicEDKey]];
|
||||
}
|
||||
|
||||
- (NSString * __nullable)publicDSAKeyFileKey
|
||||
{
|
||||
return [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
|
||||
|
||||
Vendored
+1
-1
@@ -39,7 +39,7 @@
|
||||
return version;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpartial-availability"
|
||||
return [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
|
||||
Vendored
+1
-1
@@ -58,7 +58,7 @@
|
||||
return ([self commandAndArgumentsConformingToTypeOfPath:path] != nil);
|
||||
}
|
||||
|
||||
+ (BOOL)mustValidateBeforeExtraction
|
||||
+ (BOOL)unsafeIfArchiveIsNotValidated
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
Vendored
-32
@@ -1,32 +0,0 @@
|
||||
//
|
||||
// SUDSAVerifier.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Andy Matuschak on 3/16/06.
|
||||
// Copyright 2006 Andy Matuschak. All rights reserved.
|
||||
//
|
||||
// Includes code by Zach Waldowski on 10/18/13.
|
||||
// Copyright 2014 Big Nerd Ranch. Licensed under MIT.
|
||||
//
|
||||
// Includes code from Plop by Mark Hamlin.
|
||||
// Copyright 2011 Mark Hamlin. Licensed under BSD.
|
||||
//
|
||||
|
||||
#ifndef SUDSAVERIFIER_H
|
||||
#define SUDSAVERIFIER_H
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@class SUSignatures;
|
||||
@class SUPublicKeys;
|
||||
|
||||
@interface SUSignatureVerifier : NSObject
|
||||
|
||||
+ (BOOL)validatePath:(NSString *)path withSignatures:(SUSignatures *)signatures withPublicKeys:(SUPublicKeys *)pkeys;
|
||||
|
||||
- (instancetype)initWithPublicKeys:(SUPublicKeys *)pkeys;
|
||||
|
||||
- (BOOL)verifyFileAtPath:(NSString *)path signatures:(SUSignatures *)signatures;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
Vendored
-40
@@ -1,40 +0,0 @@
|
||||
//
|
||||
// SUSignatures.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Kornel on 15/09/2018.
|
||||
// Copyright © 2018 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1090
|
||||
@interface NSData (SUDSAVerifier)
|
||||
- (id)initWithBase64Encoding:(NSString *)base64String;
|
||||
@end
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUSignatures : NSObject {
|
||||
unsigned char ed25519_signature[64];
|
||||
}
|
||||
@property (strong, readonly, nullable) NSData *dsaSignature;
|
||||
@property (readonly, nullable, nonatomic) const unsigned char *ed25519Signature;
|
||||
|
||||
- (instancetype)initWithDsa:(NSString * _Nullable)dsa ed:(NSString * _Nullable)ed;
|
||||
@end
|
||||
|
||||
|
||||
@interface SUPublicKeys : NSObject {
|
||||
unsigned char ed25519_public_key[32];
|
||||
}
|
||||
@property (strong, readonly, nullable) NSString *dsaPubKey;
|
||||
@property (readonly, nullable, nonatomic) const unsigned char *ed25519PubKey;
|
||||
|
||||
- (instancetype)initWithDsa:(NSString * _Nullable)dsa ed:(NSString * _Nullable)ed;
|
||||
- (BOOL) isEqualToKey:(SUPublicKeys *)key;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Vendored
-88
@@ -1,88 +0,0 @@
|
||||
//
|
||||
// SUSignatures.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Kornel on 15/09/2018.
|
||||
// Copyright © 2018 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUSignatures.h"
|
||||
#import <assert.h>
|
||||
#import "SULog.h"
|
||||
|
||||
@implementation SUSignatures
|
||||
@synthesize dsaSignature = _dsaSignature;
|
||||
|
||||
static NSData *decode(NSString *str) {
|
||||
if (str == nil) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString *stripped = [str stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];
|
||||
return [[NSData alloc] initWithBase64Encoding:stripped];
|
||||
}
|
||||
|
||||
- (instancetype)initWithDsa:(NSString * _Nullable)maybeDsa ed:(NSString * _Nullable)maybeEd25519
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
if (maybeDsa != nil) {
|
||||
_dsaSignature = decode(maybeDsa);
|
||||
}
|
||||
if (maybeEd25519 != nil) {
|
||||
NSData *data = decode(maybeEd25519);
|
||||
assert(64 == sizeof(self->ed25519_signature));
|
||||
[data getBytes:self->ed25519_signature length:sizeof(self->ed25519_signature)];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (const unsigned char *)ed25519Signature {
|
||||
for(size_t i=0; i < sizeof(self->ed25519_signature); i++) {
|
||||
if (self->ed25519_signature[i] != 0) {
|
||||
return self->ed25519_signature;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUPublicKeys
|
||||
@synthesize dsaPubKey = _dsaPubKey;
|
||||
|
||||
- (instancetype)initWithDsa:(NSString * _Nullable)maybeDsa ed:(NSString * _Nullable)maybeEd25519
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_dsaPubKey = maybeDsa;
|
||||
if (maybeEd25519 != nil) {
|
||||
NSData *ed = decode(maybeEd25519);
|
||||
assert(32 == sizeof(self->ed25519_public_key));
|
||||
[ed getBytes:self->ed25519_public_key length:sizeof(self->ed25519_public_key)];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) isEqualToKey:(SUPublicKeys *)key {
|
||||
NSString *thisKey = self.dsaPubKey;
|
||||
NSString *thatKey = key.dsaPubKey;
|
||||
if (thisKey == nil || thatKey == nil) {
|
||||
return NO;
|
||||
}
|
||||
return [thisKey isEqualToString:thatKey];
|
||||
}
|
||||
|
||||
|
||||
- (const unsigned char *)ed25519PubKey {
|
||||
for(size_t i=0; i < sizeof(self->ed25519_public_key); i++) {
|
||||
if (self->ed25519_public_key[i] != 0) {
|
||||
return self->ed25519_public_key;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+1
-1
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path;
|
||||
|
||||
+ (BOOL)mustValidateBeforeExtraction;
|
||||
+ (BOOL)unsafeIfArchiveIsNotValidated;
|
||||
|
||||
- (void)unarchiveWithCompletionBlock:(void (^)(NSError * _Nullable))completionBlock progressBlock:(void (^ _Nullable)(double))progressBlock;
|
||||
|
||||
|
||||
Vendored
+5
-4
@@ -9,15 +9,16 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class SUHost;
|
||||
@class SUSignatures;
|
||||
|
||||
@interface SUUpdateValidator : NSObject
|
||||
|
||||
- (instancetype)initWithDownloadPath:(NSString *)downloadPath signatures:(SUSignatures *)signatures host:(SUHost *)host;
|
||||
// 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;
|
||||
|
||||
// This is "pre" validation, before the archive has been extracted
|
||||
- (BOOL)validateDownloadPath;
|
||||
// Indicates whether we can perform (post) validation later
|
||||
@property (nonatomic, readonly) BOOL canValidate;
|
||||
|
||||
// precondition: validation must be possible (see -canValidate)
|
||||
// This is "post" validation, after an archive has been extracted
|
||||
- (BOOL)validateWithUpdateDirectory:(NSString *)updateDirectory;
|
||||
|
||||
|
||||
Vendored
+51
-45
@@ -7,21 +7,20 @@
|
||||
//
|
||||
|
||||
#import "SUUpdateValidator.h"
|
||||
#import "SUSignatureVerifier.h"
|
||||
#import "SUDSAVerifier.h"
|
||||
#import "SUCodeSigningVerifier.h"
|
||||
#import "SUInstaller.h"
|
||||
#import "SUHost.h"
|
||||
#import "SULog.h"
|
||||
#import "SUSignatures.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUUpdateValidator ()
|
||||
|
||||
@property (nonatomic, readonly) SUHost *host;
|
||||
@property (nonatomic) BOOL prevalidatedSignature;
|
||||
@property (nonatomic) BOOL downloadPrevalidationFailed;
|
||||
@property (strong, nonatomic, readonly) SUSignatures *signatures;
|
||||
@property (nonatomic, readonly) BOOL prevalidatedDsaSignature;
|
||||
@property (nonatomic, readonly) NSString *dsaSignature;
|
||||
@property (nonatomic, readonly) NSString *downloadPath;
|
||||
|
||||
@end
|
||||
@@ -29,52 +28,59 @@
|
||||
@implementation SUUpdateValidator
|
||||
|
||||
@synthesize host = _host;
|
||||
@synthesize prevalidatedSignature = _prevalidatedSignature;
|
||||
@synthesize signatures = _signatures;
|
||||
@synthesize downloadPrevalidationFailed = _downloadPrevalidationFailed;
|
||||
@synthesize canValidate = _canValidate;
|
||||
@synthesize prevalidatedDsaSignature = _prevalidatedDsaSignature;
|
||||
@synthesize dsaSignature = _dsaSignature;
|
||||
@synthesize downloadPath = _downloadPath;
|
||||
|
||||
- (instancetype)initWithDownloadPath:(NSString *)downloadPath signatures:(SUSignatures *)signatures host:(SUHost *)host
|
||||
- (instancetype)initWithDownloadPath:(NSString *)downloadPath dsaSignature:(NSString *)dsaSignature host:(SUHost *)host performingPrevalidation:(BOOL)performingPrevalidation
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
BOOL canValidate;
|
||||
BOOL prevalidatedDsaSignature;
|
||||
if (performingPrevalidation) {
|
||||
NSString *publicDSAKey = host.publicDSAKey;
|
||||
|
||||
if (publicDSAKey == nil) {
|
||||
prevalidatedDsaSignature = NO;
|
||||
SULog(SULogLevelError, @"Failed to validate update before unarchiving because no DSA key was found");
|
||||
} else if (dsaSignature == nil) {
|
||||
prevalidatedDsaSignature = NO;
|
||||
SULog(SULogLevelError, @"Failed to validate update before unarchiving because no DSA signature was found");
|
||||
} else {
|
||||
prevalidatedDsaSignature = [SUDSAVerifier validatePath:downloadPath withEncodedDSASignature:dsaSignature withPublicDSAKey:publicDSAKey];
|
||||
if (!prevalidatedDsaSignature) {
|
||||
SULog(SULogLevelError, @"DSA signature validation before unarchiving failed for update %@", downloadPath);
|
||||
}
|
||||
}
|
||||
|
||||
canValidate = prevalidatedDsaSignature;
|
||||
} else {
|
||||
prevalidatedDsaSignature = NO;
|
||||
canValidate = YES;
|
||||
}
|
||||
|
||||
_canValidate = canValidate;
|
||||
_prevalidatedDsaSignature = prevalidatedDsaSignature;
|
||||
_downloadPath = [downloadPath copy];
|
||||
_signatures = signatures;
|
||||
_dsaSignature = [dsaSignature copy];
|
||||
_host = host;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)validateDownloadPath {
|
||||
SUPublicKeys *publicKeys = self.host.publicKeys;
|
||||
SUSignatures *signatures = self.signatures;
|
||||
|
||||
if (publicKeys.dsaPubKey == nil) {
|
||||
SULog(SULogLevelError, @"Failed to validate update before unarchiving because no DSA public key was found in the old app");
|
||||
} else if (signatures == nil || signatures.dsaSignature == nil) {
|
||||
SULog(SULogLevelError, @"Failed to validate update before unarchiving because no DSA signature was found");
|
||||
} else {
|
||||
if ([SUSignatureVerifier validatePath:self.downloadPath withSignatures:signatures withPublicKeys:publicKeys]) {
|
||||
self.prevalidatedSignature = YES;
|
||||
return YES;
|
||||
}
|
||||
SULog(SULogLevelError, @"DSA signature validation before unarchiving failed for update %@", self.downloadPath);
|
||||
}
|
||||
self.downloadPrevalidationFailed = YES;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)validateWithUpdateDirectory:(NSString *)updateDirectory
|
||||
{
|
||||
if (self.downloadPrevalidationFailed) {
|
||||
return NO;
|
||||
}
|
||||
assert(self.canValidate);
|
||||
|
||||
SUSignatures *signatures = self.signatures;
|
||||
SUPublicKeys *publicKeys = self.host.publicKeys;
|
||||
NSString *DSASignature = self.dsaSignature;
|
||||
NSString *publicDSAKey = self.host.publicDSAKey;
|
||||
NSString *downloadPath = self.downloadPath;
|
||||
SUHost *host = self.host;
|
||||
|
||||
BOOL prevalidatedDsaSignature = self.prevalidatedDsaSignature;
|
||||
|
||||
BOOL isPackage = NO;
|
||||
|
||||
// install source could point to a new bundle or a package
|
||||
@@ -86,18 +92,18 @@
|
||||
|
||||
NSURL *installSourceURL = [NSURL fileURLWithPath:installSource];
|
||||
|
||||
if (!self.prevalidatedSignature) {
|
||||
if (!prevalidatedDsaSignature) {
|
||||
// Check to see if we have a package or bundle to validate
|
||||
if (isPackage) {
|
||||
// For package type updates, all we do is check if the DSA signature is valid
|
||||
BOOL validationCheckSuccess = [SUSignatureVerifier validatePath:downloadPath withSignatures:signatures withPublicKeys:publicKeys];
|
||||
BOOL validationCheckSuccess = [SUDSAVerifier validatePath:downloadPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
|
||||
if (!validationCheckSuccess) {
|
||||
SULog(SULogLevelError, @"DSA signature validation of the package failed. The update contains an installer package, and valid DSA signatures are mandatory for all installer packages. The update will be rejected. Sign the installer with a valid DSA key or use an .app bundle update instead.");
|
||||
}
|
||||
return validationCheckSuccess;
|
||||
} else {
|
||||
// For application bundle updates, we check both the DSA and Apple code signing signatures
|
||||
return [self validateUpdateForHost:host downloadedToPath:downloadPath newBundleURL:installSourceURL signatures:signatures];
|
||||
return [self validateUpdateForHost:host downloadedToPath:downloadPath newBundleURL:installSourceURL DSASignature:DSASignature];
|
||||
}
|
||||
} else if (isPackage) {
|
||||
// We shouldn't get here because we don't validate packages before extracting them currently
|
||||
@@ -125,7 +131,7 @@
|
||||
* * old and new Code Signing identity are the same and valid
|
||||
*
|
||||
*/
|
||||
- (BOOL)validateUpdateForHost:(SUHost *)host downloadedToPath:(NSString *)downloadedPath newBundleURL:(NSURL *)newBundleURL signatures:(SUSignatures *)signatures
|
||||
- (BOOL)validateUpdateForHost:(SUHost *)host downloadedToPath:(NSString *)downloadedPath newBundleURL:(NSURL *)newBundleURL DSASignature:(NSString *)DSASignature
|
||||
{
|
||||
NSBundle *newBundle = [NSBundle bundleWithURL:newBundleURL];
|
||||
if (newBundle == nil) {
|
||||
@@ -133,24 +139,24 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
SUPublicKeys *publicKeys = host.publicKeys;
|
||||
NSString *publicDSAKey = host.publicDSAKey;
|
||||
|
||||
SUHost *newHost = [[SUHost alloc] initWithBundle:newBundle];
|
||||
SUPublicKeys *newPublicKeys = newHost.publicKeys;
|
||||
NSString *newPublicDSAKey = newHost.publicDSAKey;
|
||||
|
||||
// Downgrade in DSA security should not be possible
|
||||
if (publicKeys.dsaPubKey != nil && newPublicKeys.dsaPubKey == nil) {
|
||||
if (publicDSAKey != nil && newPublicDSAKey == nil) {
|
||||
SULog(SULogLevelError, @"A public DSA key is found in the old bundle but no public DSA key is found in the new update. For security reasons, the update will be rejected.");
|
||||
return NO;
|
||||
}
|
||||
|
||||
BOOL dsaKeysMatch = [publicKeys isEqualToKey:newPublicKeys];
|
||||
BOOL dsaKeysMatch = (publicDSAKey == nil || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey];
|
||||
|
||||
// If the new DSA key differs from the old, then this check is not a security measure, because the new key is not trusted.
|
||||
// In that case, the check ensures that the app author has correctly used DSA keys, so that the app will be updateable in the next version.
|
||||
// However if the new and old DSA keys are the same, then this is a security measure.
|
||||
if (newPublicKeys.dsaPubKey != nil) {
|
||||
if (![SUSignatureVerifier validatePath:downloadedPath withSignatures:signatures withPublicKeys:newPublicKeys]) {
|
||||
if (newPublicDSAKey != nil) {
|
||||
if (![SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:newPublicDSAKey]) {
|
||||
SULog(SULogLevelError, @"DSA signature validation failed. The update has a public DSA key and is signed with a DSA key, but the %@ doesn't match the signature. The update will be rejected.",
|
||||
dsaKeysMatch ? @"public key" : @"new public key shipped with the update");
|
||||
return NO;
|
||||
@@ -167,7 +173,7 @@
|
||||
} else {
|
||||
BOOL hostIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:host.bundle.bundleURL];
|
||||
|
||||
NSString *dsaStatus = newPublicKeys.dsaPubKey ? @"has a new DSA key that doesn't match the previous one" : (publicKeys.dsaPubKey ? @"removes the DSA key" : @"isn't signed with a DSA key");
|
||||
NSString *dsaStatus = newPublicDSAKey ? @"has a new DSA key that doesn't match the previous one" : (publicDSAKey ? @"removes the DSA key" : @"isn't signed with a DSA key");
|
||||
if (!hostIsCodeSigned || !updateIsCodeSigned) {
|
||||
NSString *acsStatus = !hostIsCodeSigned ? @"old app hasn't been signed with app Code Signing" : @"new app isn't signed with app Code Signing";
|
||||
SULog(SULogLevelError, @"The update archive %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus);
|
||||
|
||||
Vendored
+3
-4
@@ -25,7 +25,6 @@
|
||||
#include <SystemConfiguration/SystemConfiguration.h>
|
||||
#import "SUSystemProfiler.h"
|
||||
#import "SUSystemUpdateInfo.h"
|
||||
#import "SUSignatures.h"
|
||||
|
||||
NSString *const SUUpdaterDidFinishLoadingAppCastNotification = @"SUUpdaterDidFinishLoadingAppCastNotification";
|
||||
NSString *const SUUpdaterDidFindValidUpdateNotification = @"SUUpdaterDidFindValidUpdateNotification";
|
||||
@@ -139,7 +138,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
}
|
||||
|
||||
-(void)checkIfConfiguredProperly {
|
||||
BOOL hasPublicDSAKey = self.host.publicKeys.dsaPubKey != nil;
|
||||
BOOL hasPublicDSAKey = [self.host publicDSAKey] != nil;
|
||||
BOOL isMainBundle = [self.host.bundle isEqualTo:[NSBundle mainBundle]];
|
||||
BOOL hostIsCodeSigned = [SUCodeSigningVerifier bundleAtURLIsCodeSigned:self.host.bundle.bundleURL];
|
||||
NSURL *feedURL = [self feedURL];
|
||||
@@ -174,7 +173,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
[self showAlertText:SULocalizedString(@"Insecure feed URL is blocked in macOS 10.11", nil)
|
||||
informativeText:[NSString stringWithFormat:SULocalizedString(@"You must change the feed URL (%@) to use HTTPS or disable App Transport Security.\n\nFor more information:\nhttps://sparkle-project.org/documentation/app-transport-security/", nil), [feedURL absoluteString]]];
|
||||
} else if (!isMainBundle) {
|
||||
SULog(SULogLevelDefault, @"WARNING: Serving updates over HTTP may be blocked in macOS 10.11. Please change the feed URL (%@) to use HTTPS. For more information:\nhttps://sparkle-project.org/documentation/app-transport-security/", feedURL);
|
||||
// SULog(SULogLevelDefault, @"WARNING: Serving updates over HTTP may be blocked in macOS 10.11. Please change the feed URL (%@) to use HTTPS. For more information:\nhttps://sparkle-project.org/documentation/app-transport-security/", feedURL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -261,7 +260,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
{
|
||||
[self setUpdateLastCheckedDate:[self.host objectForUserDefaultsKey:SULastCheckTimeKey]];
|
||||
}
|
||||
|
||||
|
||||
return [self updateLastCheckedDate];
|
||||
}
|
||||
|
||||
|
||||
Vendored
+3
-5
@@ -16,13 +16,11 @@
|
||||
|
||||
"A new version of %@ is available!" = "גרסה חדשה של %@ זמינה!";
|
||||
|
||||
"Cancel Update" = "בטל עדכון";
|
||||
"An error occurred during installation. Please try again later." = "שגיאה בהתקנה. אנא נסה שנית במועד מרוחר יותר.";
|
||||
|
||||
"An error occurred during installation. Please try again later." = "שגיאה בהתקנה. אנא נסה שנית במועד מאוחר יותר.";
|
||||
"An error occurred in retrieving update information. Please try again later." = "שגיאה בקבלת מידע על עדכונים. אנא נסה שנית במועד מרוחר יותר.";
|
||||
|
||||
"An error occurred in retrieving update information. Please try again later." = "שגיאה בקבלת מידע על עדכונים. אנא נסה שנית במועד מאוחר יותר.";
|
||||
|
||||
"An error occurred while extracting the archive. Please try again later." = "שגיאה בפתיחת הקובת המקווץ. אנא נסה שנית במועד מאוחר יותר.";
|
||||
"An error occurred while extracting the archive. Please try again later." = "שגיאה בפתיחת הקובת המקווץ. אנא נסה שנית במועד מרוחר יותר.";
|
||||
|
||||
"An error occurred while trying to download the file. Please try again later." = "שגיאה בהורדת הקובץ. אנא נסה שנית במועד מאוחר יותר.";
|
||||
|
||||
|
||||
+12
-19
@@ -8,8 +8,7 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
#import "SUSignatureVerifier.h"
|
||||
#import "SUSignatures.h"
|
||||
#import "SUDSAVerifier.h"
|
||||
|
||||
@interface SUDSAVerifierTest : XCTestCase
|
||||
@property NSString *testFile, *pubKeyFile;
|
||||
@@ -28,7 +27,7 @@
|
||||
|
||||
- (void)testVerifyFileAtPath
|
||||
{
|
||||
NSString *pubKey = [NSString stringWithContentsOfFile:self.pubKeyFile encoding:NSASCIIStringEncoding error:nil];
|
||||
NSData *pubKey = [NSData dataWithContentsOfFile:self.pubKeyFile];
|
||||
XCTAssertNotNil(pubKey, @"Public key must be readable");
|
||||
|
||||
NSString *validSig = @"MCwCFCIHCIYYkfZavNzTitTW5tlRp/k5AhQ40poFytqcVhIYdCxQznaXeJPJDQ==";
|
||||
@@ -39,7 +38,7 @@
|
||||
@"Expected valid signature");
|
||||
|
||||
XCTAssertFalse([self checkFile:self.testFile
|
||||
withPubKey:@"lol"
|
||||
withPubKey:[NSData dataWithBytes:"lol" length:3]
|
||||
signature:validSig],
|
||||
@"Invalid pubkey");
|
||||
|
||||
@@ -64,29 +63,23 @@
|
||||
@"Expected invalid signature");
|
||||
}
|
||||
|
||||
- (BOOL)checkFile:(NSString *)aFile withPubKey:(NSString *)pubKey signature:(NSString *)sigString
|
||||
- (BOOL)checkFile:(NSString *)aFile withPubKey:(NSData *)pubKey signature:(NSString *)sigString
|
||||
{
|
||||
SUPublicKeys *pubKeys = [[SUPublicKeys alloc] initWithDsa:pubKey ed:nil];
|
||||
SUSignatureVerifier *v = [[SUSignatureVerifier alloc] initWithPublicKeys:pubKeys];
|
||||
SUDSAVerifier *v = [[SUDSAVerifier alloc] initWithPublicKeyData:pubKey];
|
||||
|
||||
SUSignatures *sig = [[SUSignatures alloc] initWithDsa:sigString ed:nil];
|
||||
NSData *sig = [[NSData alloc] initWithBase64EncodedString:sigString options:(NSDataBase64DecodingOptions)0];
|
||||
|
||||
return [v verifyFileAtPath:aFile signatures:sig];
|
||||
return [v verifyFileAtPath:aFile signature:sig];
|
||||
}
|
||||
|
||||
- (void)testValidatePath
|
||||
{
|
||||
NSString *dsaStr = [NSString stringWithContentsOfFile:self.pubKeyFile encoding:NSASCIIStringEncoding error:nil];
|
||||
XCTAssertNotNil(dsaStr);
|
||||
SUPublicKeys *pubkeys = [[SUPublicKeys alloc] initWithDsa:dsaStr ed:nil];
|
||||
XCTAssertNotNil(pubkeys);
|
||||
XCTAssertNotNil(pubkeys.dsaPubKey);
|
||||
NSString *pubkey = [NSString stringWithContentsOfFile:self.pubKeyFile encoding:NSASCIIStringEncoding error:nil];
|
||||
|
||||
SUSignatures *sig = [[SUSignatures alloc] initWithDsa:@"MC0CFFMF3ha5kjvrJ9JTpTR8BenPN9QUAhUAzY06JRdtP17MJewxhK0twhvbKIE=" ed:nil];
|
||||
XCTAssertNotNil(sig);
|
||||
XCTAssertNotNil(sig.dsaSignature);
|
||||
|
||||
XCTAssertTrue([SUSignatureVerifier validatePath:self.testFile withSignatures:sig withPublicKeys:pubkeys], @"Expected valid signature");
|
||||
XCTAssertTrue([SUDSAVerifier validatePath:self.testFile
|
||||
withEncodedDSASignature:@"MC0CFFMF3ha5kjvrJ9JTpTR8BenPN9QUAhUAzY06JRdtP17MJewxhK0twhvbKIE="
|
||||
withPublicDSAKey:pubkey],
|
||||
@"Expected valid signature");
|
||||
}
|
||||
|
||||
@end
|
||||
File renamed without changes.
@@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -o pipefail
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 update_archive_file dsa_priv.pem"
|
||||
echo "This is an old DSA signing script for deprecated DSA keys."
|
||||
echo "Do not use this for new applications."
|
||||
exit 1
|
||||
fi
|
||||
openssl=/usr/bin/openssl
|
||||
version=`$openssl version`
|
||||
if [[ $version =~ "OpenSSL 0.9" ]]; then
|
||||
# pre-10.13 system: Fall back to OpenSSL DSS1 digest because it does not like the -sha1 option
|
||||
$openssl dgst -sha1 -binary < "$1" | $openssl dgst -dss1 -sign "$2" | $openssl enc -base64
|
||||
else
|
||||
# 10.13 and later: Use LibreSSL SHA1 digest
|
||||
$openssl dgst -sha1 -binary < "$1" | $openssl dgst -sha1 -sign "$2" | $openssl enc -base64
|
||||
fi
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -o pipefail
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 update_archive private_key"
|
||||
exit 1
|
||||
fi
|
||||
openssl=/usr/bin/openssl
|
||||
$openssl dgst -sha1 -binary < "$1" | $openssl dgst -sha1 -sign "$2" | $openssl enc -base64
|
||||
-1
Submodule ed25519 deleted from 7fa6712ef5.
@@ -6,5 +6,3 @@
|
||||
#import "SUUnarchiver.h"
|
||||
#import "SUBinaryDeltaUnarchiver.h"
|
||||
#import "SUBinaryDeltaCreate.h"
|
||||
#import "SUSignatures.h"
|
||||
#import "../ed25519/src/ed25519.h" // run `git submodule update --init` if you get an erorr here
|
||||
@@ -14,11 +14,10 @@ func makeError(code: SUError, _ description: String) -> NSError {
|
||||
]);
|
||||
}
|
||||
|
||||
func makeAppcast(archivesSourceDir: URL, keys: PrivateKeys, verbose: Bool) throws -> [String:[ArchiveItem]] {
|
||||
let cacheDir = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)[0].appendingPathComponent("Sparkle_generate_appcast");
|
||||
func makeAppcast(archivesSourceDir: URL, privateKey: SecKey, verbose: Bool) throws -> [String:[ArchiveItem]] {
|
||||
let comparator = SUStandardVersionComparator();
|
||||
|
||||
let allUpdates = (try unarchiveUpdates(archivesSourceDir: archivesSourceDir, archivesDestDir: cacheDir, verbose:verbose))
|
||||
let allUpdates = (try unarchiveUpdates(archivesSourceDir: archivesSourceDir, verbose:verbose))
|
||||
.sorted(by: {
|
||||
.orderedDescending == comparator.compareVersion($0.version, toVersion:$1.version)
|
||||
})
|
||||
@@ -34,27 +33,11 @@ func makeAppcast(archivesSourceDir: URL, keys: PrivateKeys, verbose: Bool) throw
|
||||
for update in allUpdates {
|
||||
group.enter();
|
||||
DispatchQueue.global().async {
|
||||
if let privateDSAKey = keys.privateDSAKey {
|
||||
do {
|
||||
update.dsaSignature = try dsaSignature(path: update.archivePath, privateDSAKey: privateDSAKey);
|
||||
} catch {
|
||||
print(update, error);
|
||||
}
|
||||
} else if update.supportsDSA {
|
||||
print("Note: did not sign with legacy DSA \(update.archivePath.path) because private DSA key file was not specified");
|
||||
do {
|
||||
update.dsaSignature = try dsaSignature(path: update.archivePath, privateKey: privateKey);
|
||||
} catch {
|
||||
print(update, error);
|
||||
}
|
||||
if let publicEdKey = update.publicEdKey {
|
||||
if let privateEdKey = keys.privateEdKey {
|
||||
do {
|
||||
update.edSignature = try edSignature(path: update.archivePath, publicEdKey: publicEdKey, privateEdKey: privateEdKey);
|
||||
} catch {
|
||||
print(update, error);
|
||||
}
|
||||
} else {
|
||||
print("Warning: could not sign \(update.archivePath.path) due to lack of private ed25519 key");
|
||||
}
|
||||
}
|
||||
|
||||
group.leave();
|
||||
}
|
||||
|
||||
@@ -80,29 +63,16 @@ func makeAppcast(archivesSourceDir: URL, keys: PrivateKeys, verbose: Bool) throw
|
||||
var numDeltas = 0;
|
||||
let appBaseName = latestItem.appPath.deletingPathExtension().lastPathComponent;
|
||||
for item in updates {
|
||||
if numDeltas > maxDeltas {
|
||||
break;
|
||||
}
|
||||
|
||||
// No downgrades
|
||||
if .orderedAscending != comparator.compareVersion(item.version, toVersion: latestItem.version) {
|
||||
continue;
|
||||
}
|
||||
// Old version will not be able to verify the new version
|
||||
if !item.supportsDSA && item.publicEdKey == nil {
|
||||
continue;
|
||||
}
|
||||
|
||||
let deltaBaseName = appBaseName + latestItem.version + "-" + item.version;
|
||||
let deltaPath = archivesSourceDir.appendingPathComponent(deltaBaseName).appendingPathExtension("delta");
|
||||
|
||||
var delta:DeltaUpdate;
|
||||
let ignoreMarkerPath = cacheDir.appendingPathComponent(deltaPath.lastPathComponent).appendingPathExtension(".ignore");
|
||||
let fm = FileManager.default;
|
||||
if fm.fileExists(atPath: ignoreMarkerPath.path) {
|
||||
continue;
|
||||
}
|
||||
if !fm.fileExists(atPath: deltaPath.path) {
|
||||
if !FileManager.default.fileExists(atPath: deltaPath.path) {
|
||||
do {
|
||||
delta = try DeltaUpdate.create(from: item, to: latestItem, archivePath: deltaPath);
|
||||
} catch {
|
||||
@@ -113,37 +83,23 @@ func makeAppcast(archivesSourceDir: URL, keys: PrivateKeys, verbose: Bool) throw
|
||||
delta = DeltaUpdate(fromVersion: item.version, archivePath: deltaPath);
|
||||
}
|
||||
|
||||
numDeltas += 1;
|
||||
|
||||
// Require delta to be a bit smaller
|
||||
if delta.fileSize / 7 > latestItem.fileSize / 8 {
|
||||
markDeltaAsIgnored(delta: delta, markerPath: ignoreMarkerPath)
|
||||
continue;
|
||||
}
|
||||
if delta.fileSize / 7 < latestItem.fileSize / 8 {
|
||||
numDeltas += 1;
|
||||
if numDeltas > maxDeltas {
|
||||
break;
|
||||
}
|
||||
|
||||
group.enter();
|
||||
DispatchQueue.global().async {
|
||||
if item.supportsDSA, let privateDSAKey = keys.privateDSAKey {
|
||||
group.enter();
|
||||
DispatchQueue.global().async {
|
||||
do {
|
||||
delta.dsaSignature = try dsaSignature(path: deltaPath, privateDSAKey: privateDSAKey);
|
||||
delta.dsaSignature = try dsaSignature(path: deltaPath, privateKey: privateKey);
|
||||
latestItem.deltas.append(delta);
|
||||
} catch {
|
||||
print(delta.archivePath.lastPathComponent, error);
|
||||
}
|
||||
group.leave();
|
||||
}
|
||||
if let publicEdKey = item.publicEdKey, let privateEdKey = keys.privateEdKey {
|
||||
do {
|
||||
delta.edSignature = try edSignature(path: deltaPath, publicEdKey: publicEdKey, privateEdKey: privateEdKey);
|
||||
} catch {
|
||||
print(delta.archivePath.lastPathComponent, error);
|
||||
}
|
||||
}
|
||||
if delta.dsaSignature != nil || delta.edSignature != nil {
|
||||
latestItem.deltas.append(delta);
|
||||
} else {
|
||||
markDeltaAsIgnored(delta: delta, markerPath: ignoreMarkerPath)
|
||||
print("Delta \(delta.archivePath.path) ignored, because it could not be signed");
|
||||
}
|
||||
group.leave();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,8 +109,3 @@ func makeAppcast(archivesSourceDir: URL, keys: PrivateKeys, verbose: Bool) throw
|
||||
|
||||
return updatesByAppcast;
|
||||
}
|
||||
|
||||
func markDeltaAsIgnored(delta: DeltaUpdate, markerPath: URL) {
|
||||
let _ = try? FileManager.default.removeItem(at: delta.archivePath)
|
||||
let _ = try? Data.init().write(to: markerPath); // 0-sized file
|
||||
}
|
||||
@@ -9,7 +9,6 @@ class DeltaUpdate {
|
||||
let fromVersion: String;
|
||||
let archivePath: URL;
|
||||
var dsaSignature: String?;
|
||||
var edSignature: String?;
|
||||
|
||||
init(fromVersion: String, archivePath: URL) {
|
||||
self.archivePath = archivePath;
|
||||
@@ -39,27 +38,18 @@ class ArchiveItem: CustomStringConvertible {
|
||||
let archivePath: URL;
|
||||
let appPath: URL;
|
||||
let feedURL: URL?;
|
||||
let publicEdKey: Data?;
|
||||
let supportsDSA: Bool;
|
||||
let archiveFileAttributes: [FileAttributeKey:Any];
|
||||
var deltas: [DeltaUpdate];
|
||||
|
||||
var dsaSignature: String?;
|
||||
var edSignature: String?;
|
||||
|
||||
init(version: String, shortVersion: String?, feedURL: URL?, minimumSystemVersion: String?, publicEdKey: String?, supportsDSA: Bool, appPath: URL, archivePath: URL) throws {
|
||||
init(version: String, shortVersion: String?, feedURL: URL?, minimumSystemVersion: String?, appPath: URL, archivePath: URL) throws {
|
||||
self.version = version;
|
||||
self._shortVersion = shortVersion;
|
||||
self.feedURL = feedURL;
|
||||
self.minimumSystemVersion = minimumSystemVersion ?? "10.7";
|
||||
self.archivePath = archivePath;
|
||||
self.appPath = appPath;
|
||||
self.supportsDSA = supportsDSA;
|
||||
if let publicEdKey = publicEdKey {
|
||||
self.publicEdKey = Data(base64Encoded: publicEdKey);
|
||||
} else {
|
||||
self.publicEdKey = nil;
|
||||
}
|
||||
self.archiveFileAttributes = try FileManager.default.attributesOfItem(atPath: self.archivePath.path);
|
||||
self.deltas = [];
|
||||
}
|
||||
@@ -80,11 +70,9 @@ class ArchiveItem: CustomStringConvertible {
|
||||
throw makeError(code: .unarchivingError, "No plist \(appPath.path)");
|
||||
}
|
||||
guard let version = infoPlist[kCFBundleVersionKey] as? String else {
|
||||
throw makeError(code: .unarchivingError, "No Version \(kCFBundleVersionKey as String? ?? "missing kCFBundleVersionKey") \(appPath)");
|
||||
throw makeError(code: .unarchivingError, "No Version \(kCFBundleVersionKey) \(appPath)");
|
||||
}
|
||||
let shortVersion = infoPlist["CFBundleShortVersionString"] as? String;
|
||||
let publicEdKey = infoPlist[SUPublicEDKeyKey] as? String;
|
||||
let supportsDSA = infoPlist[SUPublicDSAKeyKey] != nil || infoPlist[SUPublicDSAKeyFileKey] != nil;
|
||||
|
||||
var feedURL:URL? = nil;
|
||||
if let feedURLStr = infoPlist["SUFeedURL"] as? String {
|
||||
@@ -95,8 +83,6 @@ class ArchiveItem: CustomStringConvertible {
|
||||
shortVersion: shortVersion,
|
||||
feedURL: feedURL,
|
||||
minimumSystemVersion: infoPlist["LSMinimumSystemVersion"] as? String,
|
||||
publicEdKey: publicEdKey,
|
||||
supportsDSA: supportsDSA,
|
||||
appPath: appPath,
|
||||
archivePath: archivePath);
|
||||
} else {
|
||||
|
||||
@@ -5,17 +5,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct PrivateKeys {
|
||||
var privateDSAKey: SecKey?;
|
||||
var privateEdKey: Data?;
|
||||
|
||||
init(privateDSAKey: SecKey?, privateEdKey: Data?) {
|
||||
self.privateDSAKey = privateDSAKey;
|
||||
self.privateEdKey = privateEdKey;
|
||||
}
|
||||
}
|
||||
|
||||
func loadPrivateDSAKey(at privateKeyURL: URL) throws -> SecKey {
|
||||
func loadPrivateKey(at privateKeyURL: URL) throws -> SecKey {
|
||||
let data = try Data(contentsOf: privateKeyURL);
|
||||
|
||||
var cfitems: CFArray? = nil;
|
||||
@@ -35,7 +25,7 @@ func loadPrivateDSAKey(at privateKeyURL: URL) throws -> SecKey {
|
||||
return (cfitems! as NSArray)[0] as! SecKey;
|
||||
}
|
||||
|
||||
func loadPrivateDSAKey(named keyName: String, fromKeychainAt keychainURL: URL) throws -> SecKey {
|
||||
func loadPrivateKey(named keyName: String, fromKeychainAt keychainURL: URL) throws -> SecKey {
|
||||
var keychain: SecKeychain? = nil
|
||||
|
||||
guard SecKeychainOpen(keychainURL.path, &keychain) == errSecSuccess, keychain != nil else {
|
||||
@@ -59,7 +49,7 @@ func loadPrivateDSAKey(named keyName: String, fromKeychainAt keychainURL: URL) t
|
||||
return item! as! SecKey
|
||||
}
|
||||
|
||||
func dsaSignature(path: URL, privateDSAKey: SecKey) throws -> String {
|
||||
func dsaSignature(path: URL, privateKey: SecKey) throws -> String {
|
||||
|
||||
var error: Unmanaged<CFError>?;
|
||||
|
||||
@@ -67,7 +57,7 @@ func dsaSignature(path: URL, privateDSAKey: SecKey) throws -> String {
|
||||
let dataReadTransform = SecTransformCreateReadTransformWithReadStream(stream);
|
||||
|
||||
let dataDigestTransform = SecDigestTransformCreate(kSecDigestSHA1, 20, nil);
|
||||
guard let dataSignTransform = SecSignTransformCreate(privateDSAKey, &error) else {
|
||||
guard let dataSignTransform = SecSignTransformCreate(privateKey, &error) else {
|
||||
print("can't use the key");
|
||||
throw error!.takeRetainedValue();
|
||||
}
|
||||
@@ -92,21 +82,3 @@ func dsaSignature(path: URL, privateDSAKey: SecKey) throws -> String {
|
||||
}
|
||||
return resultData.base64EncodedString();
|
||||
}
|
||||
|
||||
func edSignature(path: URL, publicEdKey: Data, privateEdKey: Data) throws -> String {
|
||||
assert(publicEdKey.count == 32)
|
||||
assert(privateEdKey.count == 64)
|
||||
let data = try Data.init(contentsOf: path, options: .mappedIfSafe);
|
||||
let len = data.count;
|
||||
var output = Data(count: 64);
|
||||
output.withUnsafeMutableBytes({ (output: UnsafeMutablePointer<UInt8>) in
|
||||
data.withUnsafeBytes({ (data: UnsafePointer<UInt8>) in
|
||||
publicEdKey.withUnsafeBytes({ (publicEdKey: UnsafePointer<UInt8>) in
|
||||
privateEdKey.withUnsafeBytes({ (privateEdKey: UnsafePointer<UInt8>) in
|
||||
ed25519_sign(output, data, len, publicEdKey, privateEdKey)
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
return output.base64EncodedString();
|
||||
}
|
||||
@@ -112,19 +112,19 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
|
||||
descElement.setChildren([cdata]);
|
||||
}
|
||||
|
||||
var minVer = findElement(name: SUAppcastElementMinimumSystemVersion, parent: item);
|
||||
var minVer = findElement(name: "sparkle:minimumSystemVersion", parent: item);
|
||||
if nil == minVer {
|
||||
minVer = XMLElement.element(withName: SUAppcastElementMinimumSystemVersion, uri: sparkleNS) as? XMLElement;
|
||||
minVer = XMLElement.element(withName: "sparkle:minimumSystemVersion", uri: sparkleNS) as? XMLElement;
|
||||
linebreak(item);
|
||||
item.addChild(minVer!);
|
||||
}
|
||||
minVer?.setChildren([text(update.minimumSystemVersion)]);
|
||||
|
||||
let relElement = findElement(name: SUAppcastElementReleaseNotesLink, parent: item);
|
||||
let relElement = findElement(name: "sparkle:releaseNotesLink", parent: item);
|
||||
if let url = update.releaseNotesURL {
|
||||
if nil == relElement {
|
||||
linebreak(item);
|
||||
item.addChild(XMLElement.element(withName: SUAppcastElementReleaseNotesLink, stringValue: url.absoluteString) as! XMLElement);
|
||||
item.addChild(XMLElement.element(withName:"sparkle:releaseNotesLink", stringValue: url.absoluteString) as! XMLElement);
|
||||
}
|
||||
} else if let childIndex = relElement?.index {
|
||||
item.removeChild(at: childIndex);
|
||||
@@ -142,23 +142,20 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
|
||||
};
|
||||
var attributes = [
|
||||
XMLNode.attribute(withName: "url", stringValue: archiveURL) as! XMLNode,
|
||||
XMLNode.attribute(withName: SUAppcastAttributeVersion, uri: sparkleNS, stringValue: update.version) as! XMLNode,
|
||||
XMLNode.attribute(withName: SUAppcastAttributeShortVersionString, uri: sparkleNS, stringValue: update.shortVersion) as! XMLNode,
|
||||
XMLNode.attribute(withName: "sparkle:version", uri: sparkleNS, stringValue: update.version) as! XMLNode,
|
||||
XMLNode.attribute(withName: "sparkle:shortVersionString", uri: sparkleNS, stringValue: update.shortVersion) as! XMLNode,
|
||||
XMLNode.attribute(withName: "length", stringValue: String(update.fileSize)) as! XMLNode,
|
||||
XMLNode.attribute(withName: "type", stringValue: update.mimeType) as! XMLNode,
|
||||
];
|
||||
if let sig = update.edSignature {
|
||||
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeEDSignature, uri: sparkleNS, stringValue: sig) as! XMLNode);
|
||||
}
|
||||
if let sig = update.dsaSignature {
|
||||
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeDSASignature, uri: sparkleNS, stringValue: sig) as! XMLNode);
|
||||
attributes.append(XMLNode.attribute(withName: "sparkle:dsaSignature", uri: sparkleNS, stringValue: sig) as! XMLNode);
|
||||
}
|
||||
enclosure!.attributes = attributes;
|
||||
|
||||
if update.deltas.count > 0 {
|
||||
var deltas = findElement(name: SUAppcastElementDeltas, parent: item);
|
||||
var deltas = findElement(name: "sparkle:deltas", parent: item);
|
||||
if nil == deltas {
|
||||
deltas = XMLElement.element(withName: SUAppcastElementDeltas, uri: sparkleNS) as? XMLElement;
|
||||
deltas = XMLElement.element(withName: "sparkle:deltas", uri: sparkleNS) as? XMLElement;
|
||||
linebreak(item);
|
||||
item.addChild(deltas!);
|
||||
} else {
|
||||
@@ -167,17 +164,14 @@ func writeAppcast(appcastDestPath: URL, updates: [ArchiveItem]) throws {
|
||||
for delta in update.deltas {
|
||||
var attributes = [
|
||||
XMLNode.attribute(withName: "url", stringValue: URL(string: delta.archivePath.lastPathComponent.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlPathAllowed)!, relativeTo: update.archiveURL)!.absoluteString) as! XMLNode,
|
||||
XMLNode.attribute(withName: SUAppcastAttributeVersion, uri: sparkleNS, stringValue: update.version) as! XMLNode,
|
||||
XMLNode.attribute(withName: SUAppcastAttributeShortVersionString, uri: sparkleNS, stringValue: update.shortVersion) as! XMLNode,
|
||||
XMLNode.attribute(withName: SUAppcastAttributeDeltaFrom, uri: sparkleNS, stringValue: delta.fromVersion) as! XMLNode,
|
||||
XMLNode.attribute(withName: "sparkle:version", uri: sparkleNS, stringValue: update.version) as! XMLNode,
|
||||
XMLNode.attribute(withName: "sparkle:shortVersionString", uri: sparkleNS, stringValue: update.shortVersion) as! XMLNode,
|
||||
XMLNode.attribute(withName: "sparkle:deltaFrom", uri: sparkleNS, stringValue: delta.fromVersion) as! XMLNode,
|
||||
XMLNode.attribute(withName: "length", stringValue: String(delta.fileSize)) as! XMLNode,
|
||||
XMLNode.attribute(withName: "type", stringValue: "application/octet-stream") as! XMLNode,
|
||||
];
|
||||
if let sig = delta.edSignature {
|
||||
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeEDSignature, uri: sparkleNS, stringValue: sig) as! XMLNode);
|
||||
}
|
||||
if let sig = delta.dsaSignature {
|
||||
attributes.append(XMLNode.attribute(withName: SUAppcastAttributeDSASignature, uri: sparkleNS, stringValue: sig) as! XMLNode);
|
||||
attributes.append(XMLNode.attribute(withName: "sparkle:dsaSignature", uri: sparkleNS, stringValue: sig) as! XMLNode);
|
||||
}
|
||||
linebreak(deltas!);
|
||||
deltas!.addChild(XMLNode.element(withName: "enclosure", children: nil, attributes: attributes) as! XMLElement);
|
||||
|
||||
@@ -13,11 +13,7 @@ func unarchive(itemPath:URL, archiveDestDir: URL, callback: @escaping (Error?) -
|
||||
_ = try? fileManager.createDirectory(at: tempDir, withIntermediateDirectories: true, attributes: [:]);
|
||||
|
||||
do {
|
||||
do {
|
||||
try fileManager.linkItem(at: itemPath, to: itemCopy);
|
||||
} catch {
|
||||
try fileManager.copyItem(at: itemPath, to: itemCopy);
|
||||
}
|
||||
try fileManager.linkItem(at: itemPath, to: itemCopy);
|
||||
if let unarchiver = SUUnarchiver.unarchiver(forPath: itemCopy.path, updatingHostBundlePath:nil, decryptionPassword:nil) {
|
||||
unarchiver.unarchive(completionBlock: { (error: Error?) in
|
||||
if error != nil {
|
||||
@@ -43,7 +39,8 @@ func unarchive(itemPath:URL, archiveDestDir: URL, callback: @escaping (Error?) -
|
||||
}
|
||||
}
|
||||
|
||||
func unarchiveUpdates(archivesSourceDir: URL, archivesDestDir: URL, verbose: Bool) throws -> [ArchiveItem] {
|
||||
func unarchiveUpdates(archivesSourceDir: URL, verbose: Bool) throws -> [ArchiveItem] {
|
||||
let archivesDestDir = archivesSourceDir.appendingPathComponent(".tmp");
|
||||
if verbose {
|
||||
print("Unarchiving to temp directory", archivesDestDir.path);
|
||||
}
|
||||
|
||||
+14
-35
@@ -12,59 +12,39 @@ var verbose = false;
|
||||
|
||||
func printUsage() {
|
||||
let command = URL(fileURLWithPath: CommandLine.arguments.first!).lastPathComponent;
|
||||
print("Generate appcast from a directory of Sparkle update archives\n",
|
||||
print("Generate appcast from a directory of Sparkle updates\n",
|
||||
"Usage:\n",
|
||||
" \(command) <directory with update files>\n",
|
||||
" e.g. \(command) ./my-app-release-zipfiles/\n",
|
||||
"\nOR for old apps that have a DSA keys (deprecated):\n",
|
||||
" \(command) <private DSA key path> <directory with update files>\n",
|
||||
" \(command) < -f private key path | -k keychain_path -n key_name > <directory with update archives>\n",
|
||||
" e.g. \(command) -k ~/Library/Keychains/login.keychain -n 'My Private Key' archives/\n",
|
||||
"\nOR (legacy)\n\n",
|
||||
" \(command) <private key path> <directory with update archives>\n",
|
||||
" e.g. \(command) dsa_priv.pem archives/\n",
|
||||
"\n",
|
||||
"Appcast files and deltas will be written to the archives directory.\n",
|
||||
"Note that pkg-based updates are not supported.\n"
|
||||
" Appcast files and deltas will be written to the archives directory.\n",
|
||||
" Note that pkg-based updates are not supported.\n"
|
||||
)
|
||||
}
|
||||
|
||||
func loadPrivateKeys(_ privateDSAKey: SecKey?) -> PrivateKeys {
|
||||
var privateEdKey: Data?;
|
||||
var item: CFTypeRef?;
|
||||
let res = SecItemCopyMatching([
|
||||
kSecClass as String: kSecClassGenericPassword,
|
||||
kSecAttrService as String: "https://sparkle-project.org",
|
||||
kSecAttrAccount as String: "ed25519",
|
||||
kSecAttrProtocol as String: kSecAttrProtocolSSH,
|
||||
kSecReturnData as String: kCFBooleanTrue,
|
||||
] as CFDictionary, &item);
|
||||
if res == errSecSuccess, let encoded = item as? Data, let keys = Data(base64Encoded: encoded) {
|
||||
privateEdKey = keys[0..<64];
|
||||
} else {
|
||||
print("Warning: Private key not found in the Keychain (\(res)). Please run the generate_keys tool");
|
||||
}
|
||||
return PrivateKeys(privateDSAKey: privateDSAKey, privateEdKey: privateEdKey);
|
||||
}
|
||||
|
||||
func main() {
|
||||
let args = CommandLine.arguments;
|
||||
if args.count < 2 {
|
||||
if args.count < 3 {
|
||||
printUsage()
|
||||
exit(1)
|
||||
}
|
||||
|
||||
var privateDSAKey: SecKey? = nil;
|
||||
|
||||
// this was typical usage for DSA keys
|
||||
let privateKey: SecKey
|
||||
|
||||
if args.count == 3 || (args.count == 4 && args[1] == "-f") {
|
||||
// private key specified by filename
|
||||
let privateKeyURL = URL(fileURLWithPath: args.count == 3 ? args[1] : args[2])
|
||||
|
||||
do {
|
||||
privateDSAKey = try loadPrivateDSAKey(at: privateKeyURL)
|
||||
privateKey = try loadPrivateKey(at: privateKeyURL)
|
||||
} catch {
|
||||
print("Unable to load DSA private key from", privateKeyURL.path, "\n", error)
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
// this is legacy for DSA keychain; probably very rarely used
|
||||
else if args.count == 6 && (args[1] == "-n" || args[1] == "-k") {
|
||||
// private key specified by keychain + key name
|
||||
let keyName: String
|
||||
@@ -90,22 +70,21 @@ func main() {
|
||||
}
|
||||
|
||||
do {
|
||||
privateDSAKey = try loadPrivateDSAKey(named: keyName, fromKeychainAt: keychainURL)
|
||||
privateKey = try loadPrivateKey(named: keyName, fromKeychainAt: keychainURL)
|
||||
} catch {
|
||||
print("Unable to load DSA private key '\(keyName)' from keychain at", keychainURL.path, "\n", error)
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
else if args.count != 2 {
|
||||
else {
|
||||
printUsage()
|
||||
exit(1)
|
||||
}
|
||||
|
||||
let archivesSourceDir = URL(fileURLWithPath: args.last!, isDirectory: true)
|
||||
let keys = loadPrivateKeys(privateDSAKey)
|
||||
|
||||
do {
|
||||
let allUpdates = try makeAppcast(archivesSourceDir: archivesSourceDir, keys: keys, verbose:verbose);
|
||||
let allUpdates = try makeAppcast(archivesSourceDir: archivesSourceDir, privateKey: privateKey, verbose:verbose);
|
||||
|
||||
for (appcastFile, updates) in allUpdates {
|
||||
let appcastDestPath = URL(fileURLWithPath: appcastFile, relativeTo: archivesSourceDir);
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "SUConstants.h"
|
||||
#import "SUErrors.h"
|
||||
#import "SUSignatures.h"
|
||||
#import "../ed25519/src/ed25519.h" // run `git submodule update --init` if you get an erorr here
|
||||
@@ -1,92 +0,0 @@
|
||||
//
|
||||
// main.swift
|
||||
// generate_keys
|
||||
//
|
||||
// Created by Kornel on 15/09/2018.
|
||||
// Copyright © 2018 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Security
|
||||
|
||||
func findPublicKey() -> Data? {
|
||||
var item: CFTypeRef?;
|
||||
let res = SecItemCopyMatching([
|
||||
kSecClass as String: kSecClassGenericPassword,
|
||||
kSecAttrService as String: "https://sparkle-project.org",
|
||||
kSecAttrAccount as String: "ed25519",
|
||||
kSecAttrProtocol as String: kSecAttrProtocolSSH,
|
||||
kSecReturnData as String: kCFBooleanTrue,
|
||||
] as CFDictionary, &item);
|
||||
if res == errSecSuccess, let encoded = item as? Data, let keys = Data(base64Encoded: encoded) {
|
||||
print("OK! Read the existing key saved in the Keychain.");
|
||||
return keys[64...]
|
||||
}
|
||||
else if res == errSecItemNotFound {
|
||||
return nil;
|
||||
}
|
||||
else if res == errSecAuthFailed {
|
||||
print("\nERROR! Access denied. Can't check existing keys in the keychain.");
|
||||
print("Go to Keychain Access.app, lock the login keychain, then unlock it again.");
|
||||
}
|
||||
else if res == errSecUserCanceled {
|
||||
print("\nABORTED! You've cancelled the request to read the key from the Keychain. Please run the tool again.");
|
||||
} else {
|
||||
print("\nERROR! Unable to access existing item in the Keychain", res, "(you can look it up at osstatus.com)");
|
||||
}
|
||||
exit(1)
|
||||
}
|
||||
|
||||
func generateKeyPair() -> Data {
|
||||
var seed = Data(count: 32);
|
||||
var publicEdKey = Data(count: 32);
|
||||
var privateEdKey = Data(count: 64);
|
||||
|
||||
if !seed.withUnsafeMutableBytes { (seed: UnsafeMutablePointer<UInt8>) in 0 == ed25519_create_seed(seed)} {
|
||||
print("\nERROR: Unable to initialize random seed");
|
||||
exit(1)
|
||||
}
|
||||
|
||||
seed.withUnsafeBytes({(seed: UnsafePointer<UInt8>) in
|
||||
publicEdKey.withUnsafeMutableBytes({(publicEdKey: UnsafeMutablePointer<UInt8>) in
|
||||
privateEdKey.withUnsafeMutableBytes({(privateEdKey: UnsafeMutablePointer<UInt8>) in
|
||||
ed25519_create_keypair(publicEdKey, privateEdKey, seed);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
let bothKeys = privateEdKey + publicEdKey; // public key can't be derived from the private one
|
||||
let query = [
|
||||
// macOS doesn't support ed25519 keys, so we're forced to save the key as a "password"
|
||||
// and add some made-up service data for it to prevent it clashing with other passwords.
|
||||
kSecClass as String: kSecClassGenericPassword,
|
||||
kSecAttrService as String: "https://sparkle-project.org",
|
||||
kSecAttrAccount as String: "ed25519",
|
||||
|
||||
kSecValueData as String: bothKeys.base64EncodedData() as CFData, // it's base64-encoded, because user may request to show it
|
||||
kSecAttrIsSensitive as String: kCFBooleanTrue,
|
||||
kSecAttrIsPermanent as String: kCFBooleanTrue,
|
||||
kSecAttrLabel as String: "Private key for signing Sparkle updates",
|
||||
kSecAttrComment as String: "Public key (SUPublicEDKey value) for this key is:\n\n\(publicEdKey.base64EncodedString())",
|
||||
kSecAttrDescription as String: "private key",
|
||||
] as CFDictionary;
|
||||
let res = SecItemAdd(query, nil);
|
||||
|
||||
if res == errSecSuccess {
|
||||
print("OK! A new key has been generated and saved in the Keychain.");
|
||||
}
|
||||
else if res == errSecDuplicateItem {
|
||||
print("\nERROR: You already have a previously generated key in the Keychain");
|
||||
} else if res == errSecAuthFailed {
|
||||
print("\nERROR: System denied access to the Keychain. Unable to save the new key");
|
||||
print("Go to Keychain Access.app, lock the login keychain, then unlock it again.");
|
||||
} else {
|
||||
print("\nERROR: The key could not be saved to the Keychain. error: \(res) (you can look it up at osstatus.com)");
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
print("This tool uses macOS Keychain to store the Sparkle private key.")
|
||||
print("If the Keychain prompts you for permission, please allow it.")
|
||||
let pubKey = findPublicKey() ?? generateKeyPair();
|
||||
print("\nIn your app's Info.plist set SUPublicEDKey to:\n\(pubKey.base64EncodedString())\n")
|
||||
@@ -1,70 +0,0 @@
|
||||
//
|
||||
// main.swift
|
||||
// sign_update
|
||||
//
|
||||
// Created by Kornel on 16/09/2018.
|
||||
// Copyright © 2018 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Security
|
||||
|
||||
func findKeys() -> (Data, Data) {
|
||||
var item: CFTypeRef?;
|
||||
let res = SecItemCopyMatching([
|
||||
kSecClass as String: kSecClassGenericPassword,
|
||||
kSecAttrService as String: "https://sparkle-project.org",
|
||||
kSecAttrAccount as String: "ed25519",
|
||||
kSecAttrProtocol as String: kSecAttrProtocolSSH,
|
||||
kSecReturnData as String: kCFBooleanTrue,
|
||||
] as CFDictionary, &item);
|
||||
if res == errSecSuccess, let encoded = item as? Data, let keys = Data(base64Encoded: encoded) {
|
||||
return (keys[0..<64], keys[64..<(64+32)])
|
||||
}
|
||||
else if res == errSecItemNotFound {
|
||||
print("ERROR! Signing key not found. Please run generate_keys tool first.");
|
||||
}
|
||||
else if res == errSecAuthFailed {
|
||||
print("ERROR! Access denied. Can't get keys from the keychain.");
|
||||
print("Go to Keychain Access.app, lock the login keychain, then unlock it again.");
|
||||
}
|
||||
else if res == errSecUserCanceled {
|
||||
print("ABORTED! You've cancelled the request to read the key from the Keychain. Please run the tool again.");
|
||||
} else {
|
||||
print("ERROR! Unable to access required key in the Keychain", res, "(you can look it up at osstatus.com)");
|
||||
}
|
||||
exit(1)
|
||||
}
|
||||
|
||||
func edSignature(data: Data, publicEdKey: Data, privateEdKey: Data) -> String {
|
||||
assert(publicEdKey.count == 32)
|
||||
assert(privateEdKey.count == 64)
|
||||
let len = data.count;
|
||||
var output = Data(count: 64);
|
||||
output.withUnsafeMutableBytes({ (output: UnsafeMutablePointer<UInt8>) in
|
||||
data.withUnsafeBytes({ (data: UnsafePointer<UInt8>) in
|
||||
publicEdKey.withUnsafeBytes({ (publicEdKey: UnsafePointer<UInt8>) in
|
||||
privateEdKey.withUnsafeBytes({ (privateEdKey: UnsafePointer<UInt8>) in
|
||||
ed25519_sign(output, data, len, publicEdKey, privateEdKey)
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
return output.base64EncodedString();
|
||||
}
|
||||
|
||||
let args = CommandLine.arguments;
|
||||
if args.count != 2 {
|
||||
print("Usage: \(args[0]) <archive to sign>\nPrivavte EDDSA (ed25519) key is automatically read from the Keychain.\n");
|
||||
exit(1)
|
||||
}
|
||||
|
||||
let(priv, pub) = findKeys();
|
||||
|
||||
do {
|
||||
let data = try Data.init(contentsOf: URL.init(fileURLWithPath: args[1]), options: .mappedIfSafe);
|
||||
let sig = edSignature(data:data , publicEdKey: pub, privateEdKey: priv);
|
||||
print("sparkle:edSignature=\"\(sig)\" length=\"\(data.count)\"");
|
||||
} catch {
|
||||
print("ERROR: ", error)
|
||||
}
|
||||
Reference in new issue
Block a user