diff --git a/CHANGELOG.md b/CHANGELOG.md index 040173b5a..8171020db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,21 @@ Changes that are currently in development and have not been released yet. +## [0.13.8](https://github.com/cossacklabs/themis/releases/tag/0.13.8), April 30th 2021 + +**Hotfix for Apple platforms:** + +- Updated OpenSSL to the latest 1.1.1k for SMP and attached `themis.xcframework`. (iOS and macOS). +- New Swift and Objective-C example projects: SPM for iOS and macOS. + +_Code:_ + +- **Objective-C / Swift** + + - Updated OpenSSL to the latest 1.1.1k for SMP and attached `themis.xcframework`. It is `openssl-apple` version 1.1.11101. + - New Swift and Objective-C example projects: SPM for iOS and macOS. + - Updated SPM examples source code to remove deprecated calls. + ## [0.13.7](https://github.com/cossacklabs/themis/releases/tag/0.13.7), April 28th 2021 **Hotfix for Apple platforms:** @@ -18,7 +33,7 @@ _Code:_ - Added script to generate xcframework for iOS, iOS Simulator and macOS ([#789](https://github.com/cossacklabs/themis/pull/789)). - Added Package.swift file for SPM ([#789](https://github.com/cossacklabs/themis/pull/789)). -## [0.13.6](https://github.com/cossacklabs/themis/releases/tag/0.13.6), November 23th 2020 +## [0.13.6](https://github.com/cossacklabs/themis/releases/tag/0.13.6), November 23rd 2020 **Hotfix for Apple platforms:** diff --git a/Package.swift b/Package.swift index 2c203c120..e003b4dcf 100644 --- a/Package.swift +++ b/Package.swift @@ -15,11 +15,11 @@ let package = Package( targets: [ .binaryTarget(name: "themis", // update version in URL path - url: "https://github.com/cossacklabs/themis/releases/download/0.13.7/themis.xcframework.zip", + url: "https://github.com/cossacklabs/themis/releases/download/0.13.8/themis.xcframework.zip", // The scripts/create_xcframework.sh calculates the checksum when generating the XCF. // Alternatively, run from package directory: // swift package compute-checksum build/xcf_output/themis.xcframework.zip - checksum: "9e7b42fa1b9c49a1e28ede9eb5e17340ea6a4e0f57de806db874cb22568bef96"), + checksum: "afda7b2ab0ca86a73f55d309289283e648cd958b5cd9f16dc89d7157317b2165"), ] ) diff --git a/Themis.xcodeproj/project.pbxproj b/Themis.xcodeproj/project.pbxproj index 2730950a6..e65944ce8 100644 --- a/Themis.xcodeproj/project.pbxproj +++ b/Themis.xcodeproj/project.pbxproj @@ -1482,7 +1482,7 @@ CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 8; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1508,7 +1508,7 @@ "@executable_path/../Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 0.13.7; + MARKETING_VERSION = 0.13.8; PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.themis; PRODUCT_MODULE_NAME = themis; PRODUCT_NAME = themis; @@ -1524,7 +1524,7 @@ CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 8; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1550,7 +1550,7 @@ "@executable_path/../Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 0.13.7; + MARKETING_VERSION = 0.13.8; PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.themis; PRODUCT_MODULE_NAME = themis; PRODUCT_NAME = themis; @@ -1565,7 +1565,7 @@ buildSettings = { CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 8; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1593,7 +1593,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 0.13.7; + MARKETING_VERSION = 0.13.8; PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.themis; PRODUCT_MODULE_NAME = themis; PRODUCT_NAME = themis; @@ -1613,7 +1613,7 @@ buildSettings = { CODE_SIGN_IDENTITY = ""; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 8; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; @@ -1641,7 +1641,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 0.13.7; + MARKETING_VERSION = 0.13.8; PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.themis; PRODUCT_MODULE_NAME = themis; PRODUCT_NAME = themis; diff --git a/docs/examples/objc/iOS-SPM/ThemisTest.xcodeproj/project.pbxproj b/docs/examples/objc/iOS-SPM/ThemisTest.xcodeproj/project.pbxproj new file mode 100644 index 000000000..7f4c2b8e2 --- /dev/null +++ b/docs/examples/objc/iOS-SPM/ThemisTest.xcodeproj/project.pbxproj @@ -0,0 +1,400 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 52; + objects = { + +/* Begin PBXBuildFile section */ + 6D93CFF9263C294600ED53C4 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D93CFF8263C294600ED53C4 /* AppDelegate.m */; }; + 6D93CFFC263C294600ED53C4 /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D93CFFB263C294600ED53C4 /* SceneDelegate.m */; }; + 6D93CFFF263C294600ED53C4 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D93CFFE263C294600ED53C4 /* ViewController.m */; }; + 6D93D002263C294600ED53C4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6D93D000263C294600ED53C4 /* Main.storyboard */; }; + 6D93D004263C294900ED53C4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6D93D003263C294900ED53C4 /* Assets.xcassets */; }; + 6D93D007263C294900ED53C4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6D93D005263C294900ED53C4 /* LaunchScreen.storyboard */; }; + 6D93D00A263C294900ED53C4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D93D009263C294900ED53C4 /* main.m */; }; + 6DC890F2263C29EF003DA2AB /* themis in Frameworks */ = {isa = PBXBuildFile; productRef = 6DC890F1263C29EF003DA2AB /* themis */; }; + 6DC890FA263C2AF6003DA2AB /* server.priv in Resources */ = {isa = PBXBuildFile; fileRef = 6DC890F6263C2AF6003DA2AB /* server.priv */; }; + 6DC890FB263C2AF6003DA2AB /* client.pub in Resources */ = {isa = PBXBuildFile; fileRef = 6DC890F7263C2AF6003DA2AB /* client.pub */; }; + 6DC890FC263C2AF6003DA2AB /* server.pub in Resources */ = {isa = PBXBuildFile; fileRef = 6DC890F8263C2AF6003DA2AB /* server.pub */; }; + 6DC890FD263C2AF6003DA2AB /* client.priv in Resources */ = {isa = PBXBuildFile; fileRef = 6DC890F9263C2AF6003DA2AB /* client.priv */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 6D93CFF4263C294600ED53C4 /* ThemisTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ThemisTest.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 6D93CFF7263C294600ED53C4 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 6D93CFF8263C294600ED53C4 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 6D93CFFA263C294600ED53C4 /* SceneDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SceneDelegate.h; sourceTree = ""; }; + 6D93CFFB263C294600ED53C4 /* SceneDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SceneDelegate.m; sourceTree = ""; }; + 6D93CFFD263C294600ED53C4 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 6D93CFFE263C294600ED53C4 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 6D93D001263C294600ED53C4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 6D93D003263C294900ED53C4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 6D93D006263C294900ED53C4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 6D93D008263C294900ED53C4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 6D93D009263C294900ED53C4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 6DC890F6263C2AF6003DA2AB /* server.priv */ = {isa = PBXFileReference; lastKnownFileType = file; path = server.priv; sourceTree = ""; }; + 6DC890F7263C2AF6003DA2AB /* client.pub */ = {isa = PBXFileReference; lastKnownFileType = file; path = client.pub; sourceTree = ""; }; + 6DC890F8263C2AF6003DA2AB /* server.pub */ = {isa = PBXFileReference; lastKnownFileType = file; path = server.pub; sourceTree = ""; }; + 6DC890F9263C2AF6003DA2AB /* client.priv */ = {isa = PBXFileReference; lastKnownFileType = file; path = client.priv; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 6D93CFF1263C294600ED53C4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 6DC890F2263C29EF003DA2AB /* themis in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 6D93CFEB263C294600ED53C4 = { + isa = PBXGroup; + children = ( + 6D93CFF6263C294600ED53C4 /* ThemisTest */, + 6D93CFF5263C294600ED53C4 /* Products */, + ); + sourceTree = ""; + }; + 6D93CFF5263C294600ED53C4 /* Products */ = { + isa = PBXGroup; + children = ( + 6D93CFF4263C294600ED53C4 /* ThemisTest.app */, + ); + name = Products; + sourceTree = ""; + }; + 6D93CFF6263C294600ED53C4 /* ThemisTest */ = { + isa = PBXGroup; + children = ( + 6DC890F5263C2AF6003DA2AB /* Resources */, + 6D93CFF7263C294600ED53C4 /* AppDelegate.h */, + 6D93CFF8263C294600ED53C4 /* AppDelegate.m */, + 6D93CFFA263C294600ED53C4 /* SceneDelegate.h */, + 6D93CFFB263C294600ED53C4 /* SceneDelegate.m */, + 6D93CFFD263C294600ED53C4 /* ViewController.h */, + 6D93CFFE263C294600ED53C4 /* ViewController.m */, + 6D93D000263C294600ED53C4 /* Main.storyboard */, + 6D93D003263C294900ED53C4 /* Assets.xcassets */, + 6D93D005263C294900ED53C4 /* LaunchScreen.storyboard */, + 6D93D008263C294900ED53C4 /* Info.plist */, + 6D93D009263C294900ED53C4 /* main.m */, + ); + path = ThemisTest; + sourceTree = ""; + }; + 6DC890F5263C2AF6003DA2AB /* Resources */ = { + isa = PBXGroup; + children = ( + 6DC890F6263C2AF6003DA2AB /* server.priv */, + 6DC890F7263C2AF6003DA2AB /* client.pub */, + 6DC890F8263C2AF6003DA2AB /* server.pub */, + 6DC890F9263C2AF6003DA2AB /* client.priv */, + ); + path = Resources; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 6D93CFF3263C294600ED53C4 /* ThemisTest */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6D93D00D263C294900ED53C4 /* Build configuration list for PBXNativeTarget "ThemisTest" */; + buildPhases = ( + 6D93CFF0263C294600ED53C4 /* Sources */, + 6D93CFF1263C294600ED53C4 /* Frameworks */, + 6D93CFF2263C294600ED53C4 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ThemisTest; + packageProductDependencies = ( + 6DC890F1263C29EF003DA2AB /* themis */, + ); + productName = ThemisTest; + productReference = 6D93CFF4263C294600ED53C4 /* ThemisTest.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 6D93CFEC263C294600ED53C4 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1240; + TargetAttributes = { + 6D93CFF3263C294600ED53C4 = { + CreatedOnToolsVersion = 12.4; + }; + }; + }; + buildConfigurationList = 6D93CFEF263C294600ED53C4 /* Build configuration list for PBXProject "ThemisTest" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 6D93CFEB263C294600ED53C4; + packageReferences = ( + 6DC890F0263C29EF003DA2AB /* XCRemoteSwiftPackageReference "themis" */, + ); + productRefGroup = 6D93CFF5263C294600ED53C4 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 6D93CFF3263C294600ED53C4 /* ThemisTest */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 6D93CFF2263C294600ED53C4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6DC890FC263C2AF6003DA2AB /* server.pub in Resources */, + 6D93D007263C294900ED53C4 /* LaunchScreen.storyboard in Resources */, + 6DC890FA263C2AF6003DA2AB /* server.priv in Resources */, + 6D93D004263C294900ED53C4 /* Assets.xcassets in Resources */, + 6DC890FD263C2AF6003DA2AB /* client.priv in Resources */, + 6D93D002263C294600ED53C4 /* Main.storyboard in Resources */, + 6DC890FB263C2AF6003DA2AB /* client.pub in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 6D93CFF0263C294600ED53C4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6D93CFFF263C294600ED53C4 /* ViewController.m in Sources */, + 6D93CFF9263C294600ED53C4 /* AppDelegate.m in Sources */, + 6D93D00A263C294900ED53C4 /* main.m in Sources */, + 6D93CFFC263C294600ED53C4 /* SceneDelegate.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 6D93D000263C294600ED53C4 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 6D93D001263C294600ED53C4 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 6D93D005263C294900ED53C4 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 6D93D006263C294900ED53C4 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 6D93D00B263C294900ED53C4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.4; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 6D93D00C263C294900ED53C4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.4; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 6D93D00E263C294900ED53C4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = ThemisTest/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.themis.ThemisTest; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 6D93D00F263C294900ED53C4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = ThemisTest/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.themis.ThemisTest; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 6D93CFEF263C294600ED53C4 /* Build configuration list for PBXProject "ThemisTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6D93D00B263C294900ED53C4 /* Debug */, + 6D93D00C263C294900ED53C4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 6D93D00D263C294900ED53C4 /* Build configuration list for PBXNativeTarget "ThemisTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6D93D00E263C294900ED53C4 /* Debug */, + 6D93D00F263C294900ED53C4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 6DC890F0263C29EF003DA2AB /* XCRemoteSwiftPackageReference "themis" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/cossacklabs/themis"; + requirement = { + kind = exactVersion; + version = 0.13.7; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 6DC890F1263C29EF003DA2AB /* themis */ = { + isa = XCSwiftPackageProductDependency; + package = 6DC890F0263C29EF003DA2AB /* XCRemoteSwiftPackageReference "themis" */; + productName = themis; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 6D93CFEC263C294600ED53C4 /* Project object */; +} diff --git a/docs/examples/objc/iOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/docs/examples/objc/iOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/docs/examples/objc/iOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/docs/examples/objc/iOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/docs/examples/objc/iOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 000000000..3c87f2f34 --- /dev/null +++ b/docs/examples/objc/iOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "themis", + "repositoryURL": "https://github.com/cossacklabs/themis", + "state": { + "branch": null, + "revision": "68b485b8017098fce723e0839ecb9543d32463f6", + "version": "0.13.7" + } + } + ] + }, + "version": 1 +} diff --git a/docs/examples/objc/iOS-SPM/ThemisTest/AppDelegate.h b/docs/examples/objc/iOS-SPM/ThemisTest/AppDelegate.h new file mode 100644 index 000000000..843616efa --- /dev/null +++ b/docs/examples/objc/iOS-SPM/ThemisTest/AppDelegate.h @@ -0,0 +1,21 @@ +// Copyright (c) 2021 Cossack Labs Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import + +@interface AppDelegate : UIResponder + + +@end + diff --git a/docs/examples/objc/iOS-SPM/ThemisTest/AppDelegate.m b/docs/examples/objc/iOS-SPM/ThemisTest/AppDelegate.m new file mode 100644 index 000000000..f6c1c97c2 --- /dev/null +++ b/docs/examples/objc/iOS-SPM/ThemisTest/AppDelegate.m @@ -0,0 +1,361 @@ +// Copyright (c) 2021 Cossack Labs Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import "AppDelegate.h" + +#import + +@interface AppDelegate () + +@end + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // + // We don't do UI. Please look into debug console to see the results. + // + + [self runExampleGeneratingKeys]; + [self runExampleReadingKeysFromFile]; + + [self runExampleSecureMessageEncryptionDecryption]; + [self runExampleSecureMessageSignVerify]; + + [self runExampleSecureCellSealMode]; + [self runExampleSecureCellTokenProtectMode]; + [self runExampleSecureCellImprint]; + + [self runExampleSecureComparator]; + + return YES; +} + +#pragma mark - Secure Cell + +- (NSData *)generateMasterKey { + NSString *masterKeyString = @"UkVDMgAAAC13PCVZAKOczZXUpvkhsC+xvwWnv3CLmlG0Wzy8ZBMnT+2yx/dg"; + NSData *masterKeyData = [[NSData alloc] initWithBase64EncodedString:masterKeyString + options:NSDataBase64DecodingIgnoreUnknownCharacters]; + return masterKeyData; +} + +- (void)runExampleSecureCellSealMode { + NSLog(@"----------------- %s -----------------", sel_getName(_cmd)); + + NSData *masterKeyData = [self generateMasterKey]; + TSCellSeal *cellSeal = [[TSCellSeal alloc] initWithKey:masterKeyData]; + + if (!cellSeal) { + NSLog(@"%s Error occurred while initializing object cellSeal", sel_getName(_cmd)); + return; + } + + NSString *message = @"All your base are belong to us!"; + NSString *context = @"For great justice"; + NSError *themisError; + + + // context is optional parameter and may be ignored + NSData *encryptedMessage = [cellSeal encrypt:[message dataUsingEncoding:NSUTF8StringEncoding] + context:[context dataUsingEncoding:NSUTF8StringEncoding] + error:&themisError]; + + if (themisError) { + NSLog(@"%s Error occurred while enrypting %@", sel_getName(_cmd), themisError); + return; + } + NSLog(@"encryptedMessage = %@", encryptedMessage); + + NSData *decryptedMessage = [cellSeal decrypt:encryptedMessage + context:[context dataUsingEncoding:NSUTF8StringEncoding] + error:&themisError]; + if (themisError) { + NSLog(@"%s Error occurred while decrypting %@", sel_getName(_cmd), themisError); + return; + } + NSString *resultString = [[NSString alloc] initWithData:decryptedMessage + encoding:NSUTF8StringEncoding]; + NSLog(@"%s resultString = %@", sel_getName(_cmd), resultString); +} + +- (void)runExampleSecureCellTokenProtectMode { + NSLog(@"----------------- %s -----------------", sel_getName(_cmd)); + + NSData *masterKeyData = [self generateMasterKey]; + TSCellToken *cellToken = [[TSCellToken alloc] initWithKey:masterKeyData]; + + if (!cellToken) { + NSLog(@"%s Error occurred while initializing object cellToken", sel_getName(_cmd)); + return; + } + + NSString *message = @"Roses are grey. Violets are grey."; + NSString *context = @"I'm a dog"; + NSError *themisError; + + // context is optional parameter and may be ignored + TSCellTokenEncryptedResult *encryptedMessage = [cellToken encrypt:[message dataUsingEncoding:NSUTF8StringEncoding] + context:[context dataUsingEncoding:NSUTF8StringEncoding] + error:&themisError]; + if (themisError) { + NSLog(@"%s Error occurred while enrypting %@", sel_getName(_cmd), themisError); + return; + } + NSLog(@"%s\ncipher = %@:\ntoken = %@", sel_getName(_cmd), encryptedMessage.encrypted, encryptedMessage.token); + + NSData *decryptedMessage = [cellToken decrypt:encryptedMessage.encrypted + token: encryptedMessage.token + context:[context dataUsingEncoding:NSUTF8StringEncoding] + error:&themisError]; + if (themisError) { + NSLog(@"%s Error occurred while decrypting %@", sel_getName(_cmd), themisError); + return; + } + NSString *resultString = [[NSString alloc] initWithData:decryptedMessage + encoding:NSUTF8StringEncoding]; + NSLog(@"%s resultString = %@", sel_getName(_cmd), resultString); +} + +- (void)runExampleSecureCellImprint { + NSLog(@"----------------- %s -----------------", sel_getName(_cmd)); + + NSData *masterKeyData = [self generateMasterKey]; + TSCellContextImprint *contextImprint = [[TSCellContextImprint alloc] initWithKey:masterKeyData]; + + if (!contextImprint) { + NSLog(@"%s Error occurred while initializing object contextImprint", sel_getName(_cmd)); + return; + } + + NSString *message = @"Roses are red. My name is Dave. This poem have no sense"; + NSString *context = @"Microwave"; + NSError *themisError; + + // context is not optional parameter here + NSData *encryptedMessage = [contextImprint encrypt:[message dataUsingEncoding:NSUTF8StringEncoding] + context:[context dataUsingEncoding:NSUTF8StringEncoding] + error:&themisError]; + if (themisError) { + NSLog(@"%s Error occurred while enrypting %@", sel_getName(_cmd), themisError); + return; + } + NSLog(@"%@", encryptedMessage); + + // context is not optional parameter here + NSData *decryptedMessage = [contextImprint decrypt:encryptedMessage + context:[context dataUsingEncoding:NSUTF8StringEncoding] + error:&themisError]; + if (themisError) { + NSLog(@"%s Error occurred while decrypting %@", sel_getName(_cmd), themisError); + return; + } + NSString *resultString = [[NSString alloc] initWithData:decryptedMessage + encoding:NSUTF8StringEncoding]; + NSLog(@"%s resultString = %@", sel_getName(_cmd), resultString); +} + +#pragma mark - Key Generation and Loading + +- (void)runExampleGeneratingKeys { + NSLog(@"----------------- %s -----------------", sel_getName(_cmd)); + + NSData *privateKey; + NSData *publicKey; + + // Generating RSA keys + TSKeyGen *keygenRSA = [[TSKeyGen alloc] initWithAlgorithm:TSKeyGenAsymmetricAlgorithmRSA]; + + if (!keygenRSA) { + NSLog(@"%s Error occurred while initializing object keygenRSA", sel_getName(_cmd)); + return; + } + + privateKey = keygenRSA.privateKey; + NSLog(@"RSA private key: %@", privateKey); + + publicKey = keygenRSA.publicKey; + NSLog(@"RSA public key:%@", publicKey); + + // Generating EC keys + + TSKeyGen *keygenEC = [[TSKeyGen alloc] initWithAlgorithm:TSKeyGenAsymmetricAlgorithmEC]; + + if (!keygenEC) { + NSLog(@"%s Error occurred while initializing object keygenEC", sel_getName(_cmd)); + return; + } + + privateKey = keygenEC.privateKey; + NSLog(@"EC private key: %@", privateKey); + + publicKey = keygenEC.publicKey; + NSLog(@"EC public key:%@", publicKey); +} + +// Sometimes you will need to read keys from files +- (void)runExampleReadingKeysFromFile { + NSLog(@"----------------- %s -----------------", sel_getName(_cmd)); + + NSData *serverPrivateKeyFromFile = [[NSFileManager defaultManager] contentsAtPath:[[NSBundle mainBundle] pathForResource:@"server" + ofType:@"priv"]]; + NSData *serverPublicKeyFromFile = [[NSFileManager defaultManager] contentsAtPath:[[NSBundle mainBundle] pathForResource:@"server" + ofType:@"pub"]]; + NSData *clientPrivateKeyOldFromFile = [[NSFileManager defaultManager] contentsAtPath:[[NSBundle mainBundle] pathForResource:@"client" + ofType:@"priv"]]; + NSData *clientPublicKeyOldFromFile = [[NSFileManager defaultManager] contentsAtPath:[[NSBundle mainBundle] pathForResource:@"client" + ofType:@"pub"]]; + NSLog(@"%s", sel_getName(_cmd)); + NSLog(@"serverPrivateKeyFromFile %@", serverPrivateKeyFromFile); + NSLog(@"serverPublicKeyFromFile %@", serverPublicKeyFromFile); + NSLog(@"clientPrivateKeyOldFromFile %@", clientPrivateKeyOldFromFile); + NSLog(@"clientPublicKeyOldFromFile %@", clientPublicKeyOldFromFile); +} + +#pragma mark - Secure Message + +- (void)runExampleSecureMessageEncryptionDecryption { + NSLog(@"----------------- %s -----------------", sel_getName(_cmd)); + + // ---------- encryption + + // base64 encoded keys: + // client private key + // server public key + NSString *serverPublicKeyString = @"VUVDMgAAAC2ELbj5Aue5xjiJWW3P2KNrBX+HkaeJAb+Z4MrK0cWZlAfpBUql"; + NSString *clientPrivateKeyString = @"UkVDMgAAAC13PCVZAKOczZXUpvkhsC+xvwWnv3CLmlG0Wzy8ZBMnT+2yx/dg"; + + NSData *serverPublicKey = [[NSData alloc] initWithBase64EncodedString:serverPublicKeyString + options:NSDataBase64DecodingIgnoreUnknownCharacters]; + NSData *clientPrivateKey = [[NSData alloc] initWithBase64EncodedString:clientPrivateKeyString + options:NSDataBase64DecodingIgnoreUnknownCharacters]; + + // initialize encrypter + TSMessage *encrypter = [[TSMessage alloc] initInEncryptModeWithPrivateKey:clientPrivateKey peerPublicKey:serverPublicKey]; + + NSString *message = @"- Knock, knock.\n- Who’s there?\n*very long pause...*\n- Java."; + + NSError *themisError; + NSData *encryptedMessage = [encrypter wrapData:[message dataUsingEncoding:NSUTF8StringEncoding] + error:&themisError]; + if (themisError) { + NSLog(@"%s Error occurred while encrypting %@", sel_getName(_cmd), themisError); + return; + } + NSLog(@"%@", encryptedMessage); + + // -------- decryption + + // base64 encoded keys: + // server private key + // client public key + NSString *serverPrivateKeyString = @"UkVDMgAAAC1FsVa6AMGljYqtNWQ+7r4RjXTabLZxZ/14EXmi6ec2e1vrCmyR"; + NSString *clientPublicKeyString = @"VUVDMgAAAC1SsL32Axjosnf2XXUwm/4WxPlZauQ+v+0eOOjpwMN/EO+Huh5d"; + + NSData *serverPrivateKey = [[NSData alloc] initWithBase64EncodedString:serverPrivateKeyString + options:NSDataBase64DecodingIgnoreUnknownCharacters]; + NSData *clientPublicKey = [[NSData alloc] initWithBase64EncodedString:clientPublicKeyString + options:NSDataBase64DecodingIgnoreUnknownCharacters]; + + // initialize decrypter + TSMessage *decrypter = [[TSMessage alloc] initInEncryptModeWithPrivateKey:serverPrivateKey peerPublicKey:clientPublicKey]; + + NSData *decryptedMessage = [decrypter unwrapData:encryptedMessage error:&themisError]; + if (themisError) { + NSLog(@"%s Error occurred while decrypting %@", sel_getName(_cmd), themisError); + return; + } + + NSString *resultString = [[NSString alloc] initWithData:decryptedMessage encoding:NSUTF8StringEncoding]; + NSLog(@"%@", resultString); +} + +- (void)runExampleSecureMessageSignVerify { + NSLog(@"----------------- %s -----------------", sel_getName(_cmd)); + + // base64 encoded keys: + // private key + // public key + + NSString *publicKeyString = @"VUVDMgAAAC2ELbj5Aue5xjiJWW3P2KNrBX+HkaeJAb+Z4MrK0cWZlAfpBUql"; + NSString *privateKeyString = @"UkVDMgAAAC1FsVa6AMGljYqtNWQ+7r4RjXTabLZxZ/14EXmi6ec2e1vrCmyR"; + + NSData *publicKey = [[NSData alloc] initWithBase64EncodedString:publicKeyString + options:NSDataBase64DecodingIgnoreUnknownCharacters]; + NSData *privateKey = [[NSData alloc] initWithBase64EncodedString:privateKeyString + options:NSDataBase64DecodingIgnoreUnknownCharacters]; + + + // ---------- signing + + // initialize signer, use private key + TSMessage *signer = [[TSMessage alloc] initInSignVerifyModeWithPrivateKey:privateKey peerPublicKey:nil]; + + NSString *message = @"- Knock, knock.\n- Who’s there?\n*very long pause...*\n- Java."; + + NSError *themisError; + NSData *signedMessage = [signer wrapData:[message dataUsingEncoding:NSUTF8StringEncoding] + error:&themisError]; + if (themisError) { + NSLog(@"%s Error occurred while signing %@", sel_getName(_cmd), themisError); + return; + } + + // -------- verification + + // initialize verifier, use public key + TSMessage *verifier = [[TSMessage alloc] initInSignVerifyModeWithPrivateKey:nil peerPublicKey:publicKey]; + + NSData *verifiedMessage = [verifier unwrapData:signedMessage error:&themisError]; + if (themisError) { + NSLog(@"%s Error occurred while verifying %@", sel_getName(_cmd), themisError); + return; + } + + NSString *resultString = [[NSString alloc] initWithData:verifiedMessage encoding:NSUTF8StringEncoding]; + NSLog(@"%@", resultString); +} + +#pragma mark - Secure Comparator + +- (void)runExampleSecureComparator { + NSLog(@"----------------- %s -----------------", sel_getName(_cmd)); + + NSString *sharedSecret = @"shared secret"; + NSData *sharedSecretData = [sharedSecret dataUsingEncoding:NSUTF8StringEncoding]; + + TSComparator *client = [[TSComparator alloc] initWithMessageToCompare:sharedSecretData]; + TSComparator *server = [[TSComparator alloc] initWithMessageToCompare:sharedSecretData]; + NSError *error = nil; + + // send this message to server + NSData *data = [client beginCompare:&error]; + while ([client status] == TSComparatorNotReady || [server status] == TSComparatorNotReady) { + // receive from server + data = [server proceedCompare:data error:&error]; + + // proceed and send again + data = [client proceedCompare:data error:&error]; + } + + if ([client status] == TSComparatorMatch) { + // secrets match + NSLog(@"SecureComparator secrets match"); + } else { + // secrets don't match + NSLog(@"SecureComparator secrets do not match"); + } +} + +@end diff --git a/docs/examples/objc/iOS-SPM/ThemisTest/Assets.xcassets/AccentColor.colorset/Contents.json b/docs/examples/objc/iOS-SPM/ThemisTest/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 000000000..eb8789700 --- /dev/null +++ b/docs/examples/objc/iOS-SPM/ThemisTest/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/docs/examples/objc/iOS-SPM/ThemisTest/Assets.xcassets/AppIcon.appiconset/Contents.json b/docs/examples/objc/iOS-SPM/ThemisTest/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..9221b9bb1 --- /dev/null +++ b/docs/examples/objc/iOS-SPM/ThemisTest/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/docs/examples/objc/iOS-SPM/ThemisTest/Assets.xcassets/Contents.json b/docs/examples/objc/iOS-SPM/ThemisTest/Assets.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/docs/examples/objc/iOS-SPM/ThemisTest/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/docs/examples/objc/iOS-SPM/ThemisTest/Base.lproj/LaunchScreen.storyboard b/docs/examples/objc/iOS-SPM/ThemisTest/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 000000000..865e9329f --- /dev/null +++ b/docs/examples/objc/iOS-SPM/ThemisTest/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/examples/objc/iOS-SPM/ThemisTest/Base.lproj/Main.storyboard b/docs/examples/objc/iOS-SPM/ThemisTest/Base.lproj/Main.storyboard new file mode 100644 index 000000000..808a21ce7 --- /dev/null +++ b/docs/examples/objc/iOS-SPM/ThemisTest/Base.lproj/Main.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/examples/objc/iOS-SPM/ThemisTest/Info.plist b/docs/examples/objc/iOS-SPM/ThemisTest/Info.plist new file mode 100644 index 000000000..72bf2c4f5 --- /dev/null +++ b/docs/examples/objc/iOS-SPM/ThemisTest/Info.plist @@ -0,0 +1,66 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + SceneDelegate + UISceneStoryboardFile + Main + + + + + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/docs/examples/objc/iOS-SPM/ThemisTest/Resources/client.priv b/docs/examples/objc/iOS-SPM/ThemisTest/Resources/client.priv new file mode 100644 index 000000000..eec0a47f8 Binary files /dev/null and b/docs/examples/objc/iOS-SPM/ThemisTest/Resources/client.priv differ diff --git a/docs/examples/objc/iOS-SPM/ThemisTest/Resources/client.pub b/docs/examples/objc/iOS-SPM/ThemisTest/Resources/client.pub new file mode 100644 index 000000000..39668bd93 Binary files /dev/null and b/docs/examples/objc/iOS-SPM/ThemisTest/Resources/client.pub differ diff --git a/docs/examples/objc/iOS-SPM/ThemisTest/Resources/server.priv b/docs/examples/objc/iOS-SPM/ThemisTest/Resources/server.priv new file mode 100644 index 000000000..e8c0755d2 Binary files /dev/null and b/docs/examples/objc/iOS-SPM/ThemisTest/Resources/server.priv differ diff --git a/docs/examples/objc/iOS-SPM/ThemisTest/Resources/server.pub b/docs/examples/objc/iOS-SPM/ThemisTest/Resources/server.pub new file mode 100644 index 000000000..e50e2c042 Binary files /dev/null and b/docs/examples/objc/iOS-SPM/ThemisTest/Resources/server.pub differ diff --git a/docs/examples/objc/iOS-SPM/ThemisTest/SceneDelegate.h b/docs/examples/objc/iOS-SPM/ThemisTest/SceneDelegate.h new file mode 100644 index 000000000..a708ff350 --- /dev/null +++ b/docs/examples/objc/iOS-SPM/ThemisTest/SceneDelegate.h @@ -0,0 +1,22 @@ +// Copyright (c) 2021 Cossack Labs Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import + +@interface SceneDelegate : UIResponder + +@property (strong, nonatomic) UIWindow * window; + +@end + diff --git a/docs/examples/objc/iOS-SPM/ThemisTest/SceneDelegate.m b/docs/examples/objc/iOS-SPM/ThemisTest/SceneDelegate.m new file mode 100644 index 000000000..8354c2892 --- /dev/null +++ b/docs/examples/objc/iOS-SPM/ThemisTest/SceneDelegate.m @@ -0,0 +1,64 @@ +// Copyright (c) 2021 Cossack Labs Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import "SceneDelegate.h" + +@interface SceneDelegate () + +@end + +@implementation SceneDelegate + + +- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). +} + + +- (void)sceneDidDisconnect:(UIScene *)scene { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). +} + + +- (void)sceneDidBecomeActive:(UIScene *)scene { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. +} + + +- (void)sceneWillResignActive:(UIScene *)scene { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). +} + + +- (void)sceneWillEnterForeground:(UIScene *)scene { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. +} + + +- (void)sceneDidEnterBackground:(UIScene *)scene { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. +} + + +@end diff --git a/docs/examples/objc/iOS-SPM/ThemisTest/ViewController.h b/docs/examples/objc/iOS-SPM/ThemisTest/ViewController.h new file mode 100644 index 000000000..3b75b084c --- /dev/null +++ b/docs/examples/objc/iOS-SPM/ThemisTest/ViewController.h @@ -0,0 +1,21 @@ +// Copyright (c) 2021 Cossack Labs Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import + +@interface ViewController : UIViewController + + +@end + diff --git a/docs/examples/objc/iOS-SPM/ThemisTest/ViewController.m b/docs/examples/objc/iOS-SPM/ThemisTest/ViewController.m new file mode 100644 index 000000000..742827969 --- /dev/null +++ b/docs/examples/objc/iOS-SPM/ThemisTest/ViewController.m @@ -0,0 +1,29 @@ +// Copyright (c) 2021 Cossack Labs Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import "ViewController.h" + +@interface ViewController () + +@end + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. +} + + +@end diff --git a/docs/examples/objc/iOS-SPM/ThemisTest/main.m b/docs/examples/objc/iOS-SPM/ThemisTest/main.m new file mode 100644 index 000000000..1f9650e7c --- /dev/null +++ b/docs/examples/objc/iOS-SPM/ThemisTest/main.m @@ -0,0 +1,25 @@ +// Copyright (c) 2021 Cossack Labs Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + NSString * appDelegateClassName; + @autoreleasepool { + // Setup code that might create autoreleased objects goes here. + appDelegateClassName = NSStringFromClass([AppDelegate class]); + } + return UIApplicationMain(argc, argv, nil, appDelegateClassName); +} diff --git a/docs/examples/objc/macOS-SPM/ThemisTest.xcodeproj/project.pbxproj b/docs/examples/objc/macOS-SPM/ThemisTest.xcodeproj/project.pbxproj new file mode 100644 index 000000000..50536812a --- /dev/null +++ b/docs/examples/objc/macOS-SPM/ThemisTest.xcodeproj/project.pbxproj @@ -0,0 +1,383 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 52; + objects = { + +/* Begin PBXBuildFile section */ + 6D445235263C2B4C00871215 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D445234263C2B4C00871215 /* AppDelegate.m */; }; + 6D445238263C2B4C00871215 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D445237263C2B4C00871215 /* ViewController.m */; }; + 6D44523A263C2B4E00871215 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6D445239263C2B4E00871215 /* Assets.xcassets */; }; + 6D44523D263C2B4E00871215 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6D44523B263C2B4E00871215 /* Main.storyboard */; }; + 6D445240263C2B4E00871215 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D44523F263C2B4E00871215 /* main.m */; }; + 6D44524A263C2BA500871215 /* themis in Frameworks */ = {isa = PBXBuildFile; productRef = 6D445249263C2BA500871215 /* themis */; }; + 6D445251263C2BAE00871215 /* server.priv in Resources */ = {isa = PBXBuildFile; fileRef = 6D44524D263C2BAE00871215 /* server.priv */; }; + 6D445252263C2BAE00871215 /* client.pub in Resources */ = {isa = PBXBuildFile; fileRef = 6D44524E263C2BAE00871215 /* client.pub */; }; + 6D445253263C2BAE00871215 /* server.pub in Resources */ = {isa = PBXBuildFile; fileRef = 6D44524F263C2BAE00871215 /* server.pub */; }; + 6D445254263C2BAE00871215 /* client.priv in Resources */ = {isa = PBXBuildFile; fileRef = 6D445250263C2BAE00871215 /* client.priv */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 6D445230263C2B4C00871215 /* ThemisTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ThemisTest.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 6D445233263C2B4C00871215 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 6D445234263C2B4C00871215 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 6D445236263C2B4C00871215 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 6D445237263C2B4C00871215 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 6D445239263C2B4E00871215 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 6D44523C263C2B4E00871215 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 6D44523E263C2B4E00871215 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 6D44523F263C2B4E00871215 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 6D445241263C2B4E00871215 /* ThemisTest.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ThemisTest.entitlements; sourceTree = ""; }; + 6D44524D263C2BAE00871215 /* server.priv */ = {isa = PBXFileReference; lastKnownFileType = file; path = server.priv; sourceTree = ""; }; + 6D44524E263C2BAE00871215 /* client.pub */ = {isa = PBXFileReference; lastKnownFileType = file; path = client.pub; sourceTree = ""; }; + 6D44524F263C2BAE00871215 /* server.pub */ = {isa = PBXFileReference; lastKnownFileType = file; path = server.pub; sourceTree = ""; }; + 6D445250263C2BAE00871215 /* client.priv */ = {isa = PBXFileReference; lastKnownFileType = file; path = client.priv; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 6D44522D263C2B4C00871215 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 6D44524A263C2BA500871215 /* themis in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 6D445227263C2B4C00871215 = { + isa = PBXGroup; + children = ( + 6D445232263C2B4C00871215 /* ThemisTest */, + 6D445231263C2B4C00871215 /* Products */, + ); + sourceTree = ""; + }; + 6D445231263C2B4C00871215 /* Products */ = { + isa = PBXGroup; + children = ( + 6D445230263C2B4C00871215 /* ThemisTest.app */, + ); + name = Products; + sourceTree = ""; + }; + 6D445232263C2B4C00871215 /* ThemisTest */ = { + isa = PBXGroup; + children = ( + 6D44524C263C2BAE00871215 /* Resources */, + 6D445233263C2B4C00871215 /* AppDelegate.h */, + 6D445234263C2B4C00871215 /* AppDelegate.m */, + 6D445236263C2B4C00871215 /* ViewController.h */, + 6D445237263C2B4C00871215 /* ViewController.m */, + 6D445239263C2B4E00871215 /* Assets.xcassets */, + 6D44523B263C2B4E00871215 /* Main.storyboard */, + 6D44523E263C2B4E00871215 /* Info.plist */, + 6D44523F263C2B4E00871215 /* main.m */, + 6D445241263C2B4E00871215 /* ThemisTest.entitlements */, + ); + path = ThemisTest; + sourceTree = ""; + }; + 6D44524C263C2BAE00871215 /* Resources */ = { + isa = PBXGroup; + children = ( + 6D44524D263C2BAE00871215 /* server.priv */, + 6D44524E263C2BAE00871215 /* client.pub */, + 6D44524F263C2BAE00871215 /* server.pub */, + 6D445250263C2BAE00871215 /* client.priv */, + ); + path = Resources; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 6D44522F263C2B4C00871215 /* ThemisTest */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6D445244263C2B4E00871215 /* Build configuration list for PBXNativeTarget "ThemisTest" */; + buildPhases = ( + 6D44522C263C2B4C00871215 /* Sources */, + 6D44522D263C2B4C00871215 /* Frameworks */, + 6D44522E263C2B4C00871215 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ThemisTest; + packageProductDependencies = ( + 6D445249263C2BA500871215 /* themis */, + ); + productName = ThemisTest; + productReference = 6D445230263C2B4C00871215 /* ThemisTest.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 6D445228263C2B4C00871215 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1240; + TargetAttributes = { + 6D44522F263C2B4C00871215 = { + CreatedOnToolsVersion = 12.4; + }; + }; + }; + buildConfigurationList = 6D44522B263C2B4C00871215 /* Build configuration list for PBXProject "ThemisTest" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 6D445227263C2B4C00871215; + packageReferences = ( + 6D445248263C2BA500871215 /* XCRemoteSwiftPackageReference "themis" */, + ); + productRefGroup = 6D445231263C2B4C00871215 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 6D44522F263C2B4C00871215 /* ThemisTest */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 6D44522E263C2B4C00871215 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6D44523A263C2B4E00871215 /* Assets.xcassets in Resources */, + 6D445251263C2BAE00871215 /* server.priv in Resources */, + 6D445252263C2BAE00871215 /* client.pub in Resources */, + 6D445253263C2BAE00871215 /* server.pub in Resources */, + 6D44523D263C2B4E00871215 /* Main.storyboard in Resources */, + 6D445254263C2BAE00871215 /* client.priv in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 6D44522C263C2B4C00871215 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6D445238263C2B4C00871215 /* ViewController.m in Sources */, + 6D445240263C2B4E00871215 /* main.m in Sources */, + 6D445235263C2B4C00871215 /* AppDelegate.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 6D44523B263C2B4E00871215 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 6D44523C263C2B4E00871215 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 6D445242263C2B4E00871215 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 6D445243263C2B4E00871215 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + }; + name = Release; + }; + 6D445245263C2B4E00871215 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = ThemisTest/ThemisTest.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = ThemisTest/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.themis.ThemisTest; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 6D445246263C2B4E00871215 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = ThemisTest/ThemisTest.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = ThemisTest/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.themis.ThemisTest; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 6D44522B263C2B4C00871215 /* Build configuration list for PBXProject "ThemisTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6D445242263C2B4E00871215 /* Debug */, + 6D445243263C2B4E00871215 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 6D445244263C2B4E00871215 /* Build configuration list for PBXNativeTarget "ThemisTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6D445245263C2B4E00871215 /* Debug */, + 6D445246263C2B4E00871215 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 6D445248263C2BA500871215 /* XCRemoteSwiftPackageReference "themis" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/cossacklabs/themis"; + requirement = { + kind = exactVersion; + version = 0.13.7; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 6D445249263C2BA500871215 /* themis */ = { + isa = XCSwiftPackageProductDependency; + package = 6D445248263C2BA500871215 /* XCRemoteSwiftPackageReference "themis" */; + productName = themis; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 6D445228263C2B4C00871215 /* Project object */; +} diff --git a/docs/examples/objc/macOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/docs/examples/objc/macOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/docs/examples/objc/macOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/docs/examples/objc/macOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/docs/examples/objc/macOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 000000000..3c87f2f34 --- /dev/null +++ b/docs/examples/objc/macOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "themis", + "repositoryURL": "https://github.com/cossacklabs/themis", + "state": { + "branch": null, + "revision": "68b485b8017098fce723e0839ecb9543d32463f6", + "version": "0.13.7" + } + } + ] + }, + "version": 1 +} diff --git a/docs/examples/objc/macOS-SPM/ThemisTest/AppDelegate.h b/docs/examples/objc/macOS-SPM/ThemisTest/AppDelegate.h new file mode 100644 index 000000000..3e2700370 --- /dev/null +++ b/docs/examples/objc/macOS-SPM/ThemisTest/AppDelegate.h @@ -0,0 +1,21 @@ +// Copyright (c) 2021 Cossack Labs Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import + +@interface AppDelegate : NSObject + + +@end + diff --git a/docs/examples/objc/macOS-SPM/ThemisTest/AppDelegate.m b/docs/examples/objc/macOS-SPM/ThemisTest/AppDelegate.m new file mode 100644 index 000000000..1ac7e8859 --- /dev/null +++ b/docs/examples/objc/macOS-SPM/ThemisTest/AppDelegate.m @@ -0,0 +1,355 @@ +// Copyright (c) 2021 Cossack Labs Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import "AppDelegate.h" + +#import + +@implementation AppDelegate + +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { + // + // We don't do UI. Please look into debug console to see the results. + // + + [self runExampleGeneratingKeys]; + [self runExampleReadingKeysFromFile]; + + [self runExampleSecureMessageEncryptionDecryption]; + [self runExampleSecureMessageSignVerify]; + + [self runExampleSecureCellSealMode]; + [self runExampleSecureCellTokenProtectMode]; + [self runExampleSecureCellImprint]; + + [self runExampleSecureComparator]; +} + +#pragma mark - Secure Cell + +- (NSData *)generateMasterKey { + NSString *masterKeyString = @"UkVDMgAAAC13PCVZAKOczZXUpvkhsC+xvwWnv3CLmlG0Wzy8ZBMnT+2yx/dg"; + NSData *masterKeyData = [[NSData alloc] initWithBase64EncodedString:masterKeyString + options:NSDataBase64DecodingIgnoreUnknownCharacters]; + return masterKeyData; +} + +- (void)runExampleSecureCellSealMode { + NSLog(@"----------------- %s -----------------", sel_getName(_cmd)); + + NSData *masterKeyData = [self generateMasterKey]; + TSCellSeal *cellSeal = [[TSCellSeal alloc] initWithKey:masterKeyData]; + + if (!cellSeal) { + NSLog(@"%s Error occurred while initializing object cellSeal", sel_getName(_cmd)); + return; + } + + NSString *message = @"All your base are belong to us!"; + NSString *context = @"For great justice"; + NSError *themisError; + + + // context is optional parameter and may be ignored + NSData *encryptedMessage = [cellSeal encrypt:[message dataUsingEncoding:NSUTF8StringEncoding] + context:[context dataUsingEncoding:NSUTF8StringEncoding] + error:&themisError]; + + if (themisError) { + NSLog(@"%s Error occurred while enrypting %@", sel_getName(_cmd), themisError); + return; + } + NSLog(@"encryptedMessage = %@", encryptedMessage); + + NSData *decryptedMessage = [cellSeal decrypt:encryptedMessage + context:[context dataUsingEncoding:NSUTF8StringEncoding] + error:&themisError]; + if (themisError) { + NSLog(@"%s Error occurred while decrypting %@", sel_getName(_cmd), themisError); + return; + } + NSString *resultString = [[NSString alloc] initWithData:decryptedMessage + encoding:NSUTF8StringEncoding]; + NSLog(@"%s resultString = %@", sel_getName(_cmd), resultString); +} + +- (void)runExampleSecureCellTokenProtectMode { + NSLog(@"----------------- %s -----------------", sel_getName(_cmd)); + + NSData *masterKeyData = [self generateMasterKey]; + TSCellToken *cellToken = [[TSCellToken alloc] initWithKey:masterKeyData]; + + if (!cellToken) { + NSLog(@"%s Error occurred while initializing object cellToken", sel_getName(_cmd)); + return; + } + + NSString *message = @"Roses are grey. Violets are grey."; + NSString *context = @"I'm a dog"; + NSError *themisError; + + // context is optional parameter and may be ignored + TSCellTokenEncryptedResult *encryptedMessage = [cellToken encrypt:[message dataUsingEncoding:NSUTF8StringEncoding] + context:[context dataUsingEncoding:NSUTF8StringEncoding] + error:&themisError]; + if (themisError) { + NSLog(@"%s Error occurred while enrypting %@", sel_getName(_cmd), themisError); + return; + } + NSLog(@"%s\ncipher = %@:\ntoken = %@", sel_getName(_cmd), encryptedMessage.encrypted, encryptedMessage.token); + + NSData *decryptedMessage = [cellToken decrypt:encryptedMessage.encrypted + token:encryptedMessage.token + context:[context dataUsingEncoding:NSUTF8StringEncoding] + error:&themisError]; + if (themisError) { + NSLog(@"%s Error occurred while decrypting %@", sel_getName(_cmd), themisError); + return; + } + NSString *resultString = [[NSString alloc] initWithData:decryptedMessage + encoding:NSUTF8StringEncoding]; + NSLog(@"%s resultString = %@", sel_getName(_cmd), resultString); +} + +- (void)runExampleSecureCellImprint { + NSLog(@"----------------- %s -----------------", sel_getName(_cmd)); + + NSData *masterKeyData = [self generateMasterKey]; + TSCellContextImprint *contextImprint = [[TSCellContextImprint alloc] initWithKey:masterKeyData]; + + if (!contextImprint) { + NSLog(@"%s Error occurred while initializing object contextImprint", sel_getName(_cmd)); + return; + } + + NSString *message = @"Roses are red. My name is Dave. This poem have no sense"; + NSString *context = @"Microwave"; + NSError *themisError; + + // context is not optional parameter here + NSData *encryptedMessage = [contextImprint encrypt:[message dataUsingEncoding:NSUTF8StringEncoding] + context:[context dataUsingEncoding:NSUTF8StringEncoding] + error:&themisError]; + if (themisError) { + NSLog(@"%s Error occurred while enrypting %@", sel_getName(_cmd), themisError); + return; + } + NSLog(@"%@", encryptedMessage); + + // context is not optional parameter here + NSData *decryptedMessage = [contextImprint decrypt:encryptedMessage + context:[context dataUsingEncoding:NSUTF8StringEncoding] + error:&themisError]; + if (themisError) { + NSLog(@"%s Error occurred while decrypting %@", sel_getName(_cmd), themisError); + return; + } + NSString *resultString = [[NSString alloc] initWithData:decryptedMessage + encoding:NSUTF8StringEncoding]; + NSLog(@"%s resultString = %@", sel_getName(_cmd), resultString); +} + +#pragma mark - Key Generation and Loading + +- (void)runExampleGeneratingKeys { + NSLog(@"----------------- %s -----------------", sel_getName(_cmd)); + + NSData *privateKey; + NSData *publicKey; + + // Generating RSA keys + TSKeyGen *keygenRSA = [[TSKeyGen alloc] initWithAlgorithm:TSKeyGenAsymmetricAlgorithmRSA]; + + if (!keygenRSA) { + NSLog(@"%s Error occurred while initializing object keygenRSA", sel_getName(_cmd)); + return; + } + + privateKey = keygenRSA.privateKey; + NSLog(@"RSA private key: %@", privateKey); + + publicKey = keygenRSA.publicKey; + NSLog(@"RSA public key:%@", publicKey); + + // Generating EC keys + + TSKeyGen *keygenEC = [[TSKeyGen alloc] initWithAlgorithm:TSKeyGenAsymmetricAlgorithmEC]; + + if (!keygenEC) { + NSLog(@"%s Error occurred while initializing object keygenEC", sel_getName(_cmd)); + return; + } + + privateKey = keygenEC.privateKey; + NSLog(@"EC private key: %@", privateKey); + + publicKey = keygenEC.publicKey; + NSLog(@"EC public key:%@", publicKey); +} + +// Sometimes you will need to read keys from files +- (void)runExampleReadingKeysFromFile { + NSLog(@"----------------- %s -----------------", sel_getName(_cmd)); + + NSData *serverPrivateKeyFromFile = [[NSFileManager defaultManager] contentsAtPath:[[NSBundle mainBundle] pathForResource:@"server" + ofType:@"priv"]]; + NSData *serverPublicKeyFromFile = [[NSFileManager defaultManager] contentsAtPath:[[NSBundle mainBundle] pathForResource:@"server" + ofType:@"pub"]]; + NSData *clientPrivateKeyOldFromFile = [[NSFileManager defaultManager] contentsAtPath:[[NSBundle mainBundle] pathForResource:@"client" + ofType:@"priv"]]; + NSData *clientPublicKeyOldFromFile = [[NSFileManager defaultManager] contentsAtPath:[[NSBundle mainBundle] pathForResource:@"client" + ofType:@"pub"]]; + NSLog(@"%s", sel_getName(_cmd)); + NSLog(@"serverPrivateKeyFromFile %@", serverPrivateKeyFromFile); + NSLog(@"serverPublicKeyFromFile %@", serverPublicKeyFromFile); + NSLog(@"clientPrivateKeyOldFromFile %@", clientPrivateKeyOldFromFile); + NSLog(@"clientPublicKeyOldFromFile %@", clientPublicKeyOldFromFile); +} + +#pragma mark - Secure Message + +- (void)runExampleSecureMessageEncryptionDecryption { + NSLog(@"----------------- %s -----------------", sel_getName(_cmd)); + + // ---------- encryption + + // base64 encoded keys: + // client private key + // server public key + NSString *serverPublicKeyString = @"VUVDMgAAAC2ELbj5Aue5xjiJWW3P2KNrBX+HkaeJAb+Z4MrK0cWZlAfpBUql"; + NSString *clientPrivateKeyString = @"UkVDMgAAAC13PCVZAKOczZXUpvkhsC+xvwWnv3CLmlG0Wzy8ZBMnT+2yx/dg"; + + NSData *serverPublicKey = [[NSData alloc] initWithBase64EncodedString:serverPublicKeyString + options:NSDataBase64DecodingIgnoreUnknownCharacters]; + NSData *clientPrivateKey = [[NSData alloc] initWithBase64EncodedString:clientPrivateKeyString + options:NSDataBase64DecodingIgnoreUnknownCharacters]; + + // initialize encrypter + TSMessage *encrypter = [[TSMessage alloc] initInEncryptModeWithPrivateKey:clientPrivateKey peerPublicKey:serverPublicKey]; + + NSString *message = @"- Knock, knock.\n- Who’s there?\n*very long pause...*\n- Java."; + + NSError *themisError; + NSData *encryptedMessage = [encrypter wrapData:[message dataUsingEncoding:NSUTF8StringEncoding] + error:&themisError]; + if (themisError) { + NSLog(@"%s Error occurred while encrypting %@", sel_getName(_cmd), themisError); + return; + } + NSLog(@"%@", encryptedMessage); + + // -------- decryption + + // base64 encoded keys: + // server private key + // client public key + NSString *serverPrivateKeyString = @"UkVDMgAAAC1FsVa6AMGljYqtNWQ+7r4RjXTabLZxZ/14EXmi6ec2e1vrCmyR"; + NSString *clientPublicKeyString = @"VUVDMgAAAC1SsL32Axjosnf2XXUwm/4WxPlZauQ+v+0eOOjpwMN/EO+Huh5d"; + + NSData *serverPrivateKey = [[NSData alloc] initWithBase64EncodedString:serverPrivateKeyString + options:NSDataBase64DecodingIgnoreUnknownCharacters]; + NSData *clientPublicKey = [[NSData alloc] initWithBase64EncodedString:clientPublicKeyString + options:NSDataBase64DecodingIgnoreUnknownCharacters]; + + // initialize decrypter + TSMessage *decrypter = [[TSMessage alloc] initInEncryptModeWithPrivateKey:serverPrivateKey peerPublicKey:clientPublicKey]; + + NSData *decryptedMessage = [decrypter unwrapData:encryptedMessage error:&themisError]; + if (themisError) { + NSLog(@"%s Error occurred while decrypting %@", sel_getName(_cmd), themisError); + return; + } + + NSString *resultString = [[NSString alloc] initWithData:decryptedMessage encoding:NSUTF8StringEncoding]; + NSLog(@"%@", resultString); +} + +- (void)runExampleSecureMessageSignVerify { + NSLog(@"----------------- %s -----------------", sel_getName(_cmd)); + + // base64 encoded keys: + // private key + // public key + + NSString *publicKeyString = @"VUVDMgAAAC2ELbj5Aue5xjiJWW3P2KNrBX+HkaeJAb+Z4MrK0cWZlAfpBUql"; + NSString *privateKeyString = @"UkVDMgAAAC1FsVa6AMGljYqtNWQ+7r4RjXTabLZxZ/14EXmi6ec2e1vrCmyR"; + + NSData *publicKey = [[NSData alloc] initWithBase64EncodedString:publicKeyString + options:NSDataBase64DecodingIgnoreUnknownCharacters]; + NSData *privateKey = [[NSData alloc] initWithBase64EncodedString:privateKeyString + options:NSDataBase64DecodingIgnoreUnknownCharacters]; + + + // ---------- signing + + // initialize signer, use private key + TSMessage *signer = [[TSMessage alloc] initInSignVerifyModeWithPrivateKey:privateKey peerPublicKey:nil]; + + NSString *message = @"- Knock, knock.\n- Who’s there?\n*very long pause...*\n- Java."; + + NSError *themisError; + NSData *signedMessage = [signer wrapData:[message dataUsingEncoding:NSUTF8StringEncoding] + error:&themisError]; + if (themisError) { + NSLog(@"%s Error occurred while signing %@", sel_getName(_cmd), themisError); + return; + } + + // -------- verification + + // initialize verifier, use public key + TSMessage *verifier = [[TSMessage alloc] initInSignVerifyModeWithPrivateKey:nil peerPublicKey:publicKey]; + + NSData *verifiedMessage = [verifier unwrapData:signedMessage error:&themisError]; + if (themisError) { + NSLog(@"%s Error occurred while verifying %@", sel_getName(_cmd), themisError); + return; + } + + NSString *resultString = [[NSString alloc] initWithData:verifiedMessage encoding:NSUTF8StringEncoding]; + NSLog(@"%@", resultString); +} + +#pragma mark - Secure Comparator + +- (void)runExampleSecureComparator { + NSLog(@"----------------- %s -----------------", sel_getName(_cmd)); + + NSString *sharedSecret = @"shared secret"; + NSData *sharedSecretData = [sharedSecret dataUsingEncoding:NSUTF8StringEncoding]; + + TSComparator *client = [[TSComparator alloc] initWithMessageToCompare:sharedSecretData]; + TSComparator *server = [[TSComparator alloc] initWithMessageToCompare:sharedSecretData]; + NSError *error = nil; + + // send this message to server + NSData *data = [client beginCompare:&error]; + while ([client status] == TSComparatorNotReady || [server status] == TSComparatorNotReady) { + // receive from server + data = [server proceedCompare:data error:&error]; + + // proceed and send again + data = [client proceedCompare:data error:&error]; + } + + if ([client status] == TSComparatorMatch) { + // secrets match + NSLog(@"SecureComparator secrets match"); + } else { + // secrets don't match + NSLog(@"SecureComparator secrets do not match"); + } +} + +@end diff --git a/docs/examples/objc/macOS-SPM/ThemisTest/Assets.xcassets/AccentColor.colorset/Contents.json b/docs/examples/objc/macOS-SPM/ThemisTest/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 000000000..eb8789700 --- /dev/null +++ b/docs/examples/objc/macOS-SPM/ThemisTest/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/docs/examples/objc/macOS-SPM/ThemisTest/Assets.xcassets/AppIcon.appiconset/Contents.json b/docs/examples/objc/macOS-SPM/ThemisTest/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..3f00db43e --- /dev/null +++ b/docs/examples/objc/macOS-SPM/ThemisTest/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "scale" : "1x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "512x512" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "512x512" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/docs/examples/objc/macOS-SPM/ThemisTest/Assets.xcassets/Contents.json b/docs/examples/objc/macOS-SPM/ThemisTest/Assets.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/docs/examples/objc/macOS-SPM/ThemisTest/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/docs/examples/objc/macOS-SPM/ThemisTest/Base.lproj/Main.storyboard b/docs/examples/objc/macOS-SPM/ThemisTest/Base.lproj/Main.storyboard new file mode 100644 index 000000000..a12f1912f --- /dev/null +++ b/docs/examples/objc/macOS-SPM/ThemisTest/Base.lproj/Main.storyboard @@ -0,0 +1,717 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/examples/objc/macOS-SPM/ThemisTest/Info.plist b/docs/examples/objc/macOS-SPM/ThemisTest/Info.plist new file mode 100644 index 000000000..cfbbdb70c --- /dev/null +++ b/docs/examples/objc/macOS-SPM/ThemisTest/Info.plist @@ -0,0 +1,30 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSMainStoryboardFile + Main + NSPrincipalClass + NSApplication + + diff --git a/docs/examples/objc/macOS-SPM/ThemisTest/Resources/client.priv b/docs/examples/objc/macOS-SPM/ThemisTest/Resources/client.priv new file mode 100644 index 000000000..eec0a47f8 Binary files /dev/null and b/docs/examples/objc/macOS-SPM/ThemisTest/Resources/client.priv differ diff --git a/docs/examples/objc/macOS-SPM/ThemisTest/Resources/client.pub b/docs/examples/objc/macOS-SPM/ThemisTest/Resources/client.pub new file mode 100644 index 000000000..39668bd93 Binary files /dev/null and b/docs/examples/objc/macOS-SPM/ThemisTest/Resources/client.pub differ diff --git a/docs/examples/objc/macOS-SPM/ThemisTest/Resources/server.priv b/docs/examples/objc/macOS-SPM/ThemisTest/Resources/server.priv new file mode 100644 index 000000000..e8c0755d2 Binary files /dev/null and b/docs/examples/objc/macOS-SPM/ThemisTest/Resources/server.priv differ diff --git a/docs/examples/objc/macOS-SPM/ThemisTest/Resources/server.pub b/docs/examples/objc/macOS-SPM/ThemisTest/Resources/server.pub new file mode 100644 index 000000000..e50e2c042 Binary files /dev/null and b/docs/examples/objc/macOS-SPM/ThemisTest/Resources/server.pub differ diff --git a/docs/examples/objc/macOS-SPM/ThemisTest/ThemisTest.entitlements b/docs/examples/objc/macOS-SPM/ThemisTest/ThemisTest.entitlements new file mode 100644 index 000000000..f2ef3ae02 --- /dev/null +++ b/docs/examples/objc/macOS-SPM/ThemisTest/ThemisTest.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + + diff --git a/docs/examples/objc/macOS-SPM/ThemisTest/ViewController.h b/docs/examples/objc/macOS-SPM/ThemisTest/ViewController.h new file mode 100644 index 000000000..dbf355db6 --- /dev/null +++ b/docs/examples/objc/macOS-SPM/ThemisTest/ViewController.h @@ -0,0 +1,21 @@ +// Copyright (c) 2021 Cossack Labs Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import + +@interface ViewController : NSViewController + + +@end + diff --git a/docs/examples/objc/macOS-SPM/ThemisTest/ViewController.m b/docs/examples/objc/macOS-SPM/ThemisTest/ViewController.m new file mode 100644 index 000000000..1f3f415ad --- /dev/null +++ b/docs/examples/objc/macOS-SPM/ThemisTest/ViewController.m @@ -0,0 +1,33 @@ +// Copyright (c) 2021 Cossack Labs Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import "ViewController.h" + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + // Do any additional setup after loading the view. +} + + +- (void)setRepresentedObject:(id)representedObject { + [super setRepresentedObject:representedObject]; + + // Update the view, if already loaded. +} + + +@end diff --git a/docs/examples/objc/macOS-SPM/ThemisTest/main.m b/docs/examples/objc/macOS-SPM/ThemisTest/main.m new file mode 100644 index 000000000..e4603538b --- /dev/null +++ b/docs/examples/objc/macOS-SPM/ThemisTest/main.m @@ -0,0 +1,22 @@ +// Copyright (c) 2021 Cossack Labs Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import + +int main(int argc, const char * argv[]) { + @autoreleasepool { + // Setup code that might create autoreleased objects goes here. + } + return NSApplicationMain(argc, argv); +} diff --git a/docs/examples/swift/iOS-SPM/ThemisTest.xcodeproj/project.pbxproj b/docs/examples/swift/iOS-SPM/ThemisTest.xcodeproj/project.pbxproj new file mode 100644 index 000000000..82aa829af --- /dev/null +++ b/docs/examples/swift/iOS-SPM/ThemisTest.xcodeproj/project.pbxproj @@ -0,0 +1,397 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 52; + objects = { + +/* Begin PBXBuildFile section */ + 6D445264263C2D1600871215 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D445263263C2D1600871215 /* AppDelegate.swift */; }; + 6D445266263C2D1600871215 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D445265263C2D1600871215 /* SceneDelegate.swift */; }; + 6D445268263C2D1600871215 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D445267263C2D1600871215 /* ViewController.swift */; }; + 6D44526B263C2D1600871215 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6D445269263C2D1600871215 /* Main.storyboard */; }; + 6D44526D263C2D1800871215 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6D44526C263C2D1800871215 /* Assets.xcassets */; }; + 6D445270263C2D1800871215 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6D44526E263C2D1800871215 /* LaunchScreen.storyboard */; }; + 6D44527A263C2D5600871215 /* themis in Frameworks */ = {isa = PBXBuildFile; productRef = 6D445279263C2D5600871215 /* themis */; }; + 6D445281263C2D6100871215 /* server.priv in Resources */ = {isa = PBXBuildFile; fileRef = 6D44527D263C2D6100871215 /* server.priv */; }; + 6D445282263C2D6100871215 /* client.pub in Resources */ = {isa = PBXBuildFile; fileRef = 6D44527E263C2D6100871215 /* client.pub */; }; + 6D445283263C2D6100871215 /* server.pub in Resources */ = {isa = PBXBuildFile; fileRef = 6D44527F263C2D6100871215 /* server.pub */; }; + 6D445284263C2D6100871215 /* client.priv in Resources */ = {isa = PBXBuildFile; fileRef = 6D445280263C2D6100871215 /* client.priv */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 6D445260263C2D1600871215 /* ThemisTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ThemisTest.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 6D445263263C2D1600871215 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 6D445265263C2D1600871215 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 6D445267263C2D1600871215 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 6D44526A263C2D1600871215 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 6D44526C263C2D1800871215 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 6D44526F263C2D1800871215 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 6D445271263C2D1800871215 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 6D44527D263C2D6100871215 /* server.priv */ = {isa = PBXFileReference; lastKnownFileType = file; path = server.priv; sourceTree = ""; }; + 6D44527E263C2D6100871215 /* client.pub */ = {isa = PBXFileReference; lastKnownFileType = file; path = client.pub; sourceTree = ""; }; + 6D44527F263C2D6100871215 /* server.pub */ = {isa = PBXFileReference; lastKnownFileType = file; path = server.pub; sourceTree = ""; }; + 6D445280263C2D6100871215 /* client.priv */ = {isa = PBXFileReference; lastKnownFileType = file; path = client.priv; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 6D44525D263C2D1600871215 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 6D44527A263C2D5600871215 /* themis in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 6D445257263C2D1600871215 = { + isa = PBXGroup; + children = ( + 6D445262263C2D1600871215 /* ThemisTest */, + 6D445261263C2D1600871215 /* Products */, + ); + sourceTree = ""; + }; + 6D445261263C2D1600871215 /* Products */ = { + isa = PBXGroup; + children = ( + 6D445260263C2D1600871215 /* ThemisTest.app */, + ); + name = Products; + sourceTree = ""; + }; + 6D445262263C2D1600871215 /* ThemisTest */ = { + isa = PBXGroup; + children = ( + 6D44527C263C2D6100871215 /* Resources */, + 6D445263263C2D1600871215 /* AppDelegate.swift */, + 6D445265263C2D1600871215 /* SceneDelegate.swift */, + 6D445267263C2D1600871215 /* ViewController.swift */, + 6D445269263C2D1600871215 /* Main.storyboard */, + 6D44526C263C2D1800871215 /* Assets.xcassets */, + 6D44526E263C2D1800871215 /* LaunchScreen.storyboard */, + 6D445271263C2D1800871215 /* Info.plist */, + ); + path = ThemisTest; + sourceTree = ""; + }; + 6D44527C263C2D6100871215 /* Resources */ = { + isa = PBXGroup; + children = ( + 6D44527D263C2D6100871215 /* server.priv */, + 6D44527E263C2D6100871215 /* client.pub */, + 6D44527F263C2D6100871215 /* server.pub */, + 6D445280263C2D6100871215 /* client.priv */, + ); + path = Resources; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 6D44525F263C2D1600871215 /* ThemisTest */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6D445274263C2D1800871215 /* Build configuration list for PBXNativeTarget "ThemisTest" */; + buildPhases = ( + 6D44525C263C2D1600871215 /* Sources */, + 6D44525D263C2D1600871215 /* Frameworks */, + 6D44525E263C2D1600871215 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ThemisTest; + packageProductDependencies = ( + 6D445279263C2D5600871215 /* themis */, + ); + productName = ThemisTest; + productReference = 6D445260263C2D1600871215 /* ThemisTest.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 6D445258263C2D1600871215 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1240; + LastUpgradeCheck = 1240; + TargetAttributes = { + 6D44525F263C2D1600871215 = { + CreatedOnToolsVersion = 12.4; + }; + }; + }; + buildConfigurationList = 6D44525B263C2D1600871215 /* Build configuration list for PBXProject "ThemisTest" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 6D445257263C2D1600871215; + packageReferences = ( + 6D445278263C2D5600871215 /* XCRemoteSwiftPackageReference "themis" */, + ); + productRefGroup = 6D445261263C2D1600871215 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 6D44525F263C2D1600871215 /* ThemisTest */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 6D44525E263C2D1600871215 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6D445283263C2D6100871215 /* server.pub in Resources */, + 6D445270263C2D1800871215 /* LaunchScreen.storyboard in Resources */, + 6D445281263C2D6100871215 /* server.priv in Resources */, + 6D44526D263C2D1800871215 /* Assets.xcassets in Resources */, + 6D445284263C2D6100871215 /* client.priv in Resources */, + 6D44526B263C2D1600871215 /* Main.storyboard in Resources */, + 6D445282263C2D6100871215 /* client.pub in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 6D44525C263C2D1600871215 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6D445268263C2D1600871215 /* ViewController.swift in Sources */, + 6D445264263C2D1600871215 /* AppDelegate.swift in Sources */, + 6D445266263C2D1600871215 /* SceneDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 6D445269263C2D1600871215 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 6D44526A263C2D1600871215 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 6D44526E263C2D1800871215 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 6D44526F263C2D1800871215 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 6D445272263C2D1800871215 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.4; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 6D445273263C2D1800871215 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.4; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 6D445275263C2D1800871215 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = ThemisTest/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.themis.ThemisTest; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 6D445276263C2D1800871215 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = ""; + INFOPLIST_FILE = ThemisTest/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.themis.ThemisTest; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 6D44525B263C2D1600871215 /* Build configuration list for PBXProject "ThemisTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6D445272263C2D1800871215 /* Debug */, + 6D445273263C2D1800871215 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 6D445274263C2D1800871215 /* Build configuration list for PBXNativeTarget "ThemisTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6D445275263C2D1800871215 /* Debug */, + 6D445276263C2D1800871215 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 6D445278263C2D5600871215 /* XCRemoteSwiftPackageReference "themis" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/cossacklabs/themis"; + requirement = { + kind = exactVersion; + version = 0.13.7; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 6D445279263C2D5600871215 /* themis */ = { + isa = XCSwiftPackageProductDependency; + package = 6D445278263C2D5600871215 /* XCRemoteSwiftPackageReference "themis" */; + productName = themis; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 6D445258263C2D1600871215 /* Project object */; +} diff --git a/docs/examples/swift/iOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/docs/examples/swift/iOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/docs/examples/swift/iOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/docs/examples/swift/iOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/docs/examples/swift/iOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 000000000..3c87f2f34 --- /dev/null +++ b/docs/examples/swift/iOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "themis", + "repositoryURL": "https://github.com/cossacklabs/themis", + "state": { + "branch": null, + "revision": "68b485b8017098fce723e0839ecb9543d32463f6", + "version": "0.13.7" + } + } + ] + }, + "version": 1 +} diff --git a/docs/examples/swift/iOS-SPM/ThemisTest/AppDelegate.swift b/docs/examples/swift/iOS-SPM/ThemisTest/AppDelegate.swift new file mode 100644 index 000000000..d3ef4eda4 --- /dev/null +++ b/docs/examples/swift/iOS-SPM/ThemisTest/AppDelegate.swift @@ -0,0 +1,348 @@ +// Copyright (c) 2021 Cossack Labs Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import UIKit +import themis + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // + // We don't do UI. Please look into debug console to see the results. + // + + runExampleSecureCellSealMode() + runExampleSecureCellTokenProtectMode() + runExampleSecureCellImprint() + + runExampleGeneratingKeys() + runExampleReadingKeysFromFile() + + runExampleSecureMessageEncryptionDecryption() + runExampleSecureMessageSignVerify() + + runExampleSecureComparator() + + return true + } + + // MARK: - Secure Cell + + func generateMasterKey() -> Data { + let masterKeyString: String = "UkVDMgAAAC13PCVZAKOczZXUpvkhsC+xvwWnv3CLmlG0Wzy8ZBMnT+2yx/dg" + let masterKeyData: Data = Data(base64Encoded: masterKeyString, options: .ignoreUnknownCharacters)! + return masterKeyData + } + + func runExampleSecureCellSealMode() { + print("----------------------------------", #function) + let masterKeyData: Data = self.generateMasterKey() + guard let cellSeal: TSCellSeal = TSCellSeal(key: masterKeyData) else { + print("Error occurred while initializing object cellSeal", #function) + return + } + let message: String = "All your base are belong to us!" + let context: String = "For great justice" + + var encryptedMessage: Data = Data() + do { + // context is optional parameter and may be ignored + encryptedMessage = try cellSeal.encrypt(message.data(using: .utf8)!, + context: context.data(using: .utf8)!) + print("decryptedMessagez = \(encryptedMessage)") + + } catch let error as NSError { + print("Error occurred while encrypting \(error)", #function) + return + } + + do { + let decryptedMessage: Data = try cellSeal.decrypt(encryptedMessage, + context: context.data(using: .utf8)!) + let resultString: String = String(data: decryptedMessage, encoding: .utf8)! + print("decryptedMessage = \(resultString)") + + } catch let error as NSError { + print("Error occurred while decrypting \(error)", #function) + return + } + } + + func runExampleSecureCellTokenProtectMode() { + print("----------------------------------", #function) + let masterKeyData: Data = self.generateMasterKey() + guard let cellToken: TSCellToken = TSCellToken(key: masterKeyData) else { + print("Error occurred while initializing object cellToken", #function) + return + } + let message: String = "Roses are grey. Violets are grey." + let context: String = "I'm a dog" + + var encryptedMessage: TSCellTokenEncryptedResult = TSCellTokenEncryptedResult() + do { + // context is optional parameter and may be ignored + encryptedMessage = try cellToken.encrypt(message.data(using: .utf8)!, + context: context.data(using: .utf8)!) + print("encryptedMessage.cipher = \(encryptedMessage.encrypted)") + print("encryptedMessage.token = \(encryptedMessage.token)") + + } catch let error as NSError { + print("Error occurred while encrypting \(error)", #function) + return + } + + do { + let decryptedMessage: Data = try cellToken.decrypt(encryptedMessage.encrypted, + token: encryptedMessage.token, + context: context.data(using: .utf8)!) + let resultString: String = String(data: decryptedMessage, encoding: .utf8)! + print("decryptedMessage = \(resultString)") + + } catch let error as NSError { + print("Error occurred while decrypting \(error)", #function) + return + } + } + + func runExampleSecureCellImprint() { + print("----------------------------------", #function) + let masterKeyData: Data = self.generateMasterKey() + guard let contextImprint: TSCellContextImprint = TSCellContextImprint(key: masterKeyData) else { + print("Error occurred while initializing object contextImprint", #function) + return + } + let message: String = "Roses are red. My name is Dave. This poem have no sense" + let context: String = "Microwave" + + var encryptedMessage: Data = Data() + do { + // context is NOT optional parameter here + encryptedMessage = try contextImprint.encrypt(message.data(using: .utf8)!, + context: context.data(using: .utf8)!) + print("encryptedMessage = \(encryptedMessage)") + + } catch let error as NSError { + print("Error occurred while encrypting \(error)", #function) + return + } + + do { + // context is NOT optional parameter here + let decryptedMessage: Data = try contextImprint.decrypt(encryptedMessage, + context: context.data(using: .utf8)!) + let resultString: String = String(data: decryptedMessage, encoding: .utf8)! + print("decryptedMessage = \(resultString)") + + } catch let error as NSError { + print("Error occurred while decrypting \(error)", #function) + return + } + } + + // MARK: - Key Generation and Loading + + func runExampleGeneratingKeys() { + print("----------------------------------", #function) + + // Generating RSA keys + guard let keyGeneratorRSA: TSKeyGen = TSKeyGen(algorithm: .RSA) else { + print("Error occurred while initializing object keyGeneratorRSA", #function) + return + } + let privateKeyRSA: Data = keyGeneratorRSA.privateKey as Data + let publicKeyRSA: Data = keyGeneratorRSA.publicKey as Data + print("RSA privateKey = \(privateKeyRSA)") + print("RSA publicKey = \(publicKeyRSA)") + + // Generating EC keys + guard let keyGeneratorEC: TSKeyGen = TSKeyGen(algorithm: .EC) else { + print("Error occurred while initializing object keyGeneratorEC", #function) + return + } + let privateKeyEC: Data = keyGeneratorEC.privateKey as Data + let publicKeyEC: Data = keyGeneratorEC.publicKey as Data + print("EC privateKey = \(privateKeyEC)") + print("RSA publicKey = \(publicKeyEC)") + } + + // Sometimes you will need to read keys from files + func runExampleReadingKeysFromFile() { + print("----------------------------------", #function) + let fileManager: FileManager = FileManager.default + let mainBundle: Bundle = Bundle.main + + // yes, app will crash if no keys. that's idea of our sample + + let serverPrivateKeyFromFile: Data = fileManager.contents(atPath: mainBundle.path(forResource: "server", + ofType: "priv")!)! + let serverPublicKeyFromFile: Data = fileManager.contents(atPath: mainBundle.path(forResource: "server", + ofType: "pub")!)! + let clientPrivateKeyOldFromFile: Data = fileManager.contents(atPath: mainBundle.path(forResource: "client", + ofType: "priv")!)! + let clientPublicKeyOldFromFile: Data = fileManager.contents(atPath: mainBundle.path(forResource: "client", + ofType: "pub")!)! + + print("serverPrivateKeyFromFile = \(serverPrivateKeyFromFile)") + print("serverPublicKeyFromFile = \(serverPublicKeyFromFile)") + print("clientPrivateKeyOldFromFile = \(clientPrivateKeyOldFromFile)") + print("clientPublicKeyOldFromFile = \(clientPublicKeyOldFromFile)") + } + + // MARK: - Secure Message + + func runExampleSecureMessageEncryptionDecryption() { + print("----------------------------------", #function) + + // ---------- encryption ---------------- + + // base64 encoded keys: + // client private key + // server public key + + let serverPublicKeyString: String = "VUVDMgAAAC2ELbj5Aue5xjiJWW3P2KNrBX+HkaeJAb+Z4MrK0cWZlAfpBUql" + let clientPrivateKeyString: String = "UkVDMgAAAC13PCVZAKOczZXUpvkhsC+xvwWnv3CLmlG0Wzy8ZBMnT+2yx/dg" + + guard let serverPublicKey: Data = Data(base64Encoded: serverPublicKeyString, + options: .ignoreUnknownCharacters), + let clientPrivateKey: Data = Data(base64Encoded: clientPrivateKeyString, + options: .ignoreUnknownCharacters) else { + print("Error occurred during base64 encoding", #function) + return + } + + let encrypter: TSMessage = TSMessage.init(inEncryptModeWithPrivateKey: clientPrivateKey, + peerPublicKey: serverPublicKey)! + + let message: String = "- Knock, knock.\n- Who’s there?\n*very long pause...*\n- Java." + + var encryptedMessage: Data = Data() + do { + encryptedMessage = try encrypter.wrap(message.data(using: .utf8)) + print("encryptedMessage = \(encryptedMessage)") + + } catch let error as NSError { + print("Error occurred while encrypting \(error)", #function) + return + } + + // ---------- decryption ---------------- + let serverPrivateKeyString: String = "UkVDMgAAAC1FsVa6AMGljYqtNWQ+7r4RjXTabLZxZ/14EXmi6ec2e1vrCmyR" + let clientPublicKeyString: String = "VUVDMgAAAC1SsL32Axjosnf2XXUwm/4WxPlZauQ+v+0eOOjpwMN/EO+Huh5d" + + guard let serverPrivateKey: Data = Data(base64Encoded: serverPrivateKeyString, + options: .ignoreUnknownCharacters), + let clientPublicKey: Data = Data(base64Encoded: clientPublicKeyString, + options: .ignoreUnknownCharacters) else { + print("Error occurred during base64 encoding", #function) + return + } + + let decrypter: TSMessage = TSMessage.init(inEncryptModeWithPrivateKey: serverPrivateKey, + peerPublicKey: clientPublicKey)! + + do { + let decryptedMessage: Data = try decrypter.unwrapData(encryptedMessage) + let resultString: String = String(data: decryptedMessage, encoding: .utf8)! + print("decryptedMessage->\n\(resultString)") + + } catch let error as NSError { + print("Error occurred while decrypting \(error)", #function) + return + } + } + + func runExampleSecureMessageSignVerify() { + print("----------------------------------", #function) + + // base64 encoded keys: + // private key + // public key + + let publicKeyString: String = "VUVDMgAAAC2ELbj5Aue5xjiJWW3P2KNrBX+HkaeJAb+Z4MrK0cWZlAfpBUql" + let privateKeyString: String = "UkVDMgAAAC1FsVa6AMGljYqtNWQ+7r4RjXTabLZxZ/14EXmi6ec2e1vrCmyR" + + guard let publicKey: Data = Data(base64Encoded: publicKeyString, + options: .ignoreUnknownCharacters), + let privateKey: Data = Data(base64Encoded: privateKeyString, + options: .ignoreUnknownCharacters) else { + print("Error occurred during base64 encoding", #function) + return + } + + // ---------- signing ---------------- + // use private key + + let signer: TSMessage = TSMessage.init(inSignVerifyModeWithPrivateKey: privateKey, + peerPublicKey: nil)! + + let message: String = "I had a problem so I though to use Java. Now I have a ProblemFactory." + + var signedMessage: Data = Data() + do { + signedMessage = try signer.wrap(message.data(using: .utf8)) + print("signedMessage = \(signedMessage)") + + } catch let error as NSError { + print("Error occurred while signing \(error)", #function) + return + } + + // ---------- verification ---------------- + // use public key + let verifier = TSMessage.init(inSignVerifyModeWithPrivateKey: nil, + peerPublicKey: publicKey)! + + do { + let verifiedMessage: Data = try verifier.unwrapData(signedMessage) + let resultString: String = String(data: verifiedMessage, encoding: .utf8)! + print("verifiedMessage ->\n\(resultString)") + + } catch let error as NSError { + print("Error occurred while verifing \(error)", #function) + return + } + } + + // MARK: - Secure Comparator + + func runExampleSecureComparator() { + print("----------------------------------", #function) + + let sharedMessage = "shared secret" + let client: TSComparator = TSComparator.init(messageToCompare: sharedMessage.data(using: .utf8)!)! + let server: TSComparator = TSComparator.init(messageToCompare: sharedMessage.data(using: .utf8)!)! + + // send this message to server + var data = try? client.beginCompare() + + while (client.status() == TSComparatorStateType.notReady || + server.status() == TSComparatorStateType.notReady ) { + + // receive from server + data = try? server.proceedCompare(data) + + // proceed and send again + data = try? client.proceedCompare(data) + } + + if (client.status() == TSComparatorStateType.match) { + // secrets match + print("SecureComparator secrets match") + } else { + // secrets don't match + print("SecureComparator secrets do not match") + } + } +} diff --git a/docs/examples/swift/iOS-SPM/ThemisTest/Assets.xcassets/AccentColor.colorset/Contents.json b/docs/examples/swift/iOS-SPM/ThemisTest/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 000000000..eb8789700 --- /dev/null +++ b/docs/examples/swift/iOS-SPM/ThemisTest/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/docs/examples/swift/iOS-SPM/ThemisTest/Assets.xcassets/AppIcon.appiconset/Contents.json b/docs/examples/swift/iOS-SPM/ThemisTest/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..9221b9bb1 --- /dev/null +++ b/docs/examples/swift/iOS-SPM/ThemisTest/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/docs/examples/swift/iOS-SPM/ThemisTest/Assets.xcassets/Contents.json b/docs/examples/swift/iOS-SPM/ThemisTest/Assets.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/docs/examples/swift/iOS-SPM/ThemisTest/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/docs/examples/swift/iOS-SPM/ThemisTest/Base.lproj/LaunchScreen.storyboard b/docs/examples/swift/iOS-SPM/ThemisTest/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 000000000..865e9329f --- /dev/null +++ b/docs/examples/swift/iOS-SPM/ThemisTest/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/examples/swift/iOS-SPM/ThemisTest/Base.lproj/Main.storyboard b/docs/examples/swift/iOS-SPM/ThemisTest/Base.lproj/Main.storyboard new file mode 100644 index 000000000..25a763858 --- /dev/null +++ b/docs/examples/swift/iOS-SPM/ThemisTest/Base.lproj/Main.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/examples/swift/iOS-SPM/ThemisTest/Info.plist b/docs/examples/swift/iOS-SPM/ThemisTest/Info.plist new file mode 100644 index 000000000..5b531f7b2 --- /dev/null +++ b/docs/examples/swift/iOS-SPM/ThemisTest/Info.plist @@ -0,0 +1,66 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/docs/examples/swift/iOS-SPM/ThemisTest/Resources/client.priv b/docs/examples/swift/iOS-SPM/ThemisTest/Resources/client.priv new file mode 100644 index 000000000..eec0a47f8 Binary files /dev/null and b/docs/examples/swift/iOS-SPM/ThemisTest/Resources/client.priv differ diff --git a/docs/examples/swift/iOS-SPM/ThemisTest/Resources/client.pub b/docs/examples/swift/iOS-SPM/ThemisTest/Resources/client.pub new file mode 100644 index 000000000..39668bd93 Binary files /dev/null and b/docs/examples/swift/iOS-SPM/ThemisTest/Resources/client.pub differ diff --git a/docs/examples/swift/iOS-SPM/ThemisTest/Resources/server.priv b/docs/examples/swift/iOS-SPM/ThemisTest/Resources/server.priv new file mode 100644 index 000000000..e8c0755d2 Binary files /dev/null and b/docs/examples/swift/iOS-SPM/ThemisTest/Resources/server.priv differ diff --git a/docs/examples/swift/iOS-SPM/ThemisTest/Resources/server.pub b/docs/examples/swift/iOS-SPM/ThemisTest/Resources/server.pub new file mode 100644 index 000000000..e50e2c042 Binary files /dev/null and b/docs/examples/swift/iOS-SPM/ThemisTest/Resources/server.pub differ diff --git a/docs/examples/swift/iOS-SPM/ThemisTest/SceneDelegate.swift b/docs/examples/swift/iOS-SPM/ThemisTest/SceneDelegate.swift new file mode 100644 index 000000000..a8a8e0294 --- /dev/null +++ b/docs/examples/swift/iOS-SPM/ThemisTest/SceneDelegate.swift @@ -0,0 +1,59 @@ +// Copyright (c) 2021 Cossack Labs Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + guard let _ = (scene as? UIWindowScene) else { return } + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + +} + diff --git a/docs/examples/swift/iOS-SPM/ThemisTest/ViewController.swift b/docs/examples/swift/iOS-SPM/ThemisTest/ViewController.swift new file mode 100644 index 000000000..9f101a514 --- /dev/null +++ b/docs/examples/swift/iOS-SPM/ThemisTest/ViewController.swift @@ -0,0 +1,26 @@ +// Copyright (c) 2021 Cossack Labs Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import UIKit + +class ViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + } + + +} + diff --git a/docs/examples/swift/macOS-SPM/ThemisTest.xcodeproj/project.pbxproj b/docs/examples/swift/macOS-SPM/ThemisTest.xcodeproj/project.pbxproj new file mode 100644 index 000000000..db99790e9 --- /dev/null +++ b/docs/examples/swift/macOS-SPM/ThemisTest.xcodeproj/project.pbxproj @@ -0,0 +1,382 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 52; + objects = { + +/* Begin PBXBuildFile section */ + 6DFBC499263C2DB300DC8865 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DFBC498263C2DB300DC8865 /* AppDelegate.swift */; }; + 6DFBC49B263C2DB300DC8865 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DFBC49A263C2DB300DC8865 /* ViewController.swift */; }; + 6DFBC49D263C2DB600DC8865 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6DFBC49C263C2DB600DC8865 /* Assets.xcassets */; }; + 6DFBC4A0263C2DB600DC8865 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6DFBC49E263C2DB600DC8865 /* Main.storyboard */; }; + 6DFBC4AB263C2DC600DC8865 /* themis in Frameworks */ = {isa = PBXBuildFile; productRef = 6DFBC4AA263C2DC600DC8865 /* themis */; }; + 6DFBC4B2263C2DE300DC8865 /* server.priv in Resources */ = {isa = PBXBuildFile; fileRef = 6DFBC4AE263C2DE300DC8865 /* server.priv */; }; + 6DFBC4B3263C2DE300DC8865 /* client.pub in Resources */ = {isa = PBXBuildFile; fileRef = 6DFBC4AF263C2DE300DC8865 /* client.pub */; }; + 6DFBC4B4263C2DE300DC8865 /* server.pub in Resources */ = {isa = PBXBuildFile; fileRef = 6DFBC4B0263C2DE300DC8865 /* server.pub */; }; + 6DFBC4B5263C2DE300DC8865 /* client.priv in Resources */ = {isa = PBXBuildFile; fileRef = 6DFBC4B1263C2DE300DC8865 /* client.priv */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 6DFBC495263C2DB300DC8865 /* ThemisTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ThemisTest.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 6DFBC498263C2DB300DC8865 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 6DFBC49A263C2DB300DC8865 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 6DFBC49C263C2DB600DC8865 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 6DFBC49F263C2DB600DC8865 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 6DFBC4A1263C2DB600DC8865 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 6DFBC4A2263C2DB600DC8865 /* ThemisTest.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ThemisTest.entitlements; sourceTree = ""; }; + 6DFBC4AE263C2DE300DC8865 /* server.priv */ = {isa = PBXFileReference; lastKnownFileType = file; path = server.priv; sourceTree = ""; }; + 6DFBC4AF263C2DE300DC8865 /* client.pub */ = {isa = PBXFileReference; lastKnownFileType = file; path = client.pub; sourceTree = ""; }; + 6DFBC4B0263C2DE300DC8865 /* server.pub */ = {isa = PBXFileReference; lastKnownFileType = file; path = server.pub; sourceTree = ""; }; + 6DFBC4B1263C2DE300DC8865 /* client.priv */ = {isa = PBXFileReference; lastKnownFileType = file; path = client.priv; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 6DFBC492263C2DB300DC8865 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 6DFBC4AB263C2DC600DC8865 /* themis in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 6DFBC48C263C2DB300DC8865 = { + isa = PBXGroup; + children = ( + 6DFBC497263C2DB300DC8865 /* ThemisTest */, + 6DFBC496263C2DB300DC8865 /* Products */, + ); + sourceTree = ""; + }; + 6DFBC496263C2DB300DC8865 /* Products */ = { + isa = PBXGroup; + children = ( + 6DFBC495263C2DB300DC8865 /* ThemisTest.app */, + ); + name = Products; + sourceTree = ""; + }; + 6DFBC497263C2DB300DC8865 /* ThemisTest */ = { + isa = PBXGroup; + children = ( + 6DFBC4AD263C2DE300DC8865 /* Resources */, + 6DFBC498263C2DB300DC8865 /* AppDelegate.swift */, + 6DFBC49A263C2DB300DC8865 /* ViewController.swift */, + 6DFBC49C263C2DB600DC8865 /* Assets.xcassets */, + 6DFBC49E263C2DB600DC8865 /* Main.storyboard */, + 6DFBC4A1263C2DB600DC8865 /* Info.plist */, + 6DFBC4A2263C2DB600DC8865 /* ThemisTest.entitlements */, + ); + path = ThemisTest; + sourceTree = ""; + }; + 6DFBC4AD263C2DE300DC8865 /* Resources */ = { + isa = PBXGroup; + children = ( + 6DFBC4AE263C2DE300DC8865 /* server.priv */, + 6DFBC4AF263C2DE300DC8865 /* client.pub */, + 6DFBC4B0263C2DE300DC8865 /* server.pub */, + 6DFBC4B1263C2DE300DC8865 /* client.priv */, + ); + path = Resources; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 6DFBC494263C2DB300DC8865 /* ThemisTest */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6DFBC4A5263C2DB600DC8865 /* Build configuration list for PBXNativeTarget "ThemisTest" */; + buildPhases = ( + 6DFBC491263C2DB300DC8865 /* Sources */, + 6DFBC492263C2DB300DC8865 /* Frameworks */, + 6DFBC493263C2DB300DC8865 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ThemisTest; + packageProductDependencies = ( + 6DFBC4AA263C2DC600DC8865 /* themis */, + ); + productName = ThemisTest; + productReference = 6DFBC495263C2DB300DC8865 /* ThemisTest.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 6DFBC48D263C2DB300DC8865 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1240; + LastUpgradeCheck = 1240; + TargetAttributes = { + 6DFBC494263C2DB300DC8865 = { + CreatedOnToolsVersion = 12.4; + }; + }; + }; + buildConfigurationList = 6DFBC490263C2DB300DC8865 /* Build configuration list for PBXProject "ThemisTest" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 6DFBC48C263C2DB300DC8865; + packageReferences = ( + 6DFBC4A9263C2DC600DC8865 /* XCRemoteSwiftPackageReference "themis" */, + ); + productRefGroup = 6DFBC496263C2DB300DC8865 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 6DFBC494263C2DB300DC8865 /* ThemisTest */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 6DFBC493263C2DB300DC8865 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6DFBC49D263C2DB600DC8865 /* Assets.xcassets in Resources */, + 6DFBC4B2263C2DE300DC8865 /* server.priv in Resources */, + 6DFBC4B3263C2DE300DC8865 /* client.pub in Resources */, + 6DFBC4B4263C2DE300DC8865 /* server.pub in Resources */, + 6DFBC4A0263C2DB600DC8865 /* Main.storyboard in Resources */, + 6DFBC4B5263C2DE300DC8865 /* client.priv in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 6DFBC491263C2DB300DC8865 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6DFBC49B263C2DB300DC8865 /* ViewController.swift in Sources */, + 6DFBC499263C2DB300DC8865 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 6DFBC49E263C2DB600DC8865 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 6DFBC49F263C2DB600DC8865 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 6DFBC4A3263C2DB600DC8865 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 6DFBC4A4263C2DB600DC8865 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 6DFBC4A6263C2DB600DC8865 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = ThemisTest/ThemisTest.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = ThemisTest/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.themis.ThemisTest; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 6DFBC4A7263C2DB600DC8865 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_ENTITLEMENTS = ThemisTest/ThemisTest.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = ThemisTest/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.cossacklabs.themis.ThemisTest; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 6DFBC490263C2DB300DC8865 /* Build configuration list for PBXProject "ThemisTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6DFBC4A3263C2DB600DC8865 /* Debug */, + 6DFBC4A4263C2DB600DC8865 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 6DFBC4A5263C2DB600DC8865 /* Build configuration list for PBXNativeTarget "ThemisTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6DFBC4A6263C2DB600DC8865 /* Debug */, + 6DFBC4A7263C2DB600DC8865 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 6DFBC4A9263C2DC600DC8865 /* XCRemoteSwiftPackageReference "themis" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/cossacklabs/themis"; + requirement = { + kind = exactVersion; + version = 0.13.7; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 6DFBC4AA263C2DC600DC8865 /* themis */ = { + isa = XCSwiftPackageProductDependency; + package = 6DFBC4A9263C2DC600DC8865 /* XCRemoteSwiftPackageReference "themis" */; + productName = themis; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 6DFBC48D263C2DB300DC8865 /* Project object */; +} diff --git a/docs/examples/swift/macOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/docs/examples/swift/macOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/docs/examples/swift/macOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/docs/examples/swift/macOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/docs/examples/swift/macOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 000000000..3c87f2f34 --- /dev/null +++ b/docs/examples/swift/macOS-SPM/ThemisTest.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "themis", + "repositoryURL": "https://github.com/cossacklabs/themis", + "state": { + "branch": null, + "revision": "68b485b8017098fce723e0839ecb9543d32463f6", + "version": "0.13.7" + } + } + ] + }, + "version": 1 +} diff --git a/docs/examples/swift/macOS-SPM/ThemisTest/AppDelegate.swift b/docs/examples/swift/macOS-SPM/ThemisTest/AppDelegate.swift new file mode 100644 index 000000000..9140466b6 --- /dev/null +++ b/docs/examples/swift/macOS-SPM/ThemisTest/AppDelegate.swift @@ -0,0 +1,346 @@ +// Copyright (c) 2021 Cossack Labs Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import Cocoa +import themis + +@NSApplicationMain +class AppDelegate: NSObject, NSApplicationDelegate { + + func applicationDidFinishLaunching(_ aNotification: Notification) { + // + // We don't do UI. Please look into debug console to see the results. + // + + runExampleSecureCellSealMode() + runExampleSecureCellTokenProtectMode() + runExampleSecureCellImprint() + + runExampleGeneratingKeys() + runExampleReadingKeysFromFile() + + runExampleSecureMessageEncryptionDecryption() + runExampleSecureMessageSignVerify() + + runExampleSecureComparator() + } + + // MARK: - Secure Cell + + func generateMasterKey() -> Data { + let masterKeyString: String = "UkVDMgAAAC13PCVZAKOczZXUpvkhsC+xvwWnv3CLmlG0Wzy8ZBMnT+2yx/dg" + let masterKeyData: Data = Data(base64Encoded: masterKeyString, options: .ignoreUnknownCharacters)! + return masterKeyData + } + + func runExampleSecureCellSealMode() { + print("----------------------------------", #function) + let masterKeyData: Data = self.generateMasterKey() + guard let cellSeal: TSCellSeal = TSCellSeal(key: masterKeyData) else { + print("Error occurred while initializing object cellSeal", #function) + return + } + let message: String = "All your base are belong to us!" + let context: String = "For great justice" + + var encryptedMessage: Data = Data() + do { + // context is optional parameter and may be ignored + encryptedMessage = try cellSeal.encrypt(message.data(using: .utf8)!, + context: context.data(using: .utf8)!) + print("decryptedMessagez = \(encryptedMessage)") + + } catch let error as NSError { + print("Error occurred while encrypting \(error)", #function) + return + } + + do { + let decryptedMessage: Data = try cellSeal.decrypt(encryptedMessage, + context: context.data(using: .utf8)!) + let resultString: String = String(data: decryptedMessage, encoding: .utf8)! + print("decryptedMessage = \(resultString)") + + } catch let error as NSError { + print("Error occurred while decrypting \(error)", #function) + return + } + } + + func runExampleSecureCellTokenProtectMode() { + print("----------------------------------", #function) + let masterKeyData: Data = self.generateMasterKey() + guard let cellToken: TSCellToken = TSCellToken(key: masterKeyData) else { + print("Error occurred while initializing object cellToken", #function) + return + } + let message: String = "Roses are grey. Violets are grey." + let context: String = "I'm a dog" + + var encryptedMessage: TSCellTokenEncryptedResult = TSCellTokenEncryptedResult() + do { + // context is optional parameter and may be ignored + encryptedMessage = try cellToken.encrypt(message.data(using: .utf8)!, + context: context.data(using: .utf8)!) + print("encryptedMessage.cipher = \(encryptedMessage.encrypted)") + print("encryptedMessage.token = \(encryptedMessage.token)") + + } catch let error as NSError { + print("Error occurred while encrypting \(error)", #function) + return + } + + do { + let decryptedMessage: Data = try cellToken.decrypt(encryptedMessage.encrypted, + token: encryptedMessage.token, + context: context.data(using: .utf8)!) + let resultString: String = String(data: decryptedMessage, encoding: .utf8)! + print("decryptedMessage = \(resultString)") + + } catch let error as NSError { + print("Error occurred while decrypting \(error)", #function) + return + } + } + + func runExampleSecureCellImprint() { + print("----------------------------------", #function) + let masterKeyData: Data = self.generateMasterKey() + guard let contextImprint: TSCellContextImprint = TSCellContextImprint(key: masterKeyData) else { + print("Error occurred while initializing object contextImprint", #function) + return + } + let message: String = "Roses are red. My name is Dave. This poem have no sense" + let context: String = "Microwave" + + var encryptedMessage: Data = Data() + do { + // context is NOT optional parameter here + encryptedMessage = try contextImprint.encrypt(message.data(using: .utf8)!, + context: context.data(using: .utf8)!) + print("encryptedMessage = \(encryptedMessage)") + + } catch let error as NSError { + print("Error occurred while encrypting \(error)", #function) + return + } + + do { + // context is NOT optional parameter here + let decryptedMessage: Data = try contextImprint.decrypt(encryptedMessage, + context: context.data(using: .utf8)!) + let resultString: String = String(data: decryptedMessage, encoding: .utf8)! + print("decryptedMessage = \(resultString)") + + } catch let error as NSError { + print("Error occurred while decrypting \(error)", #function) + return + } + } + + // MARK: - Key Generation and Loading + + func runExampleGeneratingKeys() { + print("----------------------------------", #function) + + // Generating RSA keys + guard let keyGeneratorRSA: TSKeyGen = TSKeyGen(algorithm: .RSA) else { + print("Error occurred while initializing object keyGeneratorRSA", #function) + return + } + let privateKeyRSA: Data = keyGeneratorRSA.privateKey as Data + let publicKeyRSA: Data = keyGeneratorRSA.publicKey as Data + print("RSA privateKey = \(privateKeyRSA)") + print("RSA publicKey = \(publicKeyRSA)") + + // Generating EC keys + guard let keyGeneratorEC: TSKeyGen = TSKeyGen(algorithm: .EC) else { + print("Error occurred while initializing object keyGeneratorEC", #function) + return + } + let privateKeyEC: Data = keyGeneratorEC.privateKey as Data + let publicKeyEC: Data = keyGeneratorEC.publicKey as Data + print("EC privateKey = \(privateKeyEC)") + print("RSA publicKey = \(publicKeyEC)") + } + + // Sometimes you will need to read keys from files + func runExampleReadingKeysFromFile() { + print("----------------------------------", #function) + let fileManager: FileManager = FileManager.default + let mainBundle: Bundle = Bundle.main + + // yes, app will crash if no keys. that's idea of our sample + + let serverPrivateKeyFromFile: Data = fileManager.contents(atPath: mainBundle.path(forResource: "server", + ofType: "priv")!)! + let serverPublicKeyFromFile: Data = fileManager.contents(atPath: mainBundle.path(forResource: "server", + ofType: "pub")!)! + let clientPrivateKeyOldFromFile: Data = fileManager.contents(atPath: mainBundle.path(forResource: "client", + ofType: "priv")!)! + let clientPublicKeyOldFromFile: Data = fileManager.contents(atPath: mainBundle.path(forResource: "client", + ofType: "pub")!)! + + print("serverPrivateKeyFromFile = \(serverPrivateKeyFromFile)") + print("serverPublicKeyFromFile = \(serverPublicKeyFromFile)") + print("clientPrivateKeyOldFromFile = \(clientPrivateKeyOldFromFile)") + print("clientPublicKeyOldFromFile = \(clientPublicKeyOldFromFile)") + } + + // MARK: - Secure Message + + func runExampleSecureMessageEncryptionDecryption() { + print("----------------------------------", #function) + + // ---------- encryption ---------------- + + // base64 encoded keys: + // client private key + // server public key + + let serverPublicKeyString: String = "VUVDMgAAAC2ELbj5Aue5xjiJWW3P2KNrBX+HkaeJAb+Z4MrK0cWZlAfpBUql" + let clientPrivateKeyString: String = "UkVDMgAAAC13PCVZAKOczZXUpvkhsC+xvwWnv3CLmlG0Wzy8ZBMnT+2yx/dg" + + guard let serverPublicKey: Data = Data(base64Encoded: serverPublicKeyString, + options: .ignoreUnknownCharacters), + let clientPrivateKey: Data = Data(base64Encoded: clientPrivateKeyString, + options: .ignoreUnknownCharacters) else { + print("Error occurred during base64 encoding", #function) + return + } + + let encrypter: TSMessage = TSMessage.init(inEncryptModeWithPrivateKey: clientPrivateKey, + peerPublicKey: serverPublicKey)! + + let message: String = "- Knock, knock.\n- Who’s there?\n*very long pause...*\n- Java." + + var encryptedMessage: Data = Data() + do { + encryptedMessage = try encrypter.wrap(message.data(using: .utf8)) + print("encryptedMessage = \(encryptedMessage)") + + } catch let error as NSError { + print("Error occurred while encrypting \(error)", #function) + return + } + + // ---------- decryption ---------------- + let serverPrivateKeyString: String = "UkVDMgAAAC1FsVa6AMGljYqtNWQ+7r4RjXTabLZxZ/14EXmi6ec2e1vrCmyR" + let clientPublicKeyString: String = "VUVDMgAAAC1SsL32Axjosnf2XXUwm/4WxPlZauQ+v+0eOOjpwMN/EO+Huh5d" + + guard let serverPrivateKey: Data = Data(base64Encoded: serverPrivateKeyString, + options: .ignoreUnknownCharacters), + let clientPublicKey: Data = Data(base64Encoded: clientPublicKeyString, + options: .ignoreUnknownCharacters) else { + print("Error occurred during base64 encoding", #function) + return + } + + let decrypter: TSMessage = TSMessage.init(inEncryptModeWithPrivateKey: serverPrivateKey, + peerPublicKey: clientPublicKey)! + + do { + let decryptedMessage: Data = try decrypter.unwrapData(encryptedMessage) + let resultString: String = String(data: decryptedMessage, encoding: .utf8)! + print("decryptedMessage->\n\(resultString)") + + } catch let error as NSError { + print("Error occurred while decrypting \(error)", #function) + return + } + } + + func runExampleSecureMessageSignVerify() { + print("----------------------------------", #function) + + // base64 encoded keys: + // private key + // public key + + let publicKeyString: String = "VUVDMgAAAC2ELbj5Aue5xjiJWW3P2KNrBX+HkaeJAb+Z4MrK0cWZlAfpBUql" + let privateKeyString: String = "UkVDMgAAAC1FsVa6AMGljYqtNWQ+7r4RjXTabLZxZ/14EXmi6ec2e1vrCmyR" + + guard let publicKey: Data = Data(base64Encoded: publicKeyString, + options: .ignoreUnknownCharacters), + let privateKey: Data = Data(base64Encoded: privateKeyString, + options: .ignoreUnknownCharacters) else { + print("Error occurred during base64 encoding", #function) + return + } + + // ---------- signing ---------------- + // use private key + + let signer: TSMessage = TSMessage.init(inSignVerifyModeWithPrivateKey: privateKey, + peerPublicKey: nil)! + + let message: String = "I had a problem so I though to use Java. Now I have a ProblemFactory." + + var signedMessage: Data = Data() + do { + signedMessage = try signer.wrap(message.data(using: .utf8)) + print("signedMessage = \(signedMessage)") + + } catch let error as NSError { + print("Error occurred while signing \(error)", #function) + return + } + + // ---------- verification ---------------- + // use public key + let verifier = TSMessage.init(inSignVerifyModeWithPrivateKey: nil, + peerPublicKey: publicKey)! + + do { + let verifiedMessage: Data = try verifier.unwrapData(signedMessage) + let resultString: String = String(data: verifiedMessage, encoding: .utf8)! + print("verifiedMessage ->\n\(resultString)") + + } catch let error as NSError { + print("Error occurred while verifing \(error)", #function) + return + } + } + + // MARK: - Secure Comparator + + func runExampleSecureComparator() { + print("----------------------------------", #function) + + let sharedMessage = "shared secret" + let client: TSComparator = TSComparator.init(messageToCompare: sharedMessage.data(using: .utf8)!)! + let server: TSComparator = TSComparator.init(messageToCompare: sharedMessage.data(using: .utf8)!)! + + // send this message to server + var data = try? client.beginCompare() + + while (client.status() == TSComparatorStateType.notReady || + server.status() == TSComparatorStateType.notReady ) { + + // receive from server + data = try? server.proceedCompare(data) + + // proceed and send again + data = try? client.proceedCompare(data) + } + + if (client.status() == TSComparatorStateType.match) { + // secrets match + print("SecureComparator secrets match") + } else { + // secrets don't match + print("SecureComparator secrets do not match") + } + } +} diff --git a/docs/examples/swift/macOS-SPM/ThemisTest/Assets.xcassets/AccentColor.colorset/Contents.json b/docs/examples/swift/macOS-SPM/ThemisTest/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 000000000..eb8789700 --- /dev/null +++ b/docs/examples/swift/macOS-SPM/ThemisTest/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/docs/examples/swift/macOS-SPM/ThemisTest/Assets.xcassets/AppIcon.appiconset/Contents.json b/docs/examples/swift/macOS-SPM/ThemisTest/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..3f00db43e --- /dev/null +++ b/docs/examples/swift/macOS-SPM/ThemisTest/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "scale" : "1x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "512x512" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "512x512" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/docs/examples/swift/macOS-SPM/ThemisTest/Assets.xcassets/Contents.json b/docs/examples/swift/macOS-SPM/ThemisTest/Assets.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/docs/examples/swift/macOS-SPM/ThemisTest/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/docs/examples/swift/macOS-SPM/ThemisTest/Base.lproj/Main.storyboard b/docs/examples/swift/macOS-SPM/ThemisTest/Base.lproj/Main.storyboard new file mode 100644 index 000000000..6fa2d9b85 --- /dev/null +++ b/docs/examples/swift/macOS-SPM/ThemisTest/Base.lproj/Main.storyboard @@ -0,0 +1,717 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/examples/swift/macOS-SPM/ThemisTest/Info.plist b/docs/examples/swift/macOS-SPM/ThemisTest/Info.plist new file mode 100644 index 000000000..cfbbdb70c --- /dev/null +++ b/docs/examples/swift/macOS-SPM/ThemisTest/Info.plist @@ -0,0 +1,30 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSMainStoryboardFile + Main + NSPrincipalClass + NSApplication + + diff --git a/docs/examples/swift/macOS-SPM/ThemisTest/Resources/client.priv b/docs/examples/swift/macOS-SPM/ThemisTest/Resources/client.priv new file mode 100644 index 000000000..eec0a47f8 Binary files /dev/null and b/docs/examples/swift/macOS-SPM/ThemisTest/Resources/client.priv differ diff --git a/docs/examples/swift/macOS-SPM/ThemisTest/Resources/client.pub b/docs/examples/swift/macOS-SPM/ThemisTest/Resources/client.pub new file mode 100644 index 000000000..39668bd93 Binary files /dev/null and b/docs/examples/swift/macOS-SPM/ThemisTest/Resources/client.pub differ diff --git a/docs/examples/swift/macOS-SPM/ThemisTest/Resources/server.priv b/docs/examples/swift/macOS-SPM/ThemisTest/Resources/server.priv new file mode 100644 index 000000000..e8c0755d2 Binary files /dev/null and b/docs/examples/swift/macOS-SPM/ThemisTest/Resources/server.priv differ diff --git a/docs/examples/swift/macOS-SPM/ThemisTest/Resources/server.pub b/docs/examples/swift/macOS-SPM/ThemisTest/Resources/server.pub new file mode 100644 index 000000000..e50e2c042 Binary files /dev/null and b/docs/examples/swift/macOS-SPM/ThemisTest/Resources/server.pub differ diff --git a/docs/examples/swift/macOS-SPM/ThemisTest/ThemisTest.entitlements b/docs/examples/swift/macOS-SPM/ThemisTest/ThemisTest.entitlements new file mode 100644 index 000000000..f2ef3ae02 --- /dev/null +++ b/docs/examples/swift/macOS-SPM/ThemisTest/ThemisTest.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + + + diff --git a/docs/examples/swift/macOS-SPM/ThemisTest/ViewController.swift b/docs/examples/swift/macOS-SPM/ThemisTest/ViewController.swift new file mode 100644 index 000000000..f341864e1 --- /dev/null +++ b/docs/examples/swift/macOS-SPM/ThemisTest/ViewController.swift @@ -0,0 +1,33 @@ +// Copyright (c) 2021 Cossack Labs Limited +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import Cocoa + +class ViewController: NSViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + override var representedObject: Any? { + didSet { + // Update the view, if already loaded. + } + } + + +} +