diff --git a/Adamant.xcodeproj/project.pbxproj b/Adamant.xcodeproj/project.pbxproj index 13956ba5d..927685dfb 100644 --- a/Adamant.xcodeproj/project.pbxproj +++ b/Adamant.xcodeproj/project.pbxproj @@ -845,6 +845,7 @@ "${BUILT_PRODUCTS_DIR}/MessageKit/MessageKit.framework", "${BUILT_PRODUCTS_DIR}/MyLittlePinpad/MyLittlePinpad.framework", "${BUILT_PRODUCTS_DIR}/QRCodeReader.swift/QRCodeReader.framework", + "${BUILT_PRODUCTS_DIR}/RNCryptor/RNCryptor.framework", "${BUILT_PRODUCTS_DIR}/Swinject/Swinject.framework", "${BUILT_PRODUCTS_DIR}/SwinjectStoryboard/SwinjectStoryboard.framework", ); @@ -859,6 +860,7 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MessageKit.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MyLittlePinpad.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/QRCodeReader.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/RNCryptor.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Swinject.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwinjectStoryboard.framework", ); diff --git a/Adamant/Services/KeychainStore.swift b/Adamant/Services/KeychainStore.swift index 4334f4108..fbf61cb4c 100644 --- a/Adamant/Services/KeychainStore.swift +++ b/Adamant/Services/KeychainStore.swift @@ -8,16 +8,28 @@ import Foundation import KeychainAccess +import RNCryptor class KeychainStore: SecuredStore { let keychain = Keychain(service: "im.adamant") + private let 🍩 = "hello titty" // For AppStore builds, we use a real password func get(_ key: String) -> String? { - return keychain[key] + if let rawData = keychain[key], + let encryptedData = Data(base64Encoded: rawData), + let data = try? RNCryptor.decrypt(data: encryptedData, withPassword: 🍩), + let string = String(data: data, encoding: .utf8) { + return string + } + + return nil } func set(_ value: String, for key: String) { - keychain[key] = value + if let data = value.data(using: .utf8) { + let encryptedString = RNCryptor.encrypt(data: data, withPassword: 🍩).base64EncodedString() + try? keychain.set(encryptedString, key: key) + } } func remove(_ key: String) { diff --git a/Podfile b/Podfile index d5d73f978..be3ce2d3d 100644 --- a/Podfile +++ b/Podfile @@ -6,6 +6,7 @@ target 'Adamant' do pod 'Alamofire' # Network pod 'KeychainAccess' # Keychain + pod 'RNCryptor' # Cryptor # Swinject DI pod 'Swinject' diff --git a/Podfile.lock b/Podfile.lock index b3dc074b2..a42e597cc 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -14,6 +14,7 @@ PODS: - MessageKit (0.13.1) - MyLittlePinpad (0.2.2) - QRCodeReader.swift (8.1.1) + - RNCryptor (5.0.2) - Swinject (2.2.0) - SwinjectStoryboard (1.1.2): - Swinject (~> 2.1) @@ -28,6 +29,7 @@ DEPENDENCIES: - MessageKit - MyLittlePinpad - QRCodeReader.swift + - RNCryptor - Swinject - SwinjectStoryboard @@ -41,9 +43,10 @@ SPEC CHECKSUMS: MessageKit: fc74d71d9b05385138d47b3a4b7beef5c687daf1 MyLittlePinpad: 8b24927da4c1c8daa64ab1b9f142a8329f480745 QRCodeReader.swift: b164a681887de276d405ff02bce854d82cd6360b + RNCryptor: 59b9f92e9fa8a1af74c32dc6b1af5e30ff5e1b64 Swinject: 4ca48bca7de5f398229a26abe1ac902b9f3ee541 SwinjectStoryboard: 92e75763c3299cdf627bef98a5180dc894864336 -PODFILE CHECKSUM: 54b55788f642fe125eb02ede607957e5138bf2a1 +PODFILE CHECKSUM: f56801713dedd8f5b2d1ec95f822fbbce22dc294 COCOAPODS: 1.4.0