Support ObjectivePGP 0.9.0
This commit is contained in:
parent
f5f9fe505b
commit
9b8bdbf5e9
3 changed files with 11 additions and 10 deletions
2
Podfile
2
Podfile
|
|
@ -2,7 +2,7 @@ platform :ios, '10.2'
|
||||||
use_frameworks!
|
use_frameworks!
|
||||||
|
|
||||||
target 'passKit' do
|
target 'passKit' do
|
||||||
pod 'ObjectivePGP', :git => 'https://github.com/krzyzanowskim/ObjectivePGP.git'
|
pod 'ObjectivePGP', :git => 'https://github.com/krzyzanowskim/ObjectivePGP.git', :tag => '0.9.0'
|
||||||
target 'pass' do
|
target 'pass' do
|
||||||
inherit! :search_paths
|
inherit! :search_paths
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "0900"
|
LastUpgradeVersion = "0910"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
|
|
||||||
|
|
@ -21,16 +21,16 @@ public class PasswordStore {
|
||||||
|
|
||||||
public var storeRepository: GTRepository?
|
public var storeRepository: GTRepository?
|
||||||
public var pgpKeyID: String?
|
public var pgpKeyID: String?
|
||||||
public var publicKey: PGPKey? {
|
public var publicKey: Key? {
|
||||||
didSet {
|
didSet {
|
||||||
if publicKey != nil {
|
if publicKey != nil {
|
||||||
pgpKeyID = publicKey!.keyID.shortKeyString
|
pgpKeyID = publicKey!.keyID.shortIdentifier
|
||||||
} else {
|
} else {
|
||||||
pgpKeyID = nil
|
pgpKeyID = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public var privateKey: PGPKey?
|
public var privateKey: Key?
|
||||||
|
|
||||||
public var gitSignatureForNow: GTSignature {
|
public var gitSignatureForNow: GTSignature {
|
||||||
get {
|
get {
|
||||||
|
|
@ -235,9 +235,10 @@ public class PasswordStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private func importKey(from keyPath: String) -> PGPKey? {
|
private func importKey(from keyPath: String) -> Key? {
|
||||||
if fm.fileExists(atPath: keyPath) {
|
if fm.fileExists(atPath: keyPath) {
|
||||||
let keys = pgp.importKeys(fromFile: keyPath)
|
let keys = ObjectivePGP.readKeys(from: keyPath)
|
||||||
|
pgp.import(keys: keys)
|
||||||
if !keys.isEmpty {
|
if !keys.isEmpty {
|
||||||
return keys.first
|
return keys.first
|
||||||
}
|
}
|
||||||
|
|
@ -245,7 +246,7 @@ public class PasswordStore {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
public func getPgpPrivateKey() -> PGPKey {
|
public func getPgpPrivateKey() -> Key {
|
||||||
return pgp.keys.filter({$0.secretKey != nil})[0]
|
return pgp.keys.filter({$0.secretKey != nil})[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -841,7 +842,7 @@ public class PasswordStore {
|
||||||
if passphrase == nil {
|
if passphrase == nil {
|
||||||
passphrase = requestPGPKeyPassphrase()
|
passphrase = requestPGPKeyPassphrase()
|
||||||
}
|
}
|
||||||
let decryptedData = try PasswordStore.shared.pgp.decryptData(encryptedData, passphrase: passphrase)
|
let decryptedData = try PasswordStore.shared.pgp.decrypt(encryptedData, passphrase: passphrase)
|
||||||
let plainText = String(data: decryptedData, encoding: .utf8) ?? ""
|
let plainText = String(data: decryptedData, encoding: .utf8) ?? ""
|
||||||
let escapedPath = passwordEntity.path!.stringByAddingPercentEncodingForRFC3986() ?? ""
|
let escapedPath = passwordEntity.path!.stringByAddingPercentEncodingForRFC3986() ?? ""
|
||||||
return Password(name: passwordEntity.name!, url: URL(string: escapedPath), plainText: plainText)
|
return Password(name: passwordEntity.name!, url: URL(string: escapedPath), plainText: plainText)
|
||||||
|
|
@ -853,7 +854,7 @@ public class PasswordStore {
|
||||||
throw AppError.PGPPublicKeyNotExistError
|
throw AppError.PGPPublicKeyNotExistError
|
||||||
}
|
}
|
||||||
let plainData = password.getPlainData()
|
let plainData = password.getPlainData()
|
||||||
let encryptedData = try pgp.encryptData(plainData, using: Array(publicKey), armored: SharedDefaults[.encryptInArmored])
|
let encryptedData = try pgp.encrypt(plainData, using: Array(publicKey), armored: SharedDefaults[.encryptInArmored])
|
||||||
return encryptedData
|
return encryptedData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue