mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Check if public key is configured correctly
This commit is contained in:
1 parent
091a86f672
commit
f80907fa2c
3 files changed
+15
-7
No files matched your search
@@ -44,11 +44,15 @@ func makeAppcast(archivesSourceDir: URL, keys: PrivateKeys, verbose: Bool) throw
|
||||
print("Note: did not sign with legacy DSA \(update.archivePath.path) because private DSA key file was not specified");
|
||||
}
|
||||
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);
|
||||
if let privateEdKey = keys.privateEdKey, let expectedPublicKey = keys.publicEdKey {
|
||||
if publicEdKey == expectedPublicKey {
|
||||
do {
|
||||
update.edSignature = try edSignature(path: update.archivePath, publicEdKey: publicEdKey, privateEdKey: privateEdKey);
|
||||
} catch {
|
||||
print(update, error);
|
||||
}
|
||||
} else {
|
||||
print("Warning: SUPublicEDKey in the app \(update.archivePath.path) does not match key EdDSA in the Keychain. Run generate_keys and update Info.plist to match");
|
||||
}
|
||||
} else {
|
||||
print("Warning: could not sign \(update.archivePath.path) due to lack of private EdDSA key");
|
||||
|
||||
@@ -8,10 +8,12 @@ import Foundation
|
||||
struct PrivateKeys {
|
||||
var privateDSAKey: SecKey?;
|
||||
var privateEdKey: Data?;
|
||||
var publicEdKey: Data?;
|
||||
|
||||
init(privateDSAKey: SecKey?, privateEdKey: Data?) {
|
||||
init(privateDSAKey: SecKey?, privateEdKey: Data?, publicEdKey: Data?) {
|
||||
self.privateDSAKey = privateDSAKey;
|
||||
self.privateEdKey = privateEdKey;
|
||||
self.publicEdKey = publicEdKey;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ func printUsage() {
|
||||
|
||||
func loadPrivateKeys(_ privateDSAKey: SecKey?) -> PrivateKeys {
|
||||
var privateEdKey: Data?;
|
||||
var publicEdKey: Data?;
|
||||
var item: CFTypeRef?;
|
||||
let res = SecItemCopyMatching([
|
||||
kSecClass as String: kSecClassGenericPassword,
|
||||
@@ -37,10 +38,11 @@ func loadPrivateKeys(_ privateDSAKey: SecKey?) -> PrivateKeys {
|
||||
] as CFDictionary, &item);
|
||||
if res == errSecSuccess, let encoded = item as? Data, let keys = Data(base64Encoded: encoded) {
|
||||
privateEdKey = keys[0..<64];
|
||||
publicEdKey = keys[64...];
|
||||
} else {
|
||||
print("Warning: Private key not found in the Keychain (\(res)). Please run the generate_keys tool");
|
||||
}
|
||||
return PrivateKeys(privateDSAKey: privateDSAKey, privateEdKey: privateEdKey);
|
||||
return PrivateKeys(privateDSAKey: privateDSAKey, privateEdKey: privateEdKey, publicEdKey: publicEdKey);
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
Reference in new issue
Block a user