diff --git a/Autoupdate/SUBinaryDeltaTool.m b/Autoupdate/SUBinaryDeltaTool.m index 64b06162..624db703 100644 --- a/Autoupdate/SUBinaryDeltaTool.m +++ b/Autoupdate/SUBinaryDeltaTool.m @@ -30,7 +30,7 @@ static void printUsage(NSString *programName) fprintf(stderr, "%s version []\n", [programName UTF8String]); } -static BOOL runCreateCommand(NSString *programName, NSArray *args) +static BOOL runCreateCommand(NSString *programName, NSArray *args) { if (args.count < 3 || args.count > 5) { printUsage(programName); @@ -62,7 +62,7 @@ static BOOL runCreateCommand(NSString *programName, NSArray *args) BOOL verbose = (verboseIndex != NSNotFound); NSString *versionField = (versionIndex != NSNotFound) ? args[versionIndex] : nil; - NSArray *versionComponents = nil; + NSArray *versionComponents = nil; if (versionField) { versionComponents = [versionField componentsSeparatedByString:@"="]; if (versionComponents.count != 2) { @@ -218,7 +218,7 @@ static BOOL runVersionCommand(NSString *programName, NSArray *args) int main(int __unused argc, char __unused *argv[]) { @autoreleasepool { - NSArray *args = [[NSProcessInfo processInfo] arguments]; + NSArray *args = [[NSProcessInfo processInfo] arguments]; NSString *programName = [args[0] lastPathComponent]; if (args.count < 2) { diff --git a/Configurations/ConfigCommon.xcconfig b/Configurations/ConfigCommon.xcconfig index 91c72e18..accac0de 100644 --- a/Configurations/ConfigCommon.xcconfig +++ b/Configurations/ConfigCommon.xcconfig @@ -88,11 +88,8 @@ GCC_WARN_UNUSED_LABEL = YES GCC_WARN_UNUSED_PARAMETER = YES GCC_WARN_UNUSED_VARIABLE = YES -// Fixes a strange issue where the compiler thinks references to some enums are ambiguous -CLANG_ENABLE_MODULES[sdk=macosx10.8] = NO - // These should be removed once the conversion to ARC is complete 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-format-non-iso $(WARNING_CFLAGS_EXTRA) diff --git a/Resources/SampleAppcast.xml b/Resources/SampleAppcast.xml index dd9c089d..eacb8eaa 100755 --- a/Resources/SampleAppcast.xml +++ b/Resources/SampleAppcast.xml @@ -11,7 +11,7 @@ Wed, 09 Jan 2006 19:20:11 +0000 - 10.7 + 10.9 @@ -21,7 +21,7 @@ Wed, 01 Jan 2006 12:20:11 +0000 - 10.7 + 10.9 @@ -32,7 +32,7 @@ Wed, 25 Dec 2005 12:20:11 +0000 - 10.7 + 10.9 diff --git a/Sparkle.podspec b/Sparkle.podspec index f7734930..e57b5030 100644 --- a/Sparkle.podspec +++ b/Sparkle.podspec @@ -18,7 +18,7 @@ Pod::Spec.new do |s| 'Andy Matuschak' => 'andy@andymatuschak.org', } - s.platform = :osx, '10.7' + s.platform = :osx, '10.9' s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" } s.source_files = 'Sparkle.framework/Versions/A/Headers/*.h' diff --git a/Sparkle/SPUBasicUpdateDriver.m b/Sparkle/SPUBasicUpdateDriver.m index d63caa1c..921cc80a 100644 --- a/Sparkle/SPUBasicUpdateDriver.m +++ b/Sparkle/SPUBasicUpdateDriver.m @@ -131,7 +131,7 @@ - (void)didFinishLoadingAppcast:(SUAppcast *)appcast { if (!self.aborted) { - if ([self.updaterDelegate respondsToSelector:@selector(updater:didFinishLoadingAppcast:)]) { + if ([self.updaterDelegate respondsToSelector:@selector((updater:didFinishLoadingAppcast:))]) { [self.updaterDelegate updater:self.updater didFinishLoadingAppcast:appcast]; } @@ -146,7 +146,7 @@ object:self.updater userInfo:@{ SUUpdaterAppcastItemNotificationKey: updateItem }]; - if ([self.updaterDelegate respondsToSelector:@selector(updater:didFindValidUpdate:)]) { + if ([self.updaterDelegate respondsToSelector:@selector((updater:didFindValidUpdate:))]) { [self.updaterDelegate updater:self.updater didFindValidUpdate:updateItem]; } @@ -157,7 +157,7 @@ - (void)didNotFindUpdate { if (!self.aborted) { - if ([self.updaterDelegate respondsToSelector:@selector(updaterDidNotFindUpdate:)]) { + if ([self.updaterDelegate respondsToSelector:@selector((updaterDidNotFindUpdate:))]) { [self.updaterDelegate updaterDidNotFindUpdate:self.updater]; } [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater]; @@ -189,7 +189,7 @@ } // Notify host app that updater has aborted - if ([self.updaterDelegate respondsToSelector:@selector(updater:didAbortWithError:)]) { + if ([self.updaterDelegate respondsToSelector:@selector((updater:didAbortWithError:))]) { [self.updaterDelegate updater:self.updater didAbortWithError:(NSError * _Nonnull)error]; } } diff --git a/Sparkle/SPUCoreBasedUpdateDriver.m b/Sparkle/SPUCoreBasedUpdateDriver.m index 0522054a..015972ab 100644 --- a/Sparkle/SPUCoreBasedUpdateDriver.m +++ b/Sparkle/SPUCoreBasedUpdateDriver.m @@ -168,7 +168,7 @@ { self.downloadDriver = [[SPUDownloadDriver alloc] initWithUpdateItem:updateItem host:self.host userAgent:self.userAgent inBackground:background delegate:self]; - if ([self.updaterDelegate respondsToSelector:@selector(updater:willDownloadUpdate:withRequest:)]) { + if ([self.updaterDelegate respondsToSelector:@selector((updater:willDownloadUpdate:withRequest:))]) { [self.updaterDelegate updater:self.updater willDownloadUpdate:updateItem withRequest:self.downloadDriver.request]; @@ -240,7 +240,7 @@ - (void)downloadDriverDidFailToDownloadUpdateWithError:(NSError *)error { - if ([self.updaterDelegate respondsToSelector:@selector(updater:failedToDownloadUpdate:error:)]) { + if ([self.updaterDelegate respondsToSelector:@selector((updater:failedToDownloadUpdate:error:))]) { NSError *errorToReport = [error.userInfo objectForKey:NSUnderlyingErrorKey]; if (errorToReport == nil) { errorToReport = error; @@ -290,13 +290,13 @@ - (void)installerWillFinishInstallationAndRelaunch:(BOOL)relaunch { - if ([self.updaterDelegate respondsToSelector:@selector(updater:willInstallUpdate:)]) { + if ([self.updaterDelegate respondsToSelector:@selector((updater:willInstallUpdate:))]) { [self.updaterDelegate updater:self.updater willInstallUpdate:self.updateItem]; } if (relaunch) { [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self]; - if ([self.updaterDelegate respondsToSelector:@selector(updaterWillRelaunchApplication:)]) { + if ([self.updaterDelegate respondsToSelector:@selector((updaterWillRelaunchApplication:))]) { [self.updaterDelegate updaterWillRelaunchApplication:self.updater]; } } diff --git a/Sparkle/SPUInstallerDriver.m b/Sparkle/SPUInstallerDriver.m index 6995c44f..9bf034e8 100644 --- a/Sparkle/SPUInstallerDriver.m +++ b/Sparkle/SPUInstallerDriver.m @@ -446,7 +446,7 @@ - (BOOL)mayUpdateAndRestart { - return (!self.updaterDelegate || ![self.updaterDelegate respondsToSelector:@selector(updaterShouldRelaunchApplication:)] || [self.updaterDelegate updaterShouldRelaunchApplication:self.updater]); + return (!self.updaterDelegate || ![self.updaterDelegate respondsToSelector:@selector((updaterShouldRelaunchApplication:))] || [self.updaterDelegate updaterShouldRelaunchApplication:self.updater]); } // Only implemented due to backwards compability reasons; see -installWithToolAndRelaunch:displayingUserInterface: below diff --git a/Sparkle/SPUUIBasedUpdateDriver.m b/Sparkle/SPUUIBasedUpdateDriver.m index 33932533..425b9ca0 100644 --- a/Sparkle/SPUUIBasedUpdateDriver.m +++ b/Sparkle/SPUUIBasedUpdateDriver.m @@ -189,7 +189,7 @@ break; case SPUDownloadUpdateCanceled: dispatch_async(dispatch_get_main_queue(), ^{ - if ([self.updaterDelegate respondsToSelector:@selector(userDidCancelDownload:)]) { + if ([self.updaterDelegate respondsToSelector:@selector((userDidCancelDownload:))]) { [self.updaterDelegate userDidCancelDownload:self.updater]; } diff --git a/Sparkle/SPUUpdater.m b/Sparkle/SPUUpdater.m index 3a7acafc..0633d04c 100644 --- a/Sparkle/SPUUpdater.m +++ b/Sparkle/SPUUpdater.m @@ -267,7 +267,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification shouldPrompt = NO; } // Does the delegate want to take care of the logic for when we should ask permission to update? - else if ([self.delegate respondsToSelector:@selector(updaterShouldPromptForPermissionToCheckForUpdates:)]) { + else if ([self.delegate respondsToSelector:@selector((updaterShouldPromptForPermissionToCheckForUpdates:))]) { shouldPrompt = [self.delegate updaterShouldPromptForPermissionToCheckForUpdates:self]; } // Has the user been asked already? And don't ask if the host has a default value set in its Info.plist. @@ -283,7 +283,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification if (shouldPrompt) { NSArray *> *profileInfo = [SUSystemProfiler systemProfileArrayForHost:self.host]; // Always say we're sending the system profile here so that the delegate displays the parameters it would send. - if ([self.delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) { + if ([self.delegate respondsToSelector:@selector((feedParametersForUpdater:sendingSystemProfile:))]) { NSArray *feedParameters = [self.delegate feedParametersForUpdater:self sendingSystemProfile:YES]; if (feedParameters != nil) { profileInfo = [profileInfo arrayByAddingObjectsFromArray:feedParameters]; @@ -329,9 +329,9 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification - (void)updateLastUpdateCheckDate { - [self willChangeValueForKey:NSStringFromSelector(@selector(lastUpdateCheckDate))]; + [self willChangeValueForKey:NSStringFromSelector(@selector((lastUpdateCheckDate)))]; [self.host setObject:[NSDate date] forUserDefaultsKey:SULastCheckTimeKey]; - [self didChangeValueForKey:NSStringFromSelector(@selector(lastUpdateCheckDate))]; + [self didChangeValueForKey:NSStringFromSelector(@selector((lastUpdateCheckDate)))]; } - (void)scheduleNextUpdateCheck @@ -512,7 +512,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification [self updateLastUpdateCheckDate]; - if( [self.delegate respondsToSelector: @selector(updaterMayCheckForUpdates:)] && ![self.delegate updaterMayCheckForUpdates:self] ) + if( [self.delegate respondsToSelector: @selector((updaterMayCheckForUpdates:))] && ![self.delegate updaterMayCheckForUpdates:self] ) { [self scheduleNextUpdateCheck]; return; @@ -643,7 +643,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification // A value in the user defaults overrides one in the Info.plist (so preferences panels can be created wherein users choose between beta / release feeds). NSString *appcastString = [self.host objectForKey:SUFeedURLKey]; - if ([self.delegate respondsToSelector:@selector(feedURLStringForUpdater:)]) { + if ([self.delegate respondsToSelector:@selector((feedURLStringForUpdater:))]) { NSString *delegateAppcastString = [self.delegate feedURLStringForUpdater:self]; if (delegateAppcastString != nil) { appcastString = delegateAppcastString; @@ -740,7 +740,7 @@ static NSString *escapeURLComponent(NSString *str) { sendingSystemProfile &= (-[lastSubmitDate timeIntervalSinceNow] >= oneWeek); NSArray *> *parameters = @[]; - if ([self.delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) { + if ([self.delegate respondsToSelector:@selector((feedParametersForUpdater:sendingSystemProfile:))]) { NSArray *feedParameters = [self.delegate feedParametersForUpdater:self sendingSystemProfile:sendingSystemProfile]; if (feedParameters != nil) { parameters = [parameters arrayByAddingObjectsFromArray:feedParameters]; diff --git a/Sparkle/SUAppcastDriver.m b/Sparkle/SUAppcastDriver.m index 149bba33..9a864d81 100644 --- a/Sparkle/SUAppcastDriver.m +++ b/Sparkle/SUAppcastDriver.m @@ -78,7 +78,7 @@ SUAppcastItem *nonDeltaUpdateItem = nil; // Now we have to find the best valid update in the appcast. - if ([self.updaterDelegate respondsToSelector:@selector(bestValidUpdateInAppcast:forUpdater:)]) + if ([self.updaterDelegate respondsToSelector:@selector((bestValidUpdateInAppcast:forUpdater:))]) { item = [self.updaterDelegate bestValidUpdateInAppcast:ac forUpdater:(id _Nonnull)self.updater]; } @@ -157,7 +157,7 @@ id comparator = nil; // Give the delegate a chance to provide a custom version comparator - if ([self.updaterDelegate respondsToSelector:@selector(versionComparatorForUpdater:)]) { + if ([self.updaterDelegate respondsToSelector:@selector((versionComparatorForUpdater:))]) { comparator = [self.updaterDelegate versionComparatorForUpdater:(id _Nonnull)self.updater]; } diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index af8a448f..2b7f1035 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -158,7 +158,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) { // Even if we fail removing the quarantine from the root item or any single item in the directory, we will continue trying to remove the quarantine. // This is because often it may not be a fatal error from the caller to not remove the quarantine of an item NSDictionary *rootAttributes = [_fileManager attributesOfItemAtPath:rootURLPath error:nil]; - NSString *rootType = [rootAttributes objectForKey:NSFileType]; // 10.7 can't subscript this + NSString *rootType = rootAttributes[NSFileType]; if ([rootType isEqualToString:NSFileTypeDirectory]) { // The NSDirectoryEnumerator will avoid recursing into any contained diff --git a/Sparkle/SUHost.m b/Sparkle/SUHost.m index a8d2fa5d..2b4b7b06 100755 --- a/Sparkle/SUHost.m +++ b/Sparkle/SUHost.m @@ -244,7 +244,7 @@ } else { - value = (BOOL)CFBooleanGetValue((CFBooleanRef)plr); + value = CFBooleanGetValue((CFBooleanRef)plr) ? YES : NO; CFRelease(plr); } return value; diff --git a/TestApplication/SUTestApplicationDelegate.m b/TestApplication/SUTestApplicationDelegate.m index 5b6e74ec..ad003e49 100644 --- a/TestApplication/SUTestApplicationDelegate.m +++ b/TestApplication/SUTestApplicationDelegate.m @@ -140,7 +140,7 @@ static NSString * const UPDATED_VERSION = @"2.0"; ed25519_sign(signature, archive.bytes, archive.length, public_key, self_sign_demo_only_insecure_hack); - NSString *signatureString = [[NSData dataWithBytes:signature length:64] base64Encoding]; + NSString *signatureString = [[NSData dataWithBytes:signature length:64] base64EncodedStringWithOptions:0]; // Obtain the file attributes to get the file size of our update later NSError *fileAttributesError = nil; diff --git a/generate_appcast/ArchiveItem.swift b/generate_appcast/ArchiveItem.swift index 581cf078..341941aa 100644 --- a/generate_appcast/ArchiveItem.swift +++ b/generate_appcast/ArchiveItem.swift @@ -53,7 +53,7 @@ class ArchiveItem: CustomStringConvertible { self.version = version self._shortVersion = shortVersion self.feedURL = feedURL - self.minimumSystemVersion = minimumSystemVersion ?? "10.7" + self.minimumSystemVersion = minimumSystemVersion ?? "10.9" self.archivePath = archivePath self.appPath = appPath self.supportsDSA = supportsDSA @@ -86,7 +86,7 @@ class ArchiveItem: CustomStringConvertible { guard let infoPlist = NSDictionary(contentsOf: appPath.appendingPathComponent("Contents/Info.plist")) else { throw makeError(code: .unarchivingError, "No plist \(appPath.path)") } - guard let version = infoPlist[kCFBundleVersionKey] as? String else { + guard let version = infoPlist[kCFBundleVersionKey!] as? String else { throw makeError(code: .unarchivingError, "No Version \(kCFBundleVersionKey as String? ?? "missing kCFBundleVersionKey") \(appPath)") } let shortVersion = infoPlist["CFBundleShortVersionString"] as? String diff --git a/generate_appcast/Signatures.swift b/generate_appcast/Signatures.swift index 10cafed5..ed8b0fd0 100644 --- a/generate_appcast/Signatures.swift +++ b/generate_appcast/Signatures.swift @@ -98,17 +98,10 @@ func dsaSignature(path: URL, privateDSAKey: SecKey) throws -> String { 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) in - data.withUnsafeBytes({ (data: UnsafePointer) in - publicEdKey.withUnsafeBytes({ (publicEdKey: UnsafePointer) in - privateEdKey.withUnsafeBytes({ (privateEdKey: UnsafePointer) in - ed25519_sign(output, data, len, publicEdKey, privateEdKey) - }) - }) - }) - }) - return output.base64EncodedString() + let data = Array(try Data.init(contentsOf: path, options: .mappedIfSafe)) + var output = Array(repeating: 0, count: 64) + let pubkey = Array(publicEdKey), privkey = Array(privateEdKey) + + ed25519_sign(&output, data, data.count, pubkey, privkey) + return Data(output).base64EncodedString() } diff --git a/generate_appcast/main.swift b/generate_appcast/main.swift index 6f7ab20b..0c67fc67 100644 --- a/generate_appcast/main.swift +++ b/generate_appcast/main.swift @@ -59,8 +59,8 @@ func loadPrivateKeys(_ privateDSAKey: SecKey?, _ privateEdString: String?) -> Pr kSecAttrService as String: "https://sparkle-project.org", kSecAttrAccount as String: "ed25519", kSecAttrProtocol as String: kSecAttrProtocolSSH, - kSecReturnData as String: kCFBooleanTrue, - ] as CFDictionary, &item) + kSecReturnData as String: kCFBooleanTrue!, + ] as CFDictionary, &item) if res == errSecSuccess, let encoded = item as? Data, let data = Data(base64Encoded: encoded) { keys = data } else { diff --git a/generate_keys/main.swift b/generate_keys/main.swift index 9964c460..30f4dad9 100644 --- a/generate_keys/main.swift +++ b/generate_keys/main.swift @@ -17,7 +17,7 @@ func findPublicKey() -> Data? { kSecAttrAccount as String: "ed25519", kSecAttrProtocol as String: kSecAttrProtocolSSH, // kSecAttrSynchronizableAny as String: kCFBooleanTrue, - kSecReturnData as String: kCFBooleanTrue, + kSecReturnData as String: kCFBooleanTrue!, ] as CFDictionary, &item) if res == errSecSuccess, let encoded = item as? Data, let keys = Data(base64Encoded: encoded) { @@ -39,24 +39,17 @@ func findPublicKey() -> Data? { } func generateKeyPair(makeSyncable: Bool) -> Data { - var seed = Data(count: 32) - var publicEdKey = Data(count: 32) - var privateEdKey = Data(count: 64) + var seed = Array(repeating: 0, count: 32) + var publicEdKey = Array(repeating: 0, count: 32) + var privateEdKey = Array(repeating: 0, count: 64) - if !seed.withUnsafeMutableBytes({ 0 == ed25519_create_seed($0) }) { + guard ed25519_create_seed(&seed) == 0 else { print("\nERROR: Unable to initialize random seed") exit(1) } + ed25519_create_keypair(&publicEdKey, &privateEdKey, seed) - seed.withUnsafeBytes { seed in - publicEdKey.withUnsafeMutableBytes { publicEdKey in - privateEdKey.withUnsafeMutableBytes { privateEdKey in - ed25519_create_keypair(publicEdKey, privateEdKey, seed) - } - } - } - - let bothKeys = privateEdKey + publicEdKey; // public key can't be derived from the private one + let bothKeys = Data(privateEdKey) + Data(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. @@ -65,10 +58,10 @@ func generateKeyPair(makeSyncable: Bool) -> Data { 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, + 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())", + kSecAttrComment as String: "Public key (SUPublicEDKey value) for this key is:\n\n\(Data(publicEdKey).base64EncodedString())", kSecAttrDescription as String: "private key", // kSecAttrSynchronizable as String: (makeSyncable ? kCFBooleanTrue : kCFBooleanFalse)!, @@ -78,7 +71,7 @@ func generateKeyPair(makeSyncable: Bool) -> Data { if res == errSecSuccess { // print("OK! A new key has been generated and saved in the Keychain.") - return publicEdKey + return Data(publicEdKey) } else if res == errSecDuplicateItem { print("\nERROR: You already have a previously generated key in the Keychain") } else if res == errSecAuthFailed { diff --git a/sign_update/main.swift b/sign_update/main.swift index 2bb85ab3..cfaded3c 100644 --- a/sign_update/main.swift +++ b/sign_update/main.swift @@ -16,7 +16,7 @@ func findKeys() -> (Data, Data) { kSecAttrService as String: "https://sparkle-project.org", kSecAttrAccount as String: "ed25519", kSecAttrProtocol as String: kSecAttrProtocolSSH, - kSecReturnData as String: kCFBooleanTrue, + 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)]) @@ -38,18 +38,12 @@ func findKeys() -> (Data, Data) { 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) in - data.withUnsafeBytes({ (data: UnsafePointer) in - publicEdKey.withUnsafeBytes({ (publicEdKey: UnsafePointer) in - privateEdKey.withUnsafeBytes({ (privateEdKey: UnsafePointer) in - ed25519_sign(output, data, len, publicEdKey, privateEdKey) - }) - }) - }) - }) - return output.base64EncodedString() + let data = Array(data) + var output = Array(repeating: 0, count: 64) + let pubkey = Array(publicEdKey), privkey = Array(privateEdKey) + + ed25519_sign(&output, data, data.count, pubkey, privkey) + return Data(output).base64EncodedString() } let args = CommandLine.arguments