diff --git a/enzevalos_iphone.xcodeproj/project.pbxproj.orig b/enzevalos_iphone.xcodeproj/project.pbxproj.orig
index 15b17663f8fec4aa5bb347c26ef44f5f092adae3..28d911baec08c8a5d4bbbb5194599ed0d4f5a5df 100644
--- a/enzevalos_iphone.xcodeproj/project.pbxproj.orig
+++ b/enzevalos_iphone.xcodeproj/project.pbxproj.orig
@@ -27,6 +27,11 @@
 		0ECEA0FE240E7DB1007DC71E /* mykey.p12 in Resources */ = {isa = PBXBuildFile; fileRef = 0ECEA0F4240E7DB0007DC71E /* mykey.p12 */; };
 		0ECEA0FF240E7DB1007DC71E /* evilCA.pem in Resources */ = {isa = PBXBuildFile; fileRef = 0ECEA0F5240E7DB0007DC71E /* evilCA.pem */; };
 		0ECEA100240E7DB1007DC71E /* evilkey1.pem in Resources */ = {isa = PBXBuildFile; fileRef = 0ECEA0F6240E7DB1007DC71E /* evilkey1.pem */; };
+		0ED9073024338E3C008CF9D0 /* SMIMETests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED9072F24338E3C008CF9D0 /* SMIMETests.swift */; };
+		0EF148052422543E00B3C198 /* Certificate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EF148042422543E00B3C198 /* Certificate.swift */; };
+		0EF148082422572500B3C198 /* general-helpers.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF148072422572500B3C198 /* general-helpers.c */; };
+		0EF1480B2422584F00B3C198 /* certificate-helpers.c in Sources */ = {isa = PBXBuildFile; fileRef = 0EF1480A2422584F00B3C198 /* certificate-helpers.c */; };
+		0EF73F4324237E6500932FA0 /* SMIMEHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EF73F4224237E6500932FA0 /* SMIMEHelpers.swift */; };
 		0EFEF0952417C0B400BB2FF7 /* CHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EFEF0942417C0B400BB2FF7 /* CHelpers.swift */; };
 		3E6B07DE2011246500E49609 /* invitationText.html in Resources */ = {isa = PBXBuildFile; fileRef = 3E6B07DD2011246500E49609 /* invitationText.html */; };
 		3EB4FA9F2012007C001D0625 /* DialogViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EB4FA9D2012007C001D0625 /* DialogViewController.swift */; };
@@ -166,6 +171,7 @@
 		47F867E22052B48E00AA832F /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 47F867E12052B48E00AA832F /* libz.tbd */; };
 		47F867E42052B49800AA832F /* libbz2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 47F867E32052B49800AA832F /* libbz2.tbd */; };
 		50F2E7D66366C779705987A7 /* Pods_enzevalos_iphoneUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF67EF30BB065CC9C0D17940 /* Pods_enzevalos_iphoneUITests.framework */; };
+		71DF08982421520D00162B74 /* EmailStringExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71DF08972421520D00162B74 /* EmailStringExtensionTests.swift */; };
 		71DFE5BA240679E80042019C /* HeaderExtractionValues.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71DFE5B9240679E80042019C /* HeaderExtractionValues.swift */; };
 		7500EE9D4F3130671F5C1AE2 /* Pods_enzevalos_iphoneTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7977EA7012D8E98D186D5C60 /* Pods_enzevalos_iphoneTests.framework */; };
 		8428A8531F4369C0007649A5 /* Gamification.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8428A8521F4369C0007649A5 /* Gamification.storyboard */; };
@@ -185,7 +191,7 @@
 		8428A8711F436A1E007649A5 /* GamificationStatusViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8428A86D1F436A1E007649A5 /* GamificationStatusViewController.swift */; };
 		8428A8831F436AC9007649A5 /* GamificationDataUnitTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8428A8561F4369EA007649A5 /* GamificationDataUnitTest.swift */; };
 		8428A8841F436ACC007649A5 /* GamificationElements.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8428A8541F4369CF007649A5 /* GamificationElements.xcassets */; };
-		988C9C5D240D507A006213F0 /* PhishingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 988C9C5C240D507A006213F0 /* PhishingTests.swift */; };
+		988C9C5D240D507A006213F0 /* UrlStringExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 988C9C5C240D507A006213F0 /* UrlStringExtensionTests.swift */; };
 		A102AA8A1EDDB4F40024B457 /* videoOnboarding2.m4v in Resources */ = {isa = PBXBuildFile; fileRef = A102AA891EDDB4E80024B457 /* videoOnboarding2.m4v */; };
 		A1083A541E8BFEA6003666B7 /* Onboarding.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1083A531E8BFEA6003666B7 /* Onboarding.swift */; };
 		A10DAA5721F37600005D8BBB /* IntroInfoButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = A10DAA5621F37600005D8BBB /* IntroInfoButton.swift */; };
@@ -245,7 +251,7 @@
 		A1F992291DA7C9100073BF1B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A1F9922B1DA7C9100073BF1B /* Main.storyboard */; };
 		A1F992391DA7DD2E0073BF1B /* InboxTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = A1F9923B1DA7DD2E0073BF1B /* InboxTableViewCell.xib */; };
 		A1FA44A721E10E1400DB02AC /* TravelHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = A1FA44A621E10E1400DB02AC /* TravelHandler.swift */; };
-		A5E303D824110F6400310264 /* openssl-helpers.c in Sources */ = {isa = PBXBuildFile; fileRef = A5E303D724110F6400310264 /* openssl-helpers.c */; };
+		A5E303D824110F6400310264 /* smime-helpers.c in Sources */ = {isa = PBXBuildFile; fileRef = A5E303D724110F6400310264 /* smime-helpers.c */; };
 		AC4001CA169DC07A7A1E3AD3 /* Pods_enzevalos_iphone.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 94EE54279AB591E0CAB8EFD8 /* Pods_enzevalos_iphone.framework */; };
 		F113C3851F30D06800E7F1D6 /* QRScannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F113C3841F30D06800E7F1D6 /* QRScannerView.swift */; };
 		F113C38B1F3344C200E7F1D6 /* ViewControllerPannable.swift in Sources */ = {isa = PBXBuildFile; fileRef = F113C38A1F3344C200E7F1D6 /* ViewControllerPannable.swift */; };
@@ -321,6 +327,13 @@
 		0ECEA0F4240E7DB0007DC71E /* mykey.p12 */ = {isa = PBXFileReference; lastKnownFileType = file; path = mykey.p12; sourceTree = "<group>"; };
 		0ECEA0F5240E7DB0007DC71E /* evilCA.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = evilCA.pem; sourceTree = "<group>"; };
 		0ECEA0F6240E7DB1007DC71E /* evilkey1.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = evilkey1.pem; sourceTree = "<group>"; };
+		0ED9072F24338E3C008CF9D0 /* SMIMETests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SMIMETests.swift; sourceTree = "<group>"; };
+		0EF148042422543E00B3C198 /* Certificate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Certificate.swift; sourceTree = "<group>"; };
+		0EF148062422570F00B3C198 /* generic-helpers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "generic-helpers.h"; sourceTree = "<group>"; };
+		0EF148072422572500B3C198 /* general-helpers.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = "general-helpers.c"; sourceTree = "<group>"; };
+		0EF148092422584F00B3C198 /* certificate-helpers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "certificate-helpers.h"; sourceTree = "<group>"; };
+		0EF1480A2422584F00B3C198 /* certificate-helpers.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = "certificate-helpers.c"; sourceTree = "<group>"; };
+		0EF73F4224237E6500932FA0 /* SMIMEHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SMIMEHelpers.swift; sourceTree = "<group>"; };
 		0EFEF0942417C0B400BB2FF7 /* CHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CHelpers.swift; sourceTree = "<group>"; };
 		1D4A9E60565DECF52C011BC0 /* Pods-enzevalos_iphone-AdHoc.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-enzevalos_iphone-AdHoc.release.xcconfig"; path = "../enzevalos_iphone_workspace/Pods/Target Support Files/Pods-enzevalos_iphone-AdHoc/Pods-enzevalos_iphone-AdHoc.release.xcconfig"; sourceTree = "<group>"; };
 		3E6B07DD2011246500E49609 /* invitationText.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; name = invitationText.html; path = Invitation/invitationText.html; sourceTree = "<group>"; };
@@ -577,7 +590,9 @@
 		47F867E32052B49800AA832F /* libbz2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libbz2.tbd; path = usr/lib/libbz2.tbd; sourceTree = SDKROOT; };
 		48C250BB32BF11B683003BA1 /* Pods-enzevalos_iphone-enzevalos_iphoneUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-enzevalos_iphone-enzevalos_iphoneUITests.debug.xcconfig"; path = "../enzevalos_iphone_workspace/Pods/Target Support Files/Pods-enzevalos_iphone-enzevalos_iphoneUITests/Pods-enzevalos_iphone-enzevalos_iphoneUITests.debug.xcconfig"; sourceTree = "<group>"; };
 		66E758F271CD65AB3E5FE7A7 /* Pods-enzevalos_iphoneUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-enzevalos_iphoneUITests.debug.xcconfig"; path = "../enzevalos_iphone_workspace/Pods/Target Support Files/Pods-enzevalos_iphoneUITests/Pods-enzevalos_iphoneUITests.debug.xcconfig"; sourceTree = "<group>"; };
+		670159DF240FB4E800797FA5 /* enzevalos_iphone 9.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "enzevalos_iphone 9.xcdatamodel"; sourceTree = "<group>"; };
 		6EBCCD02AD3B95D8317810E2 /* Pods-enzevalos_iphoneTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-enzevalos_iphoneTests.debug.xcconfig"; path = "../enzevalos_iphone_workspace/Pods/Target Support Files/Pods-enzevalos_iphoneTests/Pods-enzevalos_iphoneTests.debug.xcconfig"; sourceTree = "<group>"; };
+		71DF08972421520D00162B74 /* EmailStringExtensionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmailStringExtensionTests.swift; sourceTree = "<group>"; };
 		71DFE5B9240679E80042019C /* HeaderExtractionValues.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderExtractionValues.swift; sourceTree = "<group>"; };
 		796D16D79BED5D60B580E602 /* Pods-enzevalos_iphoneUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-enzevalos_iphoneUITests.release.xcconfig"; path = "../enzevalos_iphone_workspace/Pods/Target Support Files/Pods-enzevalos_iphoneUITests/Pods-enzevalos_iphoneUITests.release.xcconfig"; sourceTree = "<group>"; };
 		7977EA7012D8E98D186D5C60 /* Pods_enzevalos_iphoneTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_enzevalos_iphoneTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -605,7 +620,11 @@
 		97AACD2324178C230078A68E /* AuthenticationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationModel.swift; sourceTree = "<group>"; };
 		97C5279E241A9F7B0030BBC9 /* AuthenticationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationTests.swift; sourceTree = "<group>"; };
 		97C527A0241AA4090030BBC9 /* GeneratedMocks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GeneratedMocks.swift; path = enzevalos_iphoneTests/GeneratedMocks.swift; sourceTree = SOURCE_ROOT; };
+<<<<<<< HEAD
 		988C9C5C240D507A006213F0 /* PhishingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhishingTests.swift; sourceTree = "<group>"; };
+=======
+		988C9C5C240D507A006213F0 /* UrlStringExtensionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UrlStringExtensionTests.swift; sourceTree = "<group>"; };
+>>>>>>> dev
 		9A132EDE8BCA06ACDB505C22 /* Pods-enzevalos_iphoneUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-enzevalos_iphoneUITests.debug.xcconfig"; path = "../enzevalos_iphone_workspace/Pods/Target Support Files/Pods-enzevalos_iphoneUITests/Pods-enzevalos_iphoneUITests.debug.xcconfig"; sourceTree = "<group>"; };
 		9B3D62838C729BAC6832270A /* Pods-enzevalos_iphone-AdHoc.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-enzevalos_iphone-AdHoc.debug.xcconfig"; path = "../enzevalos_iphone_workspace/Pods/Target Support Files/Pods-enzevalos_iphone-AdHoc/Pods-enzevalos_iphone-AdHoc.debug.xcconfig"; sourceTree = "<group>"; };
 		A102AA891EDDB4E80024B457 /* videoOnboarding2.m4v */ = {isa = PBXFileReference; lastKnownFileType = file; path = videoOnboarding2.m4v; sourceTree = "<group>"; };
@@ -683,8 +702,8 @@
 		A1F9923D1DA7DD350073BF1B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InboxTableViewCell.strings; sourceTree = "<group>"; };
 		A1F9923F1DA7DD370073BF1B /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InboxTableViewCell.strings; sourceTree = "<group>"; };
 		A1FA44A621E10E1400DB02AC /* TravelHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TravelHandler.swift; sourceTree = "<group>"; };
-		A5E303D624110F6400310264 /* openssl-helpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "openssl-helpers.h"; sourceTree = "<group>"; };
-		A5E303D724110F6400310264 /* openssl-helpers.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "openssl-helpers.c"; sourceTree = "<group>"; };
+		A5E303D624110F6400310264 /* smime-helpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "smime-helpers.h"; sourceTree = "<group>"; };
+		A5E303D724110F6400310264 /* smime-helpers.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "smime-helpers.c"; sourceTree = "<group>"; };
 		AA686D4FC9B86445A0C87F0F /* Pods-enzevalos_iphone.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-enzevalos_iphone.release.xcconfig"; path = "../enzevalos_iphone_workspace/Pods/Target Support Files/Pods-enzevalos_iphone/Pods-enzevalos_iphone.release.xcconfig"; sourceTree = "<group>"; };
 		AF67EF30BB065CC9C0D17940 /* Pods_enzevalos_iphoneUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_enzevalos_iphoneUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		BC7D006B3B40A23E53B4F317 /* Pods-enzevalos_iphoneTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-enzevalos_iphoneTests.release.xcconfig"; path = "../enzevalos_iphone_workspace/Pods/Target Support Files/Pods-enzevalos_iphoneTests/Pods-enzevalos_iphoneTests.release.xcconfig"; sourceTree = "<group>"; };
@@ -759,8 +778,10 @@
 		0ECEA101240EA905007DC71E /* SMIME */ = {
 			isa = PBXGroup;
 			children = (
-				0ECA5797240D496800B0F231 /* SMIME.swift */,
+				0EF148042422543E00B3C198 /* Certificate.swift */,
 				A5E303D524110F6400310264 /* c */,
+				0ECA5797240D496800B0F231 /* SMIME.swift */,
+				0EF73F4224237E6500932FA0 /* SMIMEHelpers.swift */,
 			);
 			name = SMIME;
 			sourceTree = "<group>";
@@ -1203,6 +1224,15 @@
 			path = private;
 			sourceTree = "<group>";
 		};
+		71DF0896242151E200162B74 /* phishing */ = {
+			isa = PBXGroup;
+			children = (
+				988C9C5C240D507A006213F0 /* UrlStringExtensionTests.swift */,
+				71DF08972421520D00162B74 /* EmailStringExtensionTests.swift */,
+			);
+			path = phishing;
+			sourceTree = "<group>";
+		};
 		78280F99990BFF65543B7F0B /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
@@ -1351,9 +1381,9 @@
 <<<<<<< HEAD
 				0EFEF0932417C08B00BB2FF7 /* C Helpers */,
 =======
+>>>>>>> dev
 				47EABF05241A9C7000774A93 /* Authentication */,
 				476406872416B54D00C7D426 /* SwiftUI */,
->>>>>>> dev
 				476403FA2413F95300C7D426 /* OpenSSL */,
 				A1B9999D21DE7CD2002563F6 /* Travel */,
 				477548DC21F5DA46000B22A8 /* mail */,
@@ -1395,8 +1425,14 @@
 		A135268F1D955BE000D3BFE1 /* enzevalos_iphoneTests */ = {
 			isa = PBXGroup;
 			children = (
+<<<<<<< HEAD
+				0ED9072F24338E3C008CF9D0 /* SMIMETests.swift */,
 				97C5279D241A9F690030BBC9 /* authentication */,
 				988C9C5C240D507A006213F0 /* PhishingTests.swift */,
+=======
+				71DF0896242151E200162B74 /* phishing */,
+				97C5279D241A9F690030BBC9 /* authentication */,
+>>>>>>> dev
 				47F0376C22A7278A0005C9DE /* private */,
 				470709202189C24800DF71A3 /* testKeys */,
 				470709112189BB4A00DF71A3 /* testMails */,
@@ -1582,8 +1618,12 @@
 		A5E303D524110F6400310264 /* c */ = {
 			isa = PBXGroup;
 			children = (
-				A5E303D624110F6400310264 /* openssl-helpers.h */,
-				A5E303D724110F6400310264 /* openssl-helpers.c */,
+				A5E303D624110F6400310264 /* smime-helpers.h */,
+				A5E303D724110F6400310264 /* smime-helpers.c */,
+				0EF148062422570F00B3C198 /* generic-helpers.h */,
+				0EF148072422572500B3C198 /* general-helpers.c */,
+				0EF148092422584F00B3C198 /* certificate-helpers.h */,
+				0EF1480A2422584F00B3C198 /* certificate-helpers.c */,
 			);
 			path = c;
 			sourceTree = "<group>";
@@ -1696,6 +1736,7 @@
 				A13526881D955BE000D3BFE1 /* Sources */,
 				A13526891D955BE000D3BFE1 /* Frameworks */,
 				A135268A1D955BE000D3BFE1 /* Resources */,
+				0811D368D52F1D9B243500D4 /* [CP] Embed Pods Frameworks */,
 			);
 			buildRules = (
 			);
@@ -1879,6 +1920,24 @@
 /* End PBXResourcesBuildPhase section */
 
 /* Begin PBXShellScriptBuildPhase section */
+		0811D368D52F1D9B243500D4 /* [CP] Embed Pods Frameworks */ = {
+			isa = PBXShellScriptBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			inputPaths = (
+				"${PODS_ROOT}/Target Support Files/Pods-enzevalos_iphoneTests/Pods-enzevalos_iphoneTests-frameworks.sh",
+				"${BUILT_PRODUCTS_DIR}/Cuckoo/Cuckoo.framework",
+			);
+			name = "[CP] Embed Pods Frameworks";
+			outputPaths = (
+				"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cuckoo.framework",
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+			shellPath = /bin/sh;
+			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-enzevalos_iphoneTests/Pods-enzevalos_iphoneTests-frameworks.sh\"\n";
+			showEnvVarsInLog = 0;
+		};
 		3992B0CB6412E8526773B814 /* [CP] Embed Pods Frameworks */ = {
 			isa = PBXShellScriptBuildPhase;
 			buildActionMask = 2147483647;
@@ -2050,7 +2109,7 @@
 				A1EB05801D956851008659C1 /* SendViewController.swift in Sources */,
 				479C649B21F45DAF00A01071 /* PasswordToggleVisibilityView.swift in Sources */,
 				47691A8C1ECC3EC7004BCFC5 /* EphemeralMail.swift in Sources */,
-				A5E303D824110F6400310264 /* openssl-helpers.c in Sources */,
+				A5E303D824110F6400310264 /* smime-helpers.c in Sources */,
 				A142E70921E7919F000395E3 /* IntroContactViewController.swift in Sources */,
 				8428A8671F436A11007649A5 /* SubBadgeHeaderTableViewCell.swift in Sources */,
 				A1EB05981D956947008659C1 /* InboxViewController.swift in Sources */,
@@ -2062,6 +2121,10 @@
 				472F398C1E2519C8009260FB /* CNContactExtension.swift in Sources */,
 				476406A12416B5C800C7D426 /* OnboardingIntro.swift in Sources */,
 				476406972416B54D00C7D426 /* InboxCoordinator.swift in Sources */,
+<<<<<<< HEAD
+				0EF148082422572500B3C198 /* general-helpers.c in Sources */,
+=======
+>>>>>>> dev
 				F113C3851F30D06800E7F1D6 /* QRScannerView.swift in Sources */,
 				477670C6228454F700043604 /* ButtonCell.swift in Sources */,
 				F18B44601E704C550080C041 /* ReplaceSegue.swift in Sources */,
@@ -2134,6 +2197,7 @@
 				A111F6AD1FA77B170060AFDE /* LoggerDetail.swift in Sources */,
 				A13526791D955BDF00D3BFE1 /* AppDelegate.swift in Sources */,
 				476916A2216B86CF00491527 /* EnzevalosContact+CoreDataClass.swift in Sources */,
+				0EF148052422543E00B3C198 /* Certificate.swift in Sources */,
 				A1ECE54B1EFBE7ED0009349F /* FolderCell.swift in Sources */,
 				8428A85F1F436A05007649A5 /* GamificationData.swift in Sources */,
 				475DF4791F0D54C9009D807F /* Folder+CoreDataClass.swift in Sources */,
@@ -2147,8 +2211,8 @@
 <<<<<<< HEAD
 				0EFEF0952417C0B400BB2FF7 /* CHelpers.swift in Sources */,
 =======
-				4764069D2416B54D00C7D426 /* Stroke.swift in Sources */,
 >>>>>>> dev
+				4764069D2416B54D00C7D426 /* Stroke.swift in Sources */,
 				478AF715222FD5C600AEF69E /* IncomingMail.swift in Sources */,
 				47EABF09241A9C8700774A93 /* AuthenticationModel.swift in Sources */,
 				47C036FF2347C0F5006295E8 /* ImportKeyOverviewController.swift in Sources */,
@@ -2171,6 +2235,10 @@
 				47E7376E22845EC400972401 /* SecretKeyTableViewController.swift in Sources */,
 				478154A721FF3F0900A931EC /* Warning.swift in Sources */,
 				4764069F2416B5A600C7D426 /* NewOnboardingView.swift in Sources */,
+<<<<<<< HEAD
+				0EF73F4324237E6500932FA0 /* SMIMEHelpers.swift in Sources */,
+=======
+>>>>>>> dev
 				47EABF0B241A9C8700774A93 /* AuthenticationScreen.swift in Sources */,
 				8428A8681F436A11007649A5 /* SubBadgeTableViewCell.swift in Sources */,
 				A1EB05861D956872008659C1 /* FrequentCell.swift in Sources */,
@@ -2181,6 +2249,7 @@
 				478154AC21FF6A9600A931EC /* Mailbot.swift in Sources */,
 				8428A86E1F436A1E007649A5 /* BadgeCase.swift in Sources */,
 				A1B49E5D21E54CBF00ED86FC /* IntroContactTableViewController.swift in Sources */,
+				0EF1480B2422584F00B3C198 /* certificate-helpers.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2189,12 +2258,19 @@
 			buildActionMask = 2147483647;
 			files = (
 				8428A8831F436AC9007649A5 /* GamificationDataUnitTest.swift in Sources */,
+				71DF08982421520D00162B74 /* EmailStringExtensionTests.swift in Sources */,
 				3EC35F302003838E008BDF95 /* InvitationTests.swift in Sources */,
 				474054982244D7A9007CF83B /* MailServerConfigurationTest.swift in Sources */,
 				479B5977206914BE00B3944D /* CryptoTests.swift in Sources */,
 				A15D215F223BE6E4003E0CE0 /* MailTest.swift in Sources */,
+<<<<<<< HEAD
+				0ED9073024338E3C008CF9D0 /* SMIMETests.swift in Sources */,
 				47EABF0F2420C63600774A93 /* AuthenticationTests.swift in Sources */,
 				988C9C5D240D507A006213F0 /* PhishingTests.swift in Sources */,
+=======
+				47EABF0F2420C63600774A93 /* AuthenticationTests.swift in Sources */,
+				988C9C5D240D507A006213F0 /* UrlStringExtensionTests.swift in Sources */,
+>>>>>>> dev
 				4715F637202A0248001BFFD0 /* CoreDataTests.swift in Sources */,
 				47C22281218AFD6300BD2C2B /* AutocryptTest.swift in Sources */,
 				478154AE2200641900A931EC /* StudyTest.swift in Sources */,
@@ -2736,6 +2812,7 @@
 		A135267F1D955BDF00D3BFE1 /* enzevalos_iphone.xcdatamodeld */ = {
 			isa = XCVersionGroup;
 			children = (
+				670159DF240FB4E800797FA5 /* enzevalos_iphone 9.xcdatamodel */,
 				4751C6FD2344D169006B2A4D /* enzevalos_iphone 8.xcdatamodel */,
 				4751C6F0233CE1E4006B2A4D /* enzevalos_iphone 7.xcdatamodel */,
 				A1909719220F887D00FA7B2A /* enzevalos_iphone 6.xcdatamodel */,
@@ -2745,7 +2822,7 @@
 				47B2318A1F0D458100961B28 /* enzevalos_iphone 2.xcdatamodel */,
 				A13526801D955BDF00D3BFE1 /* enzevalos_iphone.xcdatamodel */,
 			);
-			currentVersion = 4751C6FD2344D169006B2A4D /* enzevalos_iphone 8.xcdatamodel */;
+			currentVersion = 670159DF240FB4E800797FA5 /* enzevalos_iphone 9.xcdatamodel */;
 			path = enzevalos_iphone.xcdatamodeld;
 			sourceTree = "<group>";
 			versionGroupType = wrapper.xcdatamodel;
diff --git a/enzevalos_iphone/Certificate.swift b/enzevalos_iphone/Certificate.swift
index 57461a560f1ee3dece36bafc88fdb78075d40c75..730425415db8f814811263559d739e03873dbaa5 100644
--- a/enzevalos_iphone/Certificate.swift
+++ b/enzevalos_iphone/Certificate.swift
@@ -24,19 +24,16 @@ class Certificate {
         
         defer {
             deallocateCertInfo(certInfo: cCertInfo)
-            // cCertInfo?.deallocate()
         }
         
         let certInfo = cCertInfo?.pointee
         
-        // TODO: look for private key
         self.hasPrivateKey = pem.contains("PRIVATE KEY")
         
         let (fingerPrint, _, errors) = getFingerprintFromPem(pem: pem)
-        /*if (fingerPrint == nil) {
-            throw SMIMEError
-        }*/
-        self.fingerPrint = fingerPrint! // TODO: REPLACE WITH EXCEPTION
+        
+        // if it crashes on this line, you can loop through the errors and see what's wrong
+        self.fingerPrint = fingerPrint!
         self.pem = pem
         
         self.eMails = certInfo?.extractField(field: CertInfoString.emails)
@@ -45,14 +42,6 @@ class Certificate {
         self.subject = certInfo?.extractField(field: CertInfoString.subject)
         self.issuer = certInfo?.extractField(field: CertInfoString.issuer)
     }
-    
-    //deinit() {
-        
-    //}
-    
-    func getMails() {
-        
-    }
 }
 
 /**
diff --git a/enzevalos_iphone/SMIME.swift b/enzevalos_iphone/SMIME.swift
index 842f8dfcb23ba4ccf88871b05fed54e1c6370d39..023d97c543d3387e46fefa052948fc37d868adca 100644
--- a/enzevalos_iphone/SMIME.swift
+++ b/enzevalos_iphone/SMIME.swift
@@ -11,9 +11,10 @@ import Security
 import KeychainAccess
 
 /**
- The class is a swift wrapper around the C implementation for SMIME so that all C pointers are deallocated correctly
+ The class is a swift wrapper around the C implementation for SMIME. It implements S/MIME ver 3.2 (RFC5751). S/MIME 4 isn't supported yet because OpenSSL currently does not support GCM mode for S/MIME encryption
  */
 class SMIME {
+    // patterns used for extraction of keys and certs from PEMs
     private let privateKeyPattern = "[-]*BEGIN[a-zA-Z ]*PRIVATE KEY[-]*[a-zA-Z+/\n\r=0-9]*[-]*END[a-zA-Z ]*PRIVATE KEY[-]*"
     private let certificatePattern = "[-]*BEGIN[a-zA-Z ]* CERTIFICATE[-]*[a-zA-Z+/\n\r=0-9]*[-]*END[a-zA-Z ]* CERTIFICATE[-]*"
     
@@ -64,7 +65,7 @@ class SMIME {
         
         for cert in certs {
             let (fp, _, _) = getFingerprintFromPem(pem: cert)
-            // TODO Exception
+            
             if fp != nil {
                 keychain[fp!] = cert
                 fingerprints.append(fp!)
@@ -74,7 +75,6 @@ class SMIME {
         return fingerprints
     }
     
-    // TODO: importCertsForAddress
     func importCerts(certs: [String]) -> [String] {
         return importInKeychain(certs: certs.map({ (cert: String) -> String in
             return cert.extractPattern(pattern: certificatePattern).joined(separator: "\r\n")
@@ -155,36 +155,23 @@ class SMIME {
         return fp[0]
     }
     
-    let cryptoScheme = CryptoScheme.SMIME
-    
-    /*func testKeychain () {
-        resetKeychain()
-        
-        let cas = importCA(certs: [testCA])
-        let keys = importKeys(certsAndKeys: [test_key])
-        privateKeyKeychain["ownkey"]=keys[0]
-        let certs = importCerts(certs: [test_key_other])
-        
-        for ca in cas
-        {
-            print("\nCA FP ",ca, " \nPEM \n", CAKeychain[ca]!)
-        }
-        for c in certs
-        {
-           print("\nCERT FP ",c, " \nPEM \n", certsKeychain[c]!)
-        }
-        for k in keys
-        {
-           print("\nPRIV FP ",k, " \nPEM \n", privateKeyKeychain[k]!)
-        }
-    }*/
-    
     func getOwnKeyFP() -> String? {
         return privateKeyKeychain["ownkey"]
     }
         
-    // Note: we ignore the Encryption interface because some things are built with PGP in mind and make no sense in the context of SMIME (signatureIDs for example)
-    func decrypt(data: Data, fromAddr: String, ownId:String, isMailNew: Bool) throws -> CryptoObject {
+    /**
+     Decrypts a message and verifies its signature.
+     
+     - returns: a `CryptoObject`, the `decryptedData` attribute contains the decrypted message
+     
+     - throws: `SMIMEError` decryption fails for whatever reason, the `errorArray` field can be iterated to print out the errors. See `getErrorReasonString()` and `getErrorString()`
+     
+     - parameters:
+        - data: the message to decrypt and verify as `Data`
+        - fromAddr: address of the sender
+        - isMailNew: used for the verification, see `SMIME.verify()`
+     */
+    func decrypt(data: Data, fromAddr: String, isMailNew: Bool) throws -> CryptoObject {
         var outputData: Data = data
         let text = String(data: data, encoding: .utf8)!
         var fp = getOwnKeyFP()
@@ -236,6 +223,18 @@ class SMIME {
         return CryptoObject(chiphertext: data, plaintext: plainText, decryptedData: decryptedData, sigState: sigState, encState: encState, signKey: signKey, encType: CryptoScheme.SMIME, signedAdrs: addresses, signedKeys: signedKeys)
     }
     
+    /**
+     Signs a message.
+     
+     - returns: a `CryptoObject`, the `ciphertext` attribute contains the signed message
+     
+     - throws: `SMIMEError` signing fails for whatever reason, the `errorArray` field can be iterated to print out the errors. See `getErrorReasonString()` and `getErrorString()`
+     
+     - parameters:
+        - plainData: the message to sign as `Data`
+        - myEmail: the current user's e-mail
+        - detached: if true, the signature is detached (`multipart/signed`); else not (`application/pkcs7-mime`)
+     */
     func sign(plainData: Data, myEmail: String, detached: Bool = true) throws -> CryptoObject {
         let fp = getOwnKeyFP()
         let cert = certsKeychain[fp!]!
@@ -253,12 +252,14 @@ class SMIME {
     }
     
     /**
-     Verifies the signature of a signed message. If multiple signatures are present, ALL need to be valid AND have a matching mail address, else the signature is invalid. The exceptions are in part modelled after the way OpenSSL deals with verification
+     Verifies the signature of a signed message. If multiple signatures are present, ALL need to be valid AND have a matching mail address, else the signature is invalid.
+     Previously unknown (not present in the keychain) but valid certificates are stored in the keychain.
     
-     - returns:
-        * SignatureState
-        * An array of (<fingerprint>, <pem>) tuples
-        * the verified string
+     - returns: a `CryptoObject` with all the information about the verification process
+     - parameters:
+        - data: the (signed) message to verify
+        - email: the e-mail of the sender
+        - isMailNew: if true and the certificate is unknown, the fingerprint of the certificate is mapped to the e-mail in the keychain so it can be used to encrypt future messages to the sender
      */
     func verify(data: Data, email: String, isMailNew: Bool) -> CryptoObject {
         var CAs : [String] = []
@@ -274,7 +275,6 @@ class SMIME {
             
             for error in errors {
                 let reason = getErrorReasonString(errCode: error)
-                print("reason:", reason)
                 // check reasons to identify different error causes
                 // string comaprison necessary because doesn't have fixed error codes...
                 if reason == "no content type" {
@@ -336,11 +336,28 @@ class SMIME {
         return CryptoObject(chiphertext: data, plaintext: verStr!, decryptedData: nil, sigState: sigState, encState: EncryptionState.NoEncryption, signKey: nil, encType: .SMIME, signedAdrs: signedAddresses, signedKeys: signKeyFps)
     }
     
+    /**
+     Encrypts and signs a message. Signing isn't optional.
+     
+     - parameters:
+        - plainData: a `Data` object that contains the string to encrypt
+        - ids: an array with the e-mails of all users that need to be able to decrypt this. They need to have their certificates imported with `importCertForAddress(cert, addr)` beforehand
+        - ownAddr: the e-mail of the user of the app, only needed for the CryptoObject
+        - encryptForMyId: if true, message is also encrypted for the sender
+     
+     - returns: a `CryptoObject` with all needed information
+    
+     -  throws: `SMIMEError` if:
+        * any of the e-mails in `ids` doesn't have a certificate registered in the keychain (see `importCertForAddress(cert, addr)`)
+        * can't sign because the user doesn't have a private key
+        * if encryption or signing failsfor any other reason
+        the `errorArray` field can be iterated to print out the errors. See `getErrorReasonString()` and `getErrorString()`
+     */
     func encrypt(plainData: Data, ids: [String], ownAddr: String, encryptForMyId: Bool = true) throws -> CryptoObject {
         let plainText = String(data: plainData, encoding: .utf8)
-        var (sigText, sigErrArr): (String?, [UInt]?) = (nil, nil)
         var pems: [String] = []
         let ownFp: String? = getOwnKeyFP()
+        var sigText: String? = nil
         
         // retrieve the certs as pems for each ID (email), certsKeychain stores for each email a fingerprint of the cert of that user and under a fingerprint a cert is stored
         for id in ids {
@@ -364,13 +381,15 @@ class SMIME {
         
         // check if the user has a certificate
         if ownFp != nil {
-            let ownCert = certsKeychain[ownFp!]!
-            let ownPk = privateKeyKeychain[ownFp!]!
-            (sigText, sigErrArr) = signWithPem(message: plainText!, certAsPem: ownCert, keyAsPem: ownPk, detached: false)
-            
-            if sigErrArr != nil && sigErrArr!.count > 0 {
-                throw SMIMEError(message: "Signing during encryption failed!", errorArray: sigErrArr, type: SMIMEError.ErrorType.signing)
+            var signObj: CryptoObject? = nil
+            do {
+                signObj = try sign(plainData: plainData, myEmail: ownAddr, detached: false)
+            } catch let error {
+                throw error
             }
+
+            // reminder: signObj can't be nil here b/c we always get it unless we get an exception (and exceptions get instantly re-thrown)
+            sigText = String(data: signObj!.chiphertext!, encoding: .utf8)
         } else {
             throw SMIMEError(message: "Tried to sign with user's certificate but none was present!", errorArray: nil, type: SMIMEError.ErrorType.other)
         }
@@ -384,133 +403,92 @@ class SMIME {
         
         return CryptoObject(chiphertext: encStr!.data(using: .utf8), plaintext: plainText, decryptedData: plainData, sigState: SignatureState.ValidSignature, encState: EncryptionState.ValidedEncryptedWithCurrentKey, signKey: ownFp, encType: CryptoScheme.SMIME, signedAdrs: [ownAddr])
     }
-}
 
-enum ResultAttribute {
-    case certificates
-    case errors
-    case output
-    case fingerprints
-}
-
-// TODO: Bring all C struct extensions to the same file
-
-/**
- A structure returned by the C crypto functions
- 
- This is not intended to be used outside of the SMIME library for letterbox. Look at the encryption/decryption functions for example usages
- */
-extension result {
     /**
-    Extracts an array of certs in PEM of the respective function from the result object
-    Deallocates the "errors" part of the result object
-    Only use in combination with_extractOutput and _extractErrors
-    */
-    private func extractStringArray(attrType: ResultAttribute) -> [String]? {
-        let arr: UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>?
-        switch (attrType) {
-        case .certificates:
-            arr = self.certs
-        case .fingerprints:
-            arr = self.fingerprints
-        default:
-            // TODO: Exceptions
-            return nil
-        }
-        var strArr: [String]? = nil
-        
-        if arr != nil {
-            strArr = []
-            let size = self.num_certs
-            for i in 0..<size {
-                let str = String(cString: arr![Int(i)]!)
-                strArr?.append(str)
-            }
+     A wrapper for the C function for encryption. Takes care of memory managment. Only meant tobe used as a helper in the SMIME class.
+     */
+    private func encryptWithPem(message: String,certPems: [String]) -> (String?, [UInt]?) {
+        let cCertsArray = createCStrArr(sarr: certPems)
+        let enc = OpenSSL_encrypt(message, cCertsArray, Int32(certPems.count))
+        defer {
+            deallocateResult(res: enc)
         }
         
-        return strArr
+        let result = enc?.pointee;
+        
+        let encStr: String? = result?.extractField(field: ResultAttribute.output)
+        let errArr: [UInt]? = result?.extractField(field: ResultAttribute.errors)
+        
+        return (encStr, errArr)
     }
-
+    
     /**
-    Extracts an array of errors of the respective function from the result object
-    Deallocates the "errors" part of the result object
-    Only use in combination with_extractOutput
-    */
-    private func extractErrors() -> [UInt]? {
-        let arr = self.errors
-        var errArr: [UInt]? = nil
-        
-        if arr != nil {
-            errArr = []
-            let size = self.num_errors
-            for i in 0..<size {
-                errArr?.append(arr![Int(i)])
-            }
+     A wrapper for the C function for decryption. Takes care of memory managment. Only meant tobe used as a helper in the SMIME class.
+     */
+    private func decryptWithPem(message:String, certAsPem: String, keyAsPem:String) -> (String?, [UInt]?) {
+        let dec = OpenSSL_decrypt(message, certAsPem, keyAsPem)
+        defer {
+            deallocateResult(res: dec)
         }
+        let result = dec?.pointee;
+        
+        let decStr: String? = result?.extractField(field: ResultAttribute.output)
+        let errArr: [UInt]? = result?.extractField(field: ResultAttribute.errors)
         
-        return errArr
+        return (decStr, errArr)
     }
     
     /**
-    Extracts the output of the respective function from the result object
-    Deallocates the "res" part of the result object
-    Only use in combination with_extractErrors
+     A wrapper for the C function for signing. Takes care of memory managment. Only meant tobe used as a helper in the SMIME class.
      */
-    private func extractOutput() -> String? {
-         let cStr = self.res
-         
-         var swiftStr: String? = nil
-         
-         if cStr != nil {
-             swiftStr = String(cString: cStr!)
-         }
-         
-         return swiftStr
-    }
+    private func signWithPem(message:String, certAsPem: String, keyAsPem:String, detached:Bool) -> (String?, [UInt]?) {
+        var detFlag : Int32 = 0
+        if detached {
+            detFlag = 1
+        }
         
-    /**
-     A generic function that reads a field and casts it to the type of the variable that stores the result. The variable must therefore have the correct type. Look at encrypWithPem() for example usage
-     
-     - parameters:
-        - field: enum, specifiying the field to extract
-     */
-    func extractField<T>(field: ResultAttribute) -> T? {
-        switch field {
-        case .certificates:
-            fallthrough
-        case .fingerprints:
-            let res = self.extractStringArray(attrType: field)
-            if res is T? {
-                return res as! T?
-            }
-            break
-        case .errors:
-            let res = self.extractErrors()
-            if res is T? {
-                return res as! T?
-            }
-        case .output:
-            let res = self.extractOutput()
-            if res is T? {
-                return res as! T?
-            }
+        let sig = OpenSSL_sign(message, certAsPem, keyAsPem, detFlag)
+        defer {
+            deallocateResult(res: sig)
         }
         
-        // TODO: exception
-        return nil
+        let result = sig?.pointee
+        
+        let sigStr: String? = result?.extractField(field: ResultAttribute.output)
+        let errArr: [UInt]? = result?.extractField(field: ResultAttribute.errors)
+        
+        return (sigStr, errArr)
     }
-}
 
-extension String {
-    func extractPattern(pattern: String) -> [String]{
-        let range = NSRange(location: 0, length: self.utf16.count)
-        let regex = try! NSRegularExpression(pattern: pattern)
-        let check = regex.matches(in: self, options: [], range: range)
-        var foundLinks:[String] = []
-        for match in check{
-            guard let range = Range(match.range, in: self) else {continue}
-            foundLinks.append(String(self[range]))
+    /**
+     A wrapper for the C function for verification. Takes care of memory managment. Only meant to be used as a helper in the SMIME class.
+    */
+    private func verifyWithCApem (message:String, pemCAArr: [String]) -> (String?, [(String, String)]?, [UInt]?) {
+        let pemCAArrC = createCStrArr(sarr: pemCAArr)
+        let ver = OpenSSL_verify(message, pemCAArrC, Int32(pemCAArr.count))
+        
+        defer {
+            deallocateResult(res: ver)
         }
-        return (foundLinks)
+        
+        deallocateCStrArr(arr: pemCAArrC, len:pemCAArr.count)
+        
+        let result = ver?.pointee;
+        
+        let verStr: String? = result?.extractField(field: ResultAttribute.output)
+        let errArr: [UInt]? = result?.extractField(field: ResultAttribute.errors)
+        let certArr: [String]? = result?.extractField(field: ResultAttribute.certificates)
+        let fpArr: [String]? = result?.extractField(field: ResultAttribute.fingerprints)
+        
+        let numCerts = Int((result?.num_certs)!)
+        var certFPArr: [(String, String)] = []
+        
+        if (numCerts > 0) {
+            for i in 0...(numCerts-1) {
+                certFPArr.append( ((fpArr?[i])!, (certArr?[i])!) )
+            }
+        }
+        
+        return (verStr, certFPArr, errArr)
     }
 }
diff --git a/enzevalos_iphone/SMIMEHelpers.swift b/enzevalos_iphone/SMIMEHelpers.swift
index 03874305dbedc7ae74039603f2b57d96f9c8506a..8f3ba675073f71cf7a1f68f331d8e58a4b56e096 100644
--- a/enzevalos_iphone/SMIMEHelpers.swift
+++ b/enzevalos_iphone/SMIMEHelpers.swift
@@ -39,87 +39,6 @@ class SMIMEError : Error {
     }
 }
 
-func encryptWithPem(message: String,certPems: [String]) -> (String?, [UInt]?) {
-    let cCertsArray = createCStrArr(sarr: certPems)
-    let enc = OpenSSL_encrypt(message, cCertsArray, Int32(certPems.count))
-    defer {
-        deallocateResult(res: enc)
-    }
-    
-    let result = enc?.pointee;
-    
-    let encStr: String? = result?.extractField(field: ResultAttribute.output)
-    let errArr: [UInt]? = result?.extractField(field: ResultAttribute.errors)
-    
-    return (encStr, errArr)
-}
-
-func decryptWithPem(message:String, certAsPem: String, keyAsPem:String) -> (String?, [UInt]?) {
-    let dec = OpenSSL_decrypt(message, certAsPem, keyAsPem)
-    defer {
-        deallocateResult(res: dec)
-    }
-    let result = dec?.pointee;
-    
-    let decStr: String? = result?.extractField(field: ResultAttribute.output)
-    let errArr: [UInt]? = result?.extractField(field: ResultAttribute.errors)
-    
-    return (decStr, errArr)
-}
-
-func signWithPem(message:String, certAsPem: String, keyAsPem:String, detached:Bool) -> (String?, [UInt]?) {
-    var detFlag : Int32 = 0
-    if detached {
-        detFlag = 1
-    }
-    
-    let sig = OpenSSL_sign(message, certAsPem, keyAsPem, detFlag)
-    defer {
-        deallocateResult(res: sig)
-    }
-    
-    let result = sig?.pointee
-    
-    let sigStr: String? = result?.extractField(field: ResultAttribute.output)
-    let errArr: [UInt]? = result?.extractField(field: ResultAttribute.errors)
-    
-    return (sigStr, errArr)
-}
-
-
-/**
-    when the signature can't be verified with the present certs: verStr = nil, numCerts = 0, error code: 772378724
-    when no signature present, there's error reason "no content type"
- */
-func verifyWithCApem (message:String, pemCAArr: [String]) -> (String?, [(String, String)]?, [UInt]?) {
-    let pemCAArrC = createCStrArr(sarr: pemCAArr)
-    let ver = OpenSSL_verify(message, pemCAArrC, Int32(pemCAArr.count))
-    
-    defer {
-        deallocateResult(res: ver)
-    }
-    
-    deallocateCStrArr(arr: pemCAArrC, len:pemCAArr.count)
-    
-    let result = ver?.pointee;
-    
-    let verStr: String? = result?.extractField(field: ResultAttribute.output)
-    let errArr: [UInt]? = result?.extractField(field: ResultAttribute.errors)
-    let certArr: [String]? = result?.extractField(field: ResultAttribute.certificates)
-    let fpArr: [String]? = result?.extractField(field: ResultAttribute.fingerprints)
-    
-    let numCerts = Int((result?.num_certs)!)
-    var certFPArr: [(String, String)] = []
-    
-    if (numCerts > 0) {
-        for i in 0...(numCerts-1) {
-            certFPArr.append( ((fpArr?[i])!, (certArr?[i])!) )
-        }
-    }
-    
-    return (verStr, certFPArr, errArr)
-}
-
 
 /**
  Returns a fingerprint hash of a certificate given a PEM
@@ -234,3 +153,132 @@ func deallocateResult(res: UnsafeMutablePointer<result>?) {
 func deallocateCertInfo(certInfo: UnsafeMutablePointer<cert_info>?) {
     deallocate_cert_info(certInfo)
 }
+
+enum ResultAttribute {
+    case certificates
+    case errors
+    case output
+    case fingerprints
+}
+
+// TODO: Bring all C struct extensions to the same file
+
+/**
+ A structure returned by the C crypto functions
+ 
+ This is not intended to be used outside of the SMIME library for letterbox. Look at the encryption/decryption functions for example usages
+ */
+extension result {
+    /**
+    Extracts an array of certs in PEM of the respective function from the result object
+    Deallocates the "errors" part of the result object
+    Only use in combination with_extractOutput and _extractErrors
+    */
+    private func extractStringArray(attrType: ResultAttribute) -> [String]? {
+        let arr: UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>?
+        switch (attrType) {
+        case .certificates:
+            arr = self.certs
+        case .fingerprints:
+            arr = self.fingerprints
+        default:
+            // TODO: Exceptions
+            return nil
+        }
+        var strArr: [String]? = nil
+        
+        if arr != nil {
+            strArr = []
+            let size = self.num_certs
+            for i in 0..<size {
+                let str = String(cString: arr![Int(i)]!)
+                strArr?.append(str)
+            }
+        }
+        
+        return strArr
+    }
+
+    /**
+    Extracts an array of errors of the respective function from the result object
+    Deallocates the "errors" part of the result object
+    Only use in combination with_extractOutput
+    */
+    private func extractErrors() -> [UInt]? {
+        let arr = self.errors
+        var errArr: [UInt]? = nil
+        
+        if arr != nil {
+            errArr = []
+            let size = self.num_errors
+            for i in 0..<size {
+                errArr?.append(arr![Int(i)])
+            }
+        }
+        
+        return errArr
+    }
+    
+    /**
+    Extracts the output of the respective function from the result object
+    Deallocates the "res" part of the result object
+    Only use in combination with_extractErrors
+     */
+    private func extractOutput() -> String? {
+         let cStr = self.res
+         
+         var swiftStr: String? = nil
+         
+         if cStr != nil {
+             swiftStr = String(cString: cStr!)
+         }
+         
+         return swiftStr
+    }
+        
+    /**
+     A generic function that reads a field and casts it to the type of the variable that stores the result. The variable must therefore have the correct type. Look at encrypWithPem() for example usage
+     
+     - parameters:
+        - field: enum, specifiying the field to extract
+     */
+    func extractField<T>(field: ResultAttribute) -> T? {
+        switch field {
+        case .certificates:
+            fallthrough
+        case .fingerprints:
+            let res = self.extractStringArray(attrType: field)
+            if res is T? {
+                return res as! T?
+            }
+            break
+        case .errors:
+            let res = self.extractErrors()
+            if res is T? {
+                return res as! T?
+            }
+        case .output:
+            let res = self.extractOutput()
+            if res is T? {
+                return res as! T?
+            }
+        }
+        
+        // TODO: exception
+        return nil
+    }
+}
+
+extension String {
+    func extractPattern(pattern: String) -> [String]{
+        let range = NSRange(location: 0, length: self.utf16.count)
+        let regex = try! NSRegularExpression(pattern: pattern)
+        let check = regex.matches(in: self, options: [], range: range)
+        var foundLinks:[String] = []
+        for match in check{
+            guard let range = Range(match.range, in: self) else {continue}
+            foundLinks.append(String(self[range]))
+        }
+        return (foundLinks)
+    }
+}
diff --git a/enzevalos_iphone/SwiftUI/Inbox/Inbox.swift.orig b/enzevalos_iphone/SwiftUI/Inbox/Inbox.swift.orig
new file mode 100644
index 0000000000000000000000000000000000000000..e735bbcc75bfecca40523976277a64de9340b638
--- /dev/null
+++ b/enzevalos_iphone/SwiftUI/Inbox/Inbox.swift.orig
@@ -0,0 +1,145 @@
+//
+//  Inbox.swift
+//  enzevalos_iphone
+//
+//  Created by Oliver Wiese on 01.03.20.
+//  Copyright © 2020 fu-berlin. All rights reserved.
+//
+
+import SwiftUI
+
+struct Inbox: View {
+    @Environment(\.managedObjectContext) var managedObjectContext
+    @FetchRequest(fetchRequest: KeyRecord.allRecordsFetchRequest(in: Folder.inbox)) var keyrecords: FetchedResults<KeyRecord>
+    
+    @ObservedObject var folder = Folder.inbox
+    
+    @State var updating = false
+    @State var showUser = false
+    @State var searchText = ""
+    @State var searchField = 0
+    @State var searchNow = false
+    
+    let coord: InboxCoordinator
+    
+    var body: some View {
+        VStack{
+            SearchView(searchText: $searchText, searchField: $searchField, searchNow: $searchNow)
+               .padding(6)
+            // Mails
+            mailList
+            // Toolbar
+            HStack {
+                self.idButton
+                Spacer()
+                self.lastUpdate
+                Spacer()
+                self.composeButton
+            }
+            .padding(6)
+        }
+        .navigationBarTitle(NSLocalizedString("Inbox", comment: "Inbox"))
+        .navigationBarItems(leading: self.folderButton)
+    }
+    
+    private var mailList: some View {
+        List (self.keyrecords.filter(filterKeyRecord), id: \.self){
+            record in
+<<<<<<< HEAD
+                KeyRecordRow(keyrecord: record, coord: self.coord)
+=======
+            KeyRecordRow(keyrecord: record, coord: self.coord).environment(\.managedObjectContext, self.managedObjectContext)
+>>>>>>> dev
+       }
+       .resignKeyboardOnDragGesture() // hide keyboard when dragging
+    }
+        
+    private var folderButton: some View {
+        Button(action: self.coord.pushFoldersView, label: {
+            Text(NSLocalizedString("Folders", comment: "Folder"))
+        })
+    }
+    
+    private var idButton: some View {
+        Button(action: {
+            self.coord.pushRecordView(record: self.userRecord)
+        }, label: {
+            Text(NSLocalizedString("KeyID", comment: "id"))
+        })
+    }
+    
+    private var composeButton: some View {
+        Button(action: self.coord.pushComposeView, label: {
+            Image(systemName: "message").imageScale(.large)
+        })
+    }
+    
+    private var lastUpdate: some View {
+        var text = NSLocalizedString("Updating", comment: "updating...")
+        if !updating {
+            if let last = Folder.inbox.lastUpdate {
+               let dateFormatter = DateFormatter()
+                dateFormatter.locale = Locale.current
+                dateFormatter.timeStyle = .medium
+                let dateString = dateFormatter.string(from: last)
+                text = NSLocalizedString("LastUpdate", comment: "") + " " + dateString
+            }
+            else {
+                text = NSLocalizedString("NeverUpdated", comment: "no upates...")
+            }
+        }
+        return Button(action: updateMails, label: {Text(text)
+            .font(.callout)
+
+        })
+    }
+    
+    var userRecord: KeyRecord {
+           get {
+               let keyID = UserManager.loadUserValue(Attribute.prefSecretKeyID) as? String
+               let addr = UserManager.loadUserValue(Attribute.userAddr) as! String
+               return DataHandler.handler.getKeyRecord(addr: addr, keyID: keyID)
+           }
+       }
+       
+       func updateMails() {
+           guard !updating else {
+               return
+           }
+           AppDelegate.getAppDelegate().mailHandler.updateFolder(folder: Folder.inbox, completionCallback: {_ in
+               self.updating = false
+           })
+           updating = true
+       }
+       
+       func filterKeyRecord(keyRecord: KeyRecord) -> Bool {
+           let searchType = SearchType.findType(i: searchField)
+           if self.searchText.isEmpty || self.searchText == NSLocalizedString("Searchbar.Title", comment: "Search") {
+               return true
+           }
+           let query = self.searchText.lowercased()
+           if (searchType == .All || searchType == .Sender) && containsSearchTerms(content: keyRecord.name, searchText: query){
+               return true
+           }
+           else if (searchType == .All || searchType == .Sender) && keyRecord.addresses.filter({containsSearchTerms(content: $0.mailAddress, searchText: query)}).count > 0 {
+               return true
+           }
+           else if (searchType == .All || searchType == .Subject) && keyRecord.mails.filter({containsSearchTerms(content: $0.subject, searchText: query)}).count > 0 {
+               return true
+               }
+           else if (searchType == .All || searchType == .Body) && keyRecord.mails.filter({containsSearchTerms(content: $0.body, searchText: query)}).count > 0 {
+               return true
+           }
+           return false
+       }
+}
+
+
+
+/*
+struct Inbox_Previews: PreviewProvider {
+    static var previews: some View {
+        Inbox()
+    }
+}
+ */
diff --git a/enzevalos_iphone/SwiftUI/Inbox/InboxCoordinator.swift.orig b/enzevalos_iphone/SwiftUI/Inbox/InboxCoordinator.swift.orig
new file mode 100644
index 0000000000000000000000000000000000000000..74fd5b458e9625c67404053aa56bf616fc74a6a6
--- /dev/null
+++ b/enzevalos_iphone/SwiftUI/Inbox/InboxCoordinator.swift.orig
@@ -0,0 +1,94 @@
+//
+//  InboxCoordinator.swift
+//  enzevalos_iphone
+//
+//  Created by Oliver Wiese on 04.03.20.
+//  Copyright © 2020 fu-berlin. All rights reserved.
+//
+
+import Foundation
+import SwiftUI
+
+class InboxCoordinator {
+    let root: UINavigationController
+    
+    private let mainStoryboardName = "Main"
+    private let mainStoryboard: UIStoryboard
+    private var inbox: UIViewController?
+
+    
+    init(root: UINavigationController) {
+        self.root = root
+        mainStoryboard = UIStoryboard(name: self.mainStoryboardName, bundle: nil)
+    }
+    
+    func pushInbox(){
+        try? AppDelegate.getAppDelegate().mailHandler.startIMAPIdleIfSupported()
+        AppDelegate.getAppDelegate().mailHandler.updateFolder(folder: Folder.inbox, completionCallback: {_ in
+        })
+        
+        root.isToolbarHidden = true
+
+        if let vc = inbox {
+            if root.viewControllers.contains(vc) {
+                while root.topViewController != vc {
+                    root.popViewController(animated: true)
+                }
+            } else {
+                root.pushViewController(vc, animated: true)
+            }
+        }
+        else {
+            let context = DataHandler.handler.managedObjectContext
+<<<<<<< HEAD
+            let vc = UIHostingController(rootView: Inbox(coord: self).environment(\.managedObjectContext,context))
+=======
+            let vc = UIHostingController(rootView: Inbox(coord: self).environment(\.managedObjectContext, context))
+>>>>>>> dev
+            inbox = vc
+            root.pushViewController(vc, animated: true)
+        }
+    }
+
+    func pushFoldersView() {
+        let controller = mainStoryboard.instantiateViewController(withIdentifier: ViewID.FoldersView.rawValue)
+        root.isToolbarHidden = false
+        root.pushViewController(controller, animated: true)
+    }
+    
+    func pushReadView(mail: PersistentMail) {
+        let vc = mainStoryboard.instantiateViewController(withIdentifier: ViewID.ReadView.rawValue)
+        if let vc = vc as? ReadViewController {
+            vc.mail = mail
+        }
+        root.isToolbarHidden = false
+        root.pushViewController(vc, animated: true)
+    }
+    
+    func pushRecordView(record: KeyRecord){
+        let vc = mainStoryboard.instantiateViewController(withIdentifier: ViewID.KeyRecordView.rawValue)
+        if let vc = vc as? ContactViewController {
+            vc.keyRecord = record
+        }
+        root.isToolbarHidden = false
+        root.pushViewController(vc, animated: true)
+    }
+    
+    func pushComposeView() {
+        let vc = mainStoryboard.instantiateViewController(identifier: ViewID.ComposeView.rawValue)
+        if let vc = vc as? SendViewController {
+            vc.wasPushed = true
+        }
+        root.isToolbarHidden = false
+        root.pushViewController(vc, animated: true)
+    }
+    
+    func pushMailListView(record: KeyRecord) {
+        let vc = mainStoryboard.instantiateViewController(identifier: ViewID.MailListView.rawValue)
+        if let vc = vc as? ListViewController {
+            vc.contact = record
+        }
+        root.isToolbarHidden = false
+        root.pushViewController(vc, animated: true)
+    }
+}
diff --git a/enzevalos_iphone/SwiftUI/Inbox/KeyRecordRow.swift.orig b/enzevalos_iphone/SwiftUI/Inbox/KeyRecordRow.swift.orig
new file mode 100644
index 0000000000000000000000000000000000000000..2ddd602992c56f7b8d556d2a10bc670804ddec3c
--- /dev/null
+++ b/enzevalos_iphone/SwiftUI/Inbox/KeyRecordRow.swift.orig
@@ -0,0 +1,150 @@
+//
+//  KeyRecordRow.swift
+//  enzevalos_iphone
+//
+//  Created by Oliver Wiese on 02.03.20.
+//  Copyright © 2020 fu-berlin. All rights reserved.
+//
+
+import SwiftUI
+
+struct KeyRecordRow: View {
+<<<<<<< HEAD
+    @ObservedObject var keyrecord: KeyRecord
+    let coord: InboxCoordinator
+    
+=======
+    @Environment(\.managedObjectContext) var managedObjectContext
+
+    var keyrecord: KeyRecord
+    let coord: InboxCoordinator
+    
+    var fetchRequest: FetchRequest<PersistentMail>
+    var mails: FetchedResults<PersistentMail> {
+        fetchRequest.wrappedValue
+    }
+
+    init(keyrecord: KeyRecord, coord: InboxCoordinator) {
+        self.keyrecord = keyrecord
+        self.coord = coord
+        let pred = NSPredicate(format: "record == %@", keyrecord)
+        let folderPredicate = NSPredicate(format: "folder == %@", Folder.inbox)
+        let predicates = NSCompoundPredicate(andPredicateWithSubpredicates: [pred, folderPredicate])
+        let sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)]
+        fetchRequest = FetchRequest<PersistentMail>(entity: PersistentMail.entity(), sortDescriptors: sortDescriptors, predicate: predicates, animation: nil)
+    }
+    
+    
+>>>>>>> dev
+    var body: some View {
+        VStack {
+            HStack(alignment: .lastTextBaseline) {
+                icon
+                Spacer()
+                mailListView()
+                .offset(y: -10)
+            }
+            HStack {
+                name
+                Spacer()
+                moreMails
+            }
+        }
+    }
+    
+<<<<<<< HEAD
+=======
+    var secondMail: PersistentMail?{
+        if mails.count > 1 {
+            return mails[2]
+        }
+        return nil
+    }
+    
+>>>>>>> dev
+    /*
+     Displays the first (and second) mail
+     */
+    private func mailListView() -> AnyView {
+        let spacing = CGFloat(10)
+        let offset = -(spacing / 2)
+        
+<<<<<<< HEAD
+        if let first = self.keyrecord.firstMail {
+            if let second = self.keyrecord.secondMail {
+                return AnyView(VStack(alignment: .leading, spacing: spacing) {
+                        MailView(mail: first, coord: coord)
+                        MailView(mail: second, coord: coord)
+=======
+        if let first = mails.first {
+            if mails.count > 1 {
+                return AnyView(VStack(alignment: .leading, spacing: spacing) {
+                        MailView(mail: first, coord: coord)
+                        MailView(mail: mails[1], coord: coord)
+>>>>>>> dev
+                        .background(Stroke(offsetY: offset))
+                })
+            } else {
+                return AnyView(VStack(alignment: .leading,spacing: spacing) {
+                    MailView(mail: first, coord: coord)
+                    Text(NSLocalizedString("NoFurtherMessages", comment: "No more Mails"))
+                    .background(Stroke(offsetY: offset))
+                })
+            }
+        } else {
+            return AnyView(Text("NO MAILS..."))
+        }
+    }
+    
+    private var icon: some View{
+        self.keyrecord.image.img
+            .resizable()
+            .frame(width: 60, height: 60)
+            .shadow(radius: 5)
+            .onTapGesture {
+                self.coord.pushRecordView(record: self.keyrecord)
+        }
+    }
+    
+    private var name: some View {
+        Text(self.keyrecord.myNick)
+            .frame(maxWidth: 300, alignment: .leading)
+            .lineLimit(1)
+            .onTapGesture {
+                self.coord.pushRecordView(record: self.keyrecord)
+        }
+    }
+    
+    private var moreMails: some View {
+        Button(action: {
+            self.coord.pushMailListView(record: self.keyrecord)
+        }, label: {
+            Text(NSLocalizedString("MailView.MoreMails", comment: "More mails"))
+            .foregroundColor(.gray)
+        })
+    }
+}
+
+
+extension KeyRecord {
+<<<<<<< HEAD
+=======
+    
+>>>>>>> dev
+    public var firstMail: PersistentMail? {
+        get {
+            return mails.first
+        }
+    }
+    
+    public var secondMail: PersistentMail? {
+        get {
+            if mails.count > 1 {
+                return mails[1]
+            }
+            return nil
+        }
+    }
+}
+
+
diff --git a/enzevalos_iphoneTests/GeneratedMocks.swift b/enzevalos_iphoneTests/GeneratedMocks.swift
index 9aad2c9cde713fb651b74a3a03b2ded3943c8b53..f82a6cb77fc10a62ea9f44d33c7a1bb38807baf9 100644
--- a/enzevalos_iphoneTests/GeneratedMocks.swift
+++ b/enzevalos_iphoneTests/GeneratedMocks.swift
@@ -1,4 +1,4 @@
-// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationModel.swift at 2020-03-18 15:11:52 +0000
+// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationModel.swift at 2020-03-31 16:56:08 +0000
 
 //
 //  AuthenticationModel.swift
@@ -653,7 +653,7 @@ import Foundation
 }
 
 
-// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationViewModel.swift at 2020-03-18 15:11:52 +0000
+// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationViewModel.swift at 2020-03-31 16:56:08 +0000
 
 //
 //  AuthenticationViewModel.swift
diff --git a/enzevalos_iphoneTests/GeneratedMocks.swift.orig b/enzevalos_iphoneTests/GeneratedMocks.swift.orig
new file mode 100644
index 0000000000000000000000000000000000000000..cf5117324baf4c1b1874e58c100e08795b5a9c59
--- /dev/null
+++ b/enzevalos_iphoneTests/GeneratedMocks.swift.orig
@@ -0,0 +1,1094 @@
+<<<<<<< HEAD
+// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationModel.swift at 2020-03-31 15:54:34 +0000
+=======
+// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationModel.swift at 2020-03-18 15:11:52 +0000
+>>>>>>> dev
+
+//
+//  AuthenticationModel.swift
+//  enzevalos_iphone
+//
+//  Created by SWP Usable Security für Smartphones on 10.03.20.
+//  Copyright © 2020 fu-berlin. All rights reserved.
+//
+import Cuckoo
+@testable import enzevalos_iphone
+
+import Combine
+import Foundation
+
+
+ class MockAuthenticationModel: AuthenticationModel, Cuckoo.ClassMock {
+    
+     typealias MocksType = AuthenticationModel
+    
+     typealias Stubbing = __StubbingProxy_AuthenticationModel
+     typealias Verification = __VerificationProxy_AuthenticationModel
+
+     let cuckoo_manager = Cuckoo.MockManager.preconfiguredManager ?? Cuckoo.MockManager(hasParent: true)
+
+    
+    private var __defaultImplStub: AuthenticationModel?
+
+     func enableDefaultImplementation(_ stub: AuthenticationModel) {
+        __defaultImplStub = stub
+        cuckoo_manager.enableDefaultStubImplementation()
+    }
+    
+
+    
+    
+    
+     override var extendedValidation: Bool {
+        get {
+            return cuckoo_manager.getter("extendedValidation",
+                superclassCall:
+                    
+                    super.extendedValidation
+                    ,
+                defaultCall: __defaultImplStub!.extendedValidation)
+        }
+        
+        set {
+            cuckoo_manager.setter("extendedValidation",
+                value: newValue,
+                superclassCall:
+                    
+                    super.extendedValidation = newValue
+                    ,
+                defaultCall: __defaultImplStub!.extendedValidation = newValue)
+        }
+        
+    }
+    
+    
+    
+     override var imapCallback: AuthenticationCallback? {
+        get {
+            return cuckoo_manager.getter("imapCallback",
+                superclassCall:
+                    
+                    super.imapCallback
+                    ,
+                defaultCall: __defaultImplStub!.imapCallback)
+        }
+        
+        set {
+            cuckoo_manager.setter("imapCallback",
+                value: newValue,
+                superclassCall:
+                    
+                    super.imapCallback = newValue
+                    ,
+                defaultCall: __defaultImplStub!.imapCallback = newValue)
+        }
+        
+    }
+    
+    
+    
+     override var smtpCallback: AuthenticationCallback? {
+        get {
+            return cuckoo_manager.getter("smtpCallback",
+                superclassCall:
+                    
+                    super.smtpCallback
+                    ,
+                defaultCall: __defaultImplStub!.smtpCallback)
+        }
+        
+        set {
+            cuckoo_manager.setter("smtpCallback",
+                value: newValue,
+                superclassCall:
+                    
+                    super.smtpCallback = newValue
+                    ,
+                defaultCall: __defaultImplStub!.smtpCallback = newValue)
+        }
+        
+    }
+    
+    
+    
+     override var imapConfigurationSuccessful: Bool {
+        get {
+            return cuckoo_manager.getter("imapConfigurationSuccessful",
+                superclassCall:
+                    
+                    super.imapConfigurationSuccessful
+                    ,
+                defaultCall: __defaultImplStub!.imapConfigurationSuccessful)
+        }
+        
+        set {
+            cuckoo_manager.setter("imapConfigurationSuccessful",
+                value: newValue,
+                superclassCall:
+                    
+                    super.imapConfigurationSuccessful = newValue
+                    ,
+                defaultCall: __defaultImplStub!.imapConfigurationSuccessful = newValue)
+        }
+        
+    }
+    
+    
+    
+     override var smtpConfigurationSuccessful: Bool {
+        get {
+            return cuckoo_manager.getter("smtpConfigurationSuccessful",
+                superclassCall:
+                    
+                    super.smtpConfigurationSuccessful
+                    ,
+                defaultCall: __defaultImplStub!.smtpConfigurationSuccessful)
+        }
+        
+        set {
+            cuckoo_manager.setter("smtpConfigurationSuccessful",
+                value: newValue,
+                superclassCall:
+                    
+                    super.smtpConfigurationSuccessful = newValue
+                    ,
+                defaultCall: __defaultImplStub!.smtpConfigurationSuccessful = newValue)
+        }
+        
+    }
+    
+    
+    
+     override var dispatchGroup: DispatchGroup {
+        get {
+            return cuckoo_manager.getter("dispatchGroup",
+                superclassCall:
+                    
+                    super.dispatchGroup
+                    ,
+                defaultCall: __defaultImplStub!.dispatchGroup)
+        }
+        
+        set {
+            cuckoo_manager.setter("dispatchGroup",
+                value: newValue,
+                superclassCall:
+                    
+                    super.dispatchGroup = newValue
+                    ,
+                defaultCall: __defaultImplStub!.dispatchGroup = newValue)
+        }
+        
+    }
+    
+
+    
+
+    
+    
+    
+     override func checkConfig(mailAccount: MailAccount, extendedValidation: Bool) -> Future<AuthenticationResult, Never> {
+        
+    return cuckoo_manager.call("checkConfig(mailAccount: MailAccount, extendedValidation: Bool) -> Future<AuthenticationResult, Never>",
+            parameters: (mailAccount, extendedValidation),
+            escapingParameters: (mailAccount, extendedValidation),
+            superclassCall:
+                
+                super.checkConfig(mailAccount: mailAccount, extendedValidation: extendedValidation)
+                ,
+            defaultCall: __defaultImplStub!.checkConfig(mailAccount: mailAccount, extendedValidation: extendedValidation))
+        
+    }
+    
+    
+    
+     override func checkIMAPConfig(mailAccount: MailAccount, _ callback: AuthenticationCallback)  {
+        
+    return cuckoo_manager.call("checkIMAPConfig(mailAccount: MailAccount, _: AuthenticationCallback)",
+            parameters: (mailAccount, callback),
+            escapingParameters: (mailAccount, callback),
+            superclassCall:
+                
+                super.checkIMAPConfig(mailAccount: mailAccount, callback)
+                ,
+            defaultCall: __defaultImplStub!.checkIMAPConfig(mailAccount: mailAccount, callback))
+        
+    }
+    
+    
+    
+     override func checkSMTPConfig(mailAccount: MailAccount, _ callback: AuthenticationCallback)  {
+        
+    return cuckoo_manager.call("checkSMTPConfig(mailAccount: MailAccount, _: AuthenticationCallback)",
+            parameters: (mailAccount, callback),
+            escapingParameters: (mailAccount, callback),
+            superclassCall:
+                
+                super.checkSMTPConfig(mailAccount: mailAccount, callback)
+                ,
+            defaultCall: __defaultImplStub!.checkSMTPConfig(mailAccount: mailAccount, callback))
+        
+    }
+    
+    
+    
+     override func onTimeout(timeoutResult: DispatchTimeoutResult) -> AuthenticationResult {
+        
+    return cuckoo_manager.call("onTimeout(timeoutResult: DispatchTimeoutResult) -> AuthenticationResult",
+            parameters: (timeoutResult),
+            escapingParameters: (timeoutResult),
+            superclassCall:
+                
+                super.onTimeout(timeoutResult: timeoutResult)
+                ,
+            defaultCall: __defaultImplStub!.onTimeout(timeoutResult: timeoutResult))
+        
+    }
+    
+    
+    
+     override func onImapCompleted(imapWorks: Bool, _ login: String, _ password: String)  {
+        
+    return cuckoo_manager.call("onImapCompleted(imapWorks: Bool, _: String, _: String)",
+            parameters: (imapWorks, login, password),
+            escapingParameters: (imapWorks, login, password),
+            superclassCall:
+                
+                super.onImapCompleted(imapWorks: imapWorks, login, password)
+                ,
+            defaultCall: __defaultImplStub!.onImapCompleted(imapWorks: imapWorks, login, password))
+        
+    }
+    
+    
+    
+     override func onSmtpCompleted(smtpWorks: Bool, _ login: String, _ password: String)  {
+        
+    return cuckoo_manager.call("onSmtpCompleted(smtpWorks: Bool, _: String, _: String)",
+            parameters: (smtpWorks, login, password),
+            escapingParameters: (smtpWorks, login, password),
+            superclassCall:
+                
+                super.onSmtpCompleted(smtpWorks: smtpWorks, login, password)
+                ,
+            defaultCall: __defaultImplStub!.onSmtpCompleted(smtpWorks: smtpWorks, login, password))
+        
+    }
+    
+
+	 struct __StubbingProxy_AuthenticationModel: Cuckoo.StubbingProxy {
+	    private let cuckoo_manager: Cuckoo.MockManager
+	
+	     init(manager: Cuckoo.MockManager) {
+	        self.cuckoo_manager = manager
+	    }
+	    
+	    
+	    var extendedValidation: Cuckoo.ClassToBeStubbedProperty<MockAuthenticationModel, Bool> {
+	        return .init(manager: cuckoo_manager, name: "extendedValidation")
+	    }
+	    
+	    
+	    var imapCallback: Cuckoo.ClassToBeStubbedOptionalProperty<MockAuthenticationModel, AuthenticationCallback> {
+	        return .init(manager: cuckoo_manager, name: "imapCallback")
+	    }
+	    
+	    
+	    var smtpCallback: Cuckoo.ClassToBeStubbedOptionalProperty<MockAuthenticationModel, AuthenticationCallback> {
+	        return .init(manager: cuckoo_manager, name: "smtpCallback")
+	    }
+	    
+	    
+	    var imapConfigurationSuccessful: Cuckoo.ClassToBeStubbedProperty<MockAuthenticationModel, Bool> {
+	        return .init(manager: cuckoo_manager, name: "imapConfigurationSuccessful")
+	    }
+	    
+	    
+	    var smtpConfigurationSuccessful: Cuckoo.ClassToBeStubbedProperty<MockAuthenticationModel, Bool> {
+	        return .init(manager: cuckoo_manager, name: "smtpConfigurationSuccessful")
+	    }
+	    
+	    
+	    var dispatchGroup: Cuckoo.ClassToBeStubbedProperty<MockAuthenticationModel, DispatchGroup> {
+	        return .init(manager: cuckoo_manager, name: "dispatchGroup")
+	    }
+	    
+	    
+	    func checkConfig<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(mailAccount: M1, extendedValidation: M2) -> Cuckoo.ClassStubFunction<(MailAccount, Bool), Future<AuthenticationResult, Never>> where M1.MatchedType == MailAccount, M2.MatchedType == Bool {
+	        let matchers: [Cuckoo.ParameterMatcher<(MailAccount, Bool)>] = [wrap(matchable: mailAccount) { $0.0 }, wrap(matchable: extendedValidation) { $0.1 }]
+	        return .init(stub: cuckoo_manager.createStub(for: MockAuthenticationModel.self, method: "checkConfig(mailAccount: MailAccount, extendedValidation: Bool) -> Future<AuthenticationResult, Never>", parameterMatchers: matchers))
+	    }
+	    
+	    func checkIMAPConfig<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(mailAccount: M1, _ callback: M2) -> Cuckoo.ClassStubNoReturnFunction<(MailAccount, AuthenticationCallback)> where M1.MatchedType == MailAccount, M2.MatchedType == AuthenticationCallback {
+	        let matchers: [Cuckoo.ParameterMatcher<(MailAccount, AuthenticationCallback)>] = [wrap(matchable: mailAccount) { $0.0 }, wrap(matchable: callback) { $0.1 }]
+	        return .init(stub: cuckoo_manager.createStub(for: MockAuthenticationModel.self, method: "checkIMAPConfig(mailAccount: MailAccount, _: AuthenticationCallback)", parameterMatchers: matchers))
+	    }
+	    
+	    func checkSMTPConfig<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(mailAccount: M1, _ callback: M2) -> Cuckoo.ClassStubNoReturnFunction<(MailAccount, AuthenticationCallback)> where M1.MatchedType == MailAccount, M2.MatchedType == AuthenticationCallback {
+	        let matchers: [Cuckoo.ParameterMatcher<(MailAccount, AuthenticationCallback)>] = [wrap(matchable: mailAccount) { $0.0 }, wrap(matchable: callback) { $0.1 }]
+	        return .init(stub: cuckoo_manager.createStub(for: MockAuthenticationModel.self, method: "checkSMTPConfig(mailAccount: MailAccount, _: AuthenticationCallback)", parameterMatchers: matchers))
+	    }
+	    
+	    func onTimeout<M1: Cuckoo.Matchable>(timeoutResult: M1) -> Cuckoo.ClassStubFunction<(DispatchTimeoutResult), AuthenticationResult> where M1.MatchedType == DispatchTimeoutResult {
+	        let matchers: [Cuckoo.ParameterMatcher<(DispatchTimeoutResult)>] = [wrap(matchable: timeoutResult) { $0 }]
+	        return .init(stub: cuckoo_manager.createStub(for: MockAuthenticationModel.self, method: "onTimeout(timeoutResult: DispatchTimeoutResult) -> AuthenticationResult", parameterMatchers: matchers))
+	    }
+	    
+	    func onImapCompleted<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable, M3: Cuckoo.Matchable>(imapWorks: M1, _ login: M2, _ password: M3) -> Cuckoo.ClassStubNoReturnFunction<(Bool, String, String)> where M1.MatchedType == Bool, M2.MatchedType == String, M3.MatchedType == String {
+	        let matchers: [Cuckoo.ParameterMatcher<(Bool, String, String)>] = [wrap(matchable: imapWorks) { $0.0 }, wrap(matchable: login) { $0.1 }, wrap(matchable: password) { $0.2 }]
+	        return .init(stub: cuckoo_manager.createStub(for: MockAuthenticationModel.self, method: "onImapCompleted(imapWorks: Bool, _: String, _: String)", parameterMatchers: matchers))
+	    }
+	    
+	    func onSmtpCompleted<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable, M3: Cuckoo.Matchable>(smtpWorks: M1, _ login: M2, _ password: M3) -> Cuckoo.ClassStubNoReturnFunction<(Bool, String, String)> where M1.MatchedType == Bool, M2.MatchedType == String, M3.MatchedType == String {
+	        let matchers: [Cuckoo.ParameterMatcher<(Bool, String, String)>] = [wrap(matchable: smtpWorks) { $0.0 }, wrap(matchable: login) { $0.1 }, wrap(matchable: password) { $0.2 }]
+	        return .init(stub: cuckoo_manager.createStub(for: MockAuthenticationModel.self, method: "onSmtpCompleted(smtpWorks: Bool, _: String, _: String)", parameterMatchers: matchers))
+	    }
+	    
+	}
+
+	 struct __VerificationProxy_AuthenticationModel: Cuckoo.VerificationProxy {
+	    private let cuckoo_manager: Cuckoo.MockManager
+	    private let callMatcher: Cuckoo.CallMatcher
+	    private let sourceLocation: Cuckoo.SourceLocation
+	
+	     init(manager: Cuckoo.MockManager, callMatcher: Cuckoo.CallMatcher, sourceLocation: Cuckoo.SourceLocation) {
+	        self.cuckoo_manager = manager
+	        self.callMatcher = callMatcher
+	        self.sourceLocation = sourceLocation
+	    }
+	
+	    
+	    
+	    var extendedValidation: Cuckoo.VerifyProperty<Bool> {
+	        return .init(manager: cuckoo_manager, name: "extendedValidation", callMatcher: callMatcher, sourceLocation: sourceLocation)
+	    }
+	    
+	    
+	    var imapCallback: Cuckoo.VerifyOptionalProperty<AuthenticationCallback> {
+	        return .init(manager: cuckoo_manager, name: "imapCallback", callMatcher: callMatcher, sourceLocation: sourceLocation)
+	    }
+	    
+	    
+	    var smtpCallback: Cuckoo.VerifyOptionalProperty<AuthenticationCallback> {
+	        return .init(manager: cuckoo_manager, name: "smtpCallback", callMatcher: callMatcher, sourceLocation: sourceLocation)
+	    }
+	    
+	    
+	    var imapConfigurationSuccessful: Cuckoo.VerifyProperty<Bool> {
+	        return .init(manager: cuckoo_manager, name: "imapConfigurationSuccessful", callMatcher: callMatcher, sourceLocation: sourceLocation)
+	    }
+	    
+	    
+	    var smtpConfigurationSuccessful: Cuckoo.VerifyProperty<Bool> {
+	        return .init(manager: cuckoo_manager, name: "smtpConfigurationSuccessful", callMatcher: callMatcher, sourceLocation: sourceLocation)
+	    }
+	    
+	    
+	    var dispatchGroup: Cuckoo.VerifyProperty<DispatchGroup> {
+	        return .init(manager: cuckoo_manager, name: "dispatchGroup", callMatcher: callMatcher, sourceLocation: sourceLocation)
+	    }
+	    
+	
+	    
+	    @discardableResult
+	    func checkConfig<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(mailAccount: M1, extendedValidation: M2) -> Cuckoo.__DoNotUse<(MailAccount, Bool), Future<AuthenticationResult, Never>> where M1.MatchedType == MailAccount, M2.MatchedType == Bool {
+	        let matchers: [Cuckoo.ParameterMatcher<(MailAccount, Bool)>] = [wrap(matchable: mailAccount) { $0.0 }, wrap(matchable: extendedValidation) { $0.1 }]
+	        return cuckoo_manager.verify("checkConfig(mailAccount: MailAccount, extendedValidation: Bool) -> Future<AuthenticationResult, Never>", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
+	    }
+	    
+	    @discardableResult
+	    func checkIMAPConfig<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(mailAccount: M1, _ callback: M2) -> Cuckoo.__DoNotUse<(MailAccount, AuthenticationCallback), Void> where M1.MatchedType == MailAccount, M2.MatchedType == AuthenticationCallback {
+	        let matchers: [Cuckoo.ParameterMatcher<(MailAccount, AuthenticationCallback)>] = [wrap(matchable: mailAccount) { $0.0 }, wrap(matchable: callback) { $0.1 }]
+	        return cuckoo_manager.verify("checkIMAPConfig(mailAccount: MailAccount, _: AuthenticationCallback)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
+	    }
+	    
+	    @discardableResult
+	    func checkSMTPConfig<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(mailAccount: M1, _ callback: M2) -> Cuckoo.__DoNotUse<(MailAccount, AuthenticationCallback), Void> where M1.MatchedType == MailAccount, M2.MatchedType == AuthenticationCallback {
+	        let matchers: [Cuckoo.ParameterMatcher<(MailAccount, AuthenticationCallback)>] = [wrap(matchable: mailAccount) { $0.0 }, wrap(matchable: callback) { $0.1 }]
+	        return cuckoo_manager.verify("checkSMTPConfig(mailAccount: MailAccount, _: AuthenticationCallback)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
+	    }
+	    
+	    @discardableResult
+	    func onTimeout<M1: Cuckoo.Matchable>(timeoutResult: M1) -> Cuckoo.__DoNotUse<(DispatchTimeoutResult), AuthenticationResult> where M1.MatchedType == DispatchTimeoutResult {
+	        let matchers: [Cuckoo.ParameterMatcher<(DispatchTimeoutResult)>] = [wrap(matchable: timeoutResult) { $0 }]
+	        return cuckoo_manager.verify("onTimeout(timeoutResult: DispatchTimeoutResult) -> AuthenticationResult", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
+	    }
+	    
+	    @discardableResult
+	    func onImapCompleted<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable, M3: Cuckoo.Matchable>(imapWorks: M1, _ login: M2, _ password: M3) -> Cuckoo.__DoNotUse<(Bool, String, String), Void> where M1.MatchedType == Bool, M2.MatchedType == String, M3.MatchedType == String {
+	        let matchers: [Cuckoo.ParameterMatcher<(Bool, String, String)>] = [wrap(matchable: imapWorks) { $0.0 }, wrap(matchable: login) { $0.1 }, wrap(matchable: password) { $0.2 }]
+	        return cuckoo_manager.verify("onImapCompleted(imapWorks: Bool, _: String, _: String)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
+	    }
+	    
+	    @discardableResult
+	    func onSmtpCompleted<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable, M3: Cuckoo.Matchable>(smtpWorks: M1, _ login: M2, _ password: M3) -> Cuckoo.__DoNotUse<(Bool, String, String), Void> where M1.MatchedType == Bool, M2.MatchedType == String, M3.MatchedType == String {
+	        let matchers: [Cuckoo.ParameterMatcher<(Bool, String, String)>] = [wrap(matchable: smtpWorks) { $0.0 }, wrap(matchable: login) { $0.1 }, wrap(matchable: password) { $0.2 }]
+	        return cuckoo_manager.verify("onSmtpCompleted(smtpWorks: Bool, _: String, _: String)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
+	    }
+	    
+	}
+}
+
+ class AuthenticationModelStub: AuthenticationModel {
+    
+    
+     override var extendedValidation: Bool {
+        get {
+            return DefaultValueRegistry.defaultValue(for: (Bool).self)
+        }
+        
+        set { }
+        
+    }
+    
+    
+     override var imapCallback: AuthenticationCallback? {
+        get {
+            return DefaultValueRegistry.defaultValue(for: (AuthenticationCallback?).self)
+        }
+        
+        set { }
+        
+    }
+    
+    
+     override var smtpCallback: AuthenticationCallback? {
+        get {
+            return DefaultValueRegistry.defaultValue(for: (AuthenticationCallback?).self)
+        }
+        
+        set { }
+        
+    }
+    
+    
+     override var imapConfigurationSuccessful: Bool {
+        get {
+            return DefaultValueRegistry.defaultValue(for: (Bool).self)
+        }
+        
+        set { }
+        
+    }
+    
+    
+     override var smtpConfigurationSuccessful: Bool {
+        get {
+            return DefaultValueRegistry.defaultValue(for: (Bool).self)
+        }
+        
+        set { }
+        
+    }
+    
+    
+     override var dispatchGroup: DispatchGroup {
+        get {
+            return DefaultValueRegistry.defaultValue(for: (DispatchGroup).self)
+        }
+        
+        set { }
+        
+    }
+    
+
+    
+
+    
+     override func checkConfig(mailAccount: MailAccount, extendedValidation: Bool) -> Future<AuthenticationResult, Never>  {
+        return DefaultValueRegistry.defaultValue(for: (Future<AuthenticationResult, Never>).self)
+    }
+    
+     override func checkIMAPConfig(mailAccount: MailAccount, _ callback: AuthenticationCallback)   {
+        return DefaultValueRegistry.defaultValue(for: (Void).self)
+    }
+    
+     override func checkSMTPConfig(mailAccount: MailAccount, _ callback: AuthenticationCallback)   {
+        return DefaultValueRegistry.defaultValue(for: (Void).self)
+    }
+    
+     override func onTimeout(timeoutResult: DispatchTimeoutResult) -> AuthenticationResult  {
+        return DefaultValueRegistry.defaultValue(for: (AuthenticationResult).self)
+    }
+    
+     override func onImapCompleted(imapWorks: Bool, _ login: String, _ password: String)   {
+        return DefaultValueRegistry.defaultValue(for: (Void).self)
+    }
+    
+     override func onSmtpCompleted(smtpWorks: Bool, _ login: String, _ password: String)   {
+        return DefaultValueRegistry.defaultValue(for: (Void).self)
+    }
+    
+}
+
+
+
+ class MockAuthenticationCallback: AuthenticationCallback, Cuckoo.ClassMock {
+    
+     typealias MocksType = AuthenticationCallback
+    
+     typealias Stubbing = __StubbingProxy_AuthenticationCallback
+     typealias Verification = __VerificationProxy_AuthenticationCallback
+
+     let cuckoo_manager = Cuckoo.MockManager.preconfiguredManager ?? Cuckoo.MockManager(hasParent: true)
+
+    
+    private var __defaultImplStub: AuthenticationCallback?
+
+     func enableDefaultImplementation(_ stub: AuthenticationCallback) {
+        __defaultImplStub = stub
+        cuckoo_manager.enableDefaultStubImplementation()
+    }
+    
+
+    
+    
+    
+     override var callback: ((Bool, String, String) -> Void)? {
+        get {
+            return cuckoo_manager.getter("callback",
+                superclassCall:
+                    
+                    super.callback
+                    ,
+                defaultCall: __defaultImplStub!.callback)
+        }
+        
+        set {
+            cuckoo_manager.setter("callback",
+                value: newValue,
+                superclassCall:
+                    
+                    super.callback = newValue
+                    ,
+                defaultCall: __defaultImplStub!.callback = newValue)
+        }
+        
+    }
+    
+
+    
+
+    
+    
+    
+     override func onResult(worked: Bool, login: String, password: String)  {
+        
+    return cuckoo_manager.call("onResult(worked: Bool, login: String, password: String)",
+            parameters: (worked, login, password),
+            escapingParameters: (worked, login, password),
+            superclassCall:
+                
+                super.onResult(worked: worked, login: login, password: password)
+                ,
+            defaultCall: __defaultImplStub!.onResult(worked: worked, login: login, password: password))
+        
+    }
+    
+
+	 struct __StubbingProxy_AuthenticationCallback: Cuckoo.StubbingProxy {
+	    private let cuckoo_manager: Cuckoo.MockManager
+	
+	     init(manager: Cuckoo.MockManager) {
+	        self.cuckoo_manager = manager
+	    }
+	    
+	    
+	    var callback: Cuckoo.ClassToBeStubbedOptionalProperty<MockAuthenticationCallback, ((Bool, String, String) -> Void)> {
+	        return .init(manager: cuckoo_manager, name: "callback")
+	    }
+	    
+	    
+	    func onResult<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable, M3: Cuckoo.Matchable>(worked: M1, login: M2, password: M3) -> Cuckoo.ClassStubNoReturnFunction<(Bool, String, String)> where M1.MatchedType == Bool, M2.MatchedType == String, M3.MatchedType == String {
+	        let matchers: [Cuckoo.ParameterMatcher<(Bool, String, String)>] = [wrap(matchable: worked) { $0.0 }, wrap(matchable: login) { $0.1 }, wrap(matchable: password) { $0.2 }]
+	        return .init(stub: cuckoo_manager.createStub(for: MockAuthenticationCallback.self, method: "onResult(worked: Bool, login: String, password: String)", parameterMatchers: matchers))
+	    }
+	    
+	}
+
+	 struct __VerificationProxy_AuthenticationCallback: Cuckoo.VerificationProxy {
+	    private let cuckoo_manager: Cuckoo.MockManager
+	    private let callMatcher: Cuckoo.CallMatcher
+	    private let sourceLocation: Cuckoo.SourceLocation
+	
+	     init(manager: Cuckoo.MockManager, callMatcher: Cuckoo.CallMatcher, sourceLocation: Cuckoo.SourceLocation) {
+	        self.cuckoo_manager = manager
+	        self.callMatcher = callMatcher
+	        self.sourceLocation = sourceLocation
+	    }
+	
+	    
+	    
+	    var callback: Cuckoo.VerifyOptionalProperty<((Bool, String, String) -> Void)> {
+	        return .init(manager: cuckoo_manager, name: "callback", callMatcher: callMatcher, sourceLocation: sourceLocation)
+	    }
+	    
+	
+	    
+	    @discardableResult
+	    func onResult<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable, M3: Cuckoo.Matchable>(worked: M1, login: M2, password: M3) -> Cuckoo.__DoNotUse<(Bool, String, String), Void> where M1.MatchedType == Bool, M2.MatchedType == String, M3.MatchedType == String {
+	        let matchers: [Cuckoo.ParameterMatcher<(Bool, String, String)>] = [wrap(matchable: worked) { $0.0 }, wrap(matchable: login) { $0.1 }, wrap(matchable: password) { $0.2 }]
+	        return cuckoo_manager.verify("onResult(worked: Bool, login: String, password: String)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
+	    }
+	    
+	}
+}
+
+ class AuthenticationCallbackStub: AuthenticationCallback {
+    
+    
+     override var callback: ((Bool, String, String) -> Void)? {
+        get {
+            return DefaultValueRegistry.defaultValue(for: (((Bool, String, String) -> Void)?).self)
+        }
+        
+        set { }
+        
+    }
+    
+
+    
+
+    
+     override func onResult(worked: Bool, login: String, password: String)   {
+        return DefaultValueRegistry.defaultValue(for: (Void).self)
+    }
+    
+}
+
+
+<<<<<<< HEAD
+// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationViewModel.swift at 2020-03-31 15:54:34 +0000
+=======
+// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationViewModel.swift at 2020-03-18 15:11:52 +0000
+>>>>>>> dev
+
+//
+//  AuthenticationViewModel.swift
+//  enzevalos_iphone
+//
+//  Created by SWP Usable Security für Smartphones on 02.03.20.
+//  Copyright © 2020 fu-berlin. All rights reserved.
+//
+import Cuckoo
+@testable import enzevalos_iphone
+
+import Combine
+import Foundation
+
+
+ class MockAuthenticationViewModel: AuthenticationViewModel, Cuckoo.ClassMock {
+    
+     typealias MocksType = AuthenticationViewModel
+    
+     typealias Stubbing = __StubbingProxy_AuthenticationViewModel
+     typealias Verification = __VerificationProxy_AuthenticationViewModel
+
+     let cuckoo_manager = Cuckoo.MockManager.preconfiguredManager ?? Cuckoo.MockManager(hasParent: true)
+
+    
+    private var __defaultImplStub: AuthenticationViewModel?
+
+     func enableDefaultImplementation(_ stub: AuthenticationViewModel) {
+        __defaultImplStub = stub
+        cuckoo_manager.enableDefaultStubImplementation()
+    }
+    
+
+    
+    
+    
+     override var errorMessage: String? {
+        get {
+            return cuckoo_manager.getter("errorMessage",
+                superclassCall:
+                    
+                    super.errorMessage
+                    ,
+                defaultCall: __defaultImplStub!.errorMessage)
+        }
+        
+        set {
+            cuckoo_manager.setter("errorMessage",
+                value: newValue,
+                superclassCall:
+                    
+                    super.errorMessage = newValue
+                    ,
+                defaultCall: __defaultImplStub!.errorMessage = newValue)
+        }
+        
+    }
+    
+    
+    
+     override var isDetailedAuthentication: Bool {
+        get {
+            return cuckoo_manager.getter("isDetailedAuthentication",
+                superclassCall:
+                    
+                    super.isDetailedAuthentication
+                    ,
+                defaultCall: __defaultImplStub!.isDetailedAuthentication)
+        }
+        
+        set {
+            cuckoo_manager.setter("isDetailedAuthentication",
+                value: newValue,
+                superclassCall:
+                    
+                    super.isDetailedAuthentication = newValue
+                    ,
+                defaultCall: __defaultImplStub!.isDetailedAuthentication = newValue)
+        }
+        
+    }
+    
+    
+    
+     override var showProgressSpinner: Bool {
+        get {
+            return cuckoo_manager.getter("showProgressSpinner",
+                superclassCall:
+                    
+                    super.showProgressSpinner
+                    ,
+                defaultCall: __defaultImplStub!.showProgressSpinner)
+        }
+        
+        set {
+            cuckoo_manager.setter("showProgressSpinner",
+                value: newValue,
+                superclassCall:
+                    
+                    super.showProgressSpinner = newValue
+                    ,
+                defaultCall: __defaultImplStub!.showProgressSpinner = newValue)
+        }
+        
+    }
+    
+    
+    
+     override var cancellable: AnyCancellable? {
+        get {
+            return cuckoo_manager.getter("cancellable",
+                superclassCall:
+                    
+                    super.cancellable
+                    ,
+                defaultCall: __defaultImplStub!.cancellable)
+        }
+        
+        set {
+            cuckoo_manager.setter("cancellable",
+                value: newValue,
+                superclassCall:
+                    
+                    super.cancellable = newValue
+                    ,
+                defaultCall: __defaultImplStub!.cancellable = newValue)
+        }
+        
+    }
+    
+
+    
+
+    
+    
+    
+     override func validate(_ login: String, _ password: String)  {
+        
+    return cuckoo_manager.call("validate(_: String, _: String)",
+            parameters: (login, password),
+            escapingParameters: (login, password),
+            superclassCall:
+                
+                super.validate(login, password)
+                ,
+            defaultCall: __defaultImplStub!.validate(login, password))
+        
+    }
+    
+    
+    
+     override func detailValidation(_ login: String, _ password: String, _ username: String, _ imapServer: String, _ imapPort: String, _ imapEncryption: Int, _ smtpServer: String, _ smtpPort: String, _ smtpEncryption: Int)  {
+        
+    return cuckoo_manager.call("detailValidation(_: String, _: String, _: String, _: String, _: String, _: Int, _: String, _: String, _: Int)",
+            parameters: (login, password, username, imapServer, imapPort, imapEncryption, smtpServer, smtpPort, smtpEncryption),
+            escapingParameters: (login, password, username, imapServer, imapPort, imapEncryption, smtpServer, smtpPort, smtpEncryption),
+            superclassCall:
+                
+                super.detailValidation(login, password, username, imapServer, imapPort, imapEncryption, smtpServer, smtpPort, smtpEncryption)
+                ,
+            defaultCall: __defaultImplStub!.detailValidation(login, password, username, imapServer, imapPort, imapEncryption, smtpServer, smtpPort, smtpEncryption))
+        
+    }
+    
+    
+    
+     override func startGoogleOauth()  {
+        
+    return cuckoo_manager.call("startGoogleOauth()",
+            parameters: (),
+            escapingParameters: (),
+            superclassCall:
+                
+                super.startGoogleOauth()
+                ,
+            defaultCall: __defaultImplStub!.startGoogleOauth())
+        
+    }
+    
+    
+    
+     override func authenticationSucceed()  {
+        
+    return cuckoo_manager.call("authenticationSucceed()",
+            parameters: (),
+            escapingParameters: (),
+            superclassCall:
+                
+                super.authenticationSucceed()
+                ,
+            defaultCall: __defaultImplStub!.authenticationSucceed())
+        
+    }
+    
+    
+    
+     override func authenticationFailed(error: MailServerConnectionError)  {
+        
+    return cuckoo_manager.call("authenticationFailed(error: MailServerConnectionError)",
+            parameters: (error),
+            escapingParameters: (error),
+            superclassCall:
+                
+                super.authenticationFailed(error: error)
+                ,
+            defaultCall: __defaultImplStub!.authenticationFailed(error: error))
+        
+    }
+    
+    
+    
+     override func timeoutNotification()  {
+        
+    return cuckoo_manager.call("timeoutNotification()",
+            parameters: (),
+            escapingParameters: (),
+            superclassCall:
+                
+                super.timeoutNotification()
+                ,
+            defaultCall: __defaultImplStub!.timeoutNotification())
+        
+    }
+    
+
+	 struct __StubbingProxy_AuthenticationViewModel: Cuckoo.StubbingProxy {
+	    private let cuckoo_manager: Cuckoo.MockManager
+	
+	     init(manager: Cuckoo.MockManager) {
+	        self.cuckoo_manager = manager
+	    }
+	    
+	    
+	    var errorMessage: Cuckoo.ClassToBeStubbedOptionalProperty<MockAuthenticationViewModel, String> {
+	        return .init(manager: cuckoo_manager, name: "errorMessage")
+	    }
+	    
+	    
+	    var isDetailedAuthentication: Cuckoo.ClassToBeStubbedProperty<MockAuthenticationViewModel, Bool> {
+	        return .init(manager: cuckoo_manager, name: "isDetailedAuthentication")
+	    }
+	    
+	    
+	    var showProgressSpinner: Cuckoo.ClassToBeStubbedProperty<MockAuthenticationViewModel, Bool> {
+	        return .init(manager: cuckoo_manager, name: "showProgressSpinner")
+	    }
+	    
+	    
+	    var cancellable: Cuckoo.ClassToBeStubbedOptionalProperty<MockAuthenticationViewModel, AnyCancellable> {
+	        return .init(manager: cuckoo_manager, name: "cancellable")
+	    }
+	    
+	    
+	    func validate<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(_ login: M1, _ password: M2) -> Cuckoo.ClassStubNoReturnFunction<(String, String)> where M1.MatchedType == String, M2.MatchedType == String {
+	        let matchers: [Cuckoo.ParameterMatcher<(String, String)>] = [wrap(matchable: login) { $0.0 }, wrap(matchable: password) { $0.1 }]
+	        return .init(stub: cuckoo_manager.createStub(for: MockAuthenticationViewModel.self, method: "validate(_: String, _: String)", parameterMatchers: matchers))
+	    }
+	    
+	    func detailValidation<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable, M3: Cuckoo.Matchable, M4: Cuckoo.Matchable, M5: Cuckoo.Matchable, M6: Cuckoo.Matchable, M7: Cuckoo.Matchable, M8: Cuckoo.Matchable, M9: Cuckoo.Matchable>(_ login: M1, _ password: M2, _ username: M3, _ imapServer: M4, _ imapPort: M5, _ imapEncryption: M6, _ smtpServer: M7, _ smtpPort: M8, _ smtpEncryption: M9) -> Cuckoo.ClassStubNoReturnFunction<(String, String, String, String, String, Int, String, String, Int)> where M1.MatchedType == String, M2.MatchedType == String, M3.MatchedType == String, M4.MatchedType == String, M5.MatchedType == String, M6.MatchedType == Int, M7.MatchedType == String, M8.MatchedType == String, M9.MatchedType == Int {
+	        let matchers: [Cuckoo.ParameterMatcher<(String, String, String, String, String, Int, String, String, Int)>] = [wrap(matchable: login) { $0.0 }, wrap(matchable: password) { $0.1 }, wrap(matchable: username) { $0.2 }, wrap(matchable: imapServer) { $0.3 }, wrap(matchable: imapPort) { $0.4 }, wrap(matchable: imapEncryption) { $0.5 }, wrap(matchable: smtpServer) { $0.6 }, wrap(matchable: smtpPort) { $0.7 }, wrap(matchable: smtpEncryption) { $0.8 }]
+	        return .init(stub: cuckoo_manager.createStub(for: MockAuthenticationViewModel.self, method: "detailValidation(_: String, _: String, _: String, _: String, _: String, _: Int, _: String, _: String, _: Int)", parameterMatchers: matchers))
+	    }
+	    
+	    func startGoogleOauth() -> Cuckoo.ClassStubNoReturnFunction<()> {
+	        let matchers: [Cuckoo.ParameterMatcher<Void>] = []
+	        return .init(stub: cuckoo_manager.createStub(for: MockAuthenticationViewModel.self, method: "startGoogleOauth()", parameterMatchers: matchers))
+	    }
+	    
+	    func authenticationSucceed() -> Cuckoo.ClassStubNoReturnFunction<()> {
+	        let matchers: [Cuckoo.ParameterMatcher<Void>] = []
+	        return .init(stub: cuckoo_manager.createStub(for: MockAuthenticationViewModel.self, method: "authenticationSucceed()", parameterMatchers: matchers))
+	    }
+	    
+	    func authenticationFailed<M1: Cuckoo.Matchable>(error: M1) -> Cuckoo.ClassStubNoReturnFunction<(MailServerConnectionError)> where M1.MatchedType == MailServerConnectionError {
+	        let matchers: [Cuckoo.ParameterMatcher<(MailServerConnectionError)>] = [wrap(matchable: error) { $0 }]
+	        return .init(stub: cuckoo_manager.createStub(for: MockAuthenticationViewModel.self, method: "authenticationFailed(error: MailServerConnectionError)", parameterMatchers: matchers))
+	    }
+	    
+	    func timeoutNotification() -> Cuckoo.ClassStubNoReturnFunction<()> {
+	        let matchers: [Cuckoo.ParameterMatcher<Void>] = []
+	        return .init(stub: cuckoo_manager.createStub(for: MockAuthenticationViewModel.self, method: "timeoutNotification()", parameterMatchers: matchers))
+	    }
+	    
+	}
+
+	 struct __VerificationProxy_AuthenticationViewModel: Cuckoo.VerificationProxy {
+	    private let cuckoo_manager: Cuckoo.MockManager
+	    private let callMatcher: Cuckoo.CallMatcher
+	    private let sourceLocation: Cuckoo.SourceLocation
+	
+	     init(manager: Cuckoo.MockManager, callMatcher: Cuckoo.CallMatcher, sourceLocation: Cuckoo.SourceLocation) {
+	        self.cuckoo_manager = manager
+	        self.callMatcher = callMatcher
+	        self.sourceLocation = sourceLocation
+	    }
+	
+	    
+	    
+	    var errorMessage: Cuckoo.VerifyOptionalProperty<String> {
+	        return .init(manager: cuckoo_manager, name: "errorMessage", callMatcher: callMatcher, sourceLocation: sourceLocation)
+	    }
+	    
+	    
+	    var isDetailedAuthentication: Cuckoo.VerifyProperty<Bool> {
+	        return .init(manager: cuckoo_manager, name: "isDetailedAuthentication", callMatcher: callMatcher, sourceLocation: sourceLocation)
+	    }
+	    
+	    
+	    var showProgressSpinner: Cuckoo.VerifyProperty<Bool> {
+	        return .init(manager: cuckoo_manager, name: "showProgressSpinner", callMatcher: callMatcher, sourceLocation: sourceLocation)
+	    }
+	    
+	    
+	    var cancellable: Cuckoo.VerifyOptionalProperty<AnyCancellable> {
+	        return .init(manager: cuckoo_manager, name: "cancellable", callMatcher: callMatcher, sourceLocation: sourceLocation)
+	    }
+	    
+	
+	    
+	    @discardableResult
+	    func validate<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(_ login: M1, _ password: M2) -> Cuckoo.__DoNotUse<(String, String), Void> where M1.MatchedType == String, M2.MatchedType == String {
+	        let matchers: [Cuckoo.ParameterMatcher<(String, String)>] = [wrap(matchable: login) { $0.0 }, wrap(matchable: password) { $0.1 }]
+	        return cuckoo_manager.verify("validate(_: String, _: String)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
+	    }
+	    
+	    @discardableResult
+	    func detailValidation<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable, M3: Cuckoo.Matchable, M4: Cuckoo.Matchable, M5: Cuckoo.Matchable, M6: Cuckoo.Matchable, M7: Cuckoo.Matchable, M8: Cuckoo.Matchable, M9: Cuckoo.Matchable>(_ login: M1, _ password: M2, _ username: M3, _ imapServer: M4, _ imapPort: M5, _ imapEncryption: M6, _ smtpServer: M7, _ smtpPort: M8, _ smtpEncryption: M9) -> Cuckoo.__DoNotUse<(String, String, String, String, String, Int, String, String, Int), Void> where M1.MatchedType == String, M2.MatchedType == String, M3.MatchedType == String, M4.MatchedType == String, M5.MatchedType == String, M6.MatchedType == Int, M7.MatchedType == String, M8.MatchedType == String, M9.MatchedType == Int {
+	        let matchers: [Cuckoo.ParameterMatcher<(String, String, String, String, String, Int, String, String, Int)>] = [wrap(matchable: login) { $0.0 }, wrap(matchable: password) { $0.1 }, wrap(matchable: username) { $0.2 }, wrap(matchable: imapServer) { $0.3 }, wrap(matchable: imapPort) { $0.4 }, wrap(matchable: imapEncryption) { $0.5 }, wrap(matchable: smtpServer) { $0.6 }, wrap(matchable: smtpPort) { $0.7 }, wrap(matchable: smtpEncryption) { $0.8 }]
+	        return cuckoo_manager.verify("detailValidation(_: String, _: String, _: String, _: String, _: String, _: Int, _: String, _: String, _: Int)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
+	    }
+	    
+	    @discardableResult
+	    func startGoogleOauth() -> Cuckoo.__DoNotUse<(), Void> {
+	        let matchers: [Cuckoo.ParameterMatcher<Void>] = []
+	        return cuckoo_manager.verify("startGoogleOauth()", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
+	    }
+	    
+	    @discardableResult
+	    func authenticationSucceed() -> Cuckoo.__DoNotUse<(), Void> {
+	        let matchers: [Cuckoo.ParameterMatcher<Void>] = []
+	        return cuckoo_manager.verify("authenticationSucceed()", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
+	    }
+	    
+	    @discardableResult
+	    func authenticationFailed<M1: Cuckoo.Matchable>(error: M1) -> Cuckoo.__DoNotUse<(MailServerConnectionError), Void> where M1.MatchedType == MailServerConnectionError {
+	        let matchers: [Cuckoo.ParameterMatcher<(MailServerConnectionError)>] = [wrap(matchable: error) { $0 }]
+	        return cuckoo_manager.verify("authenticationFailed(error: MailServerConnectionError)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
+	    }
+	    
+	    @discardableResult
+	    func timeoutNotification() -> Cuckoo.__DoNotUse<(), Void> {
+	        let matchers: [Cuckoo.ParameterMatcher<Void>] = []
+	        return cuckoo_manager.verify("timeoutNotification()", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
+	    }
+	    
+	}
+}
+
+ class AuthenticationViewModelStub: AuthenticationViewModel {
+    
+    
+     override var errorMessage: String? {
+        get {
+            return DefaultValueRegistry.defaultValue(for: (String?).self)
+        }
+        
+        set { }
+        
+    }
+    
+    
+     override var isDetailedAuthentication: Bool {
+        get {
+            return DefaultValueRegistry.defaultValue(for: (Bool).self)
+        }
+        
+        set { }
+        
+    }
+    
+    
+     override var showProgressSpinner: Bool {
+        get {
+            return DefaultValueRegistry.defaultValue(for: (Bool).self)
+        }
+        
+        set { }
+        
+    }
+    
+    
+     override var cancellable: AnyCancellable? {
+        get {
+            return DefaultValueRegistry.defaultValue(for: (AnyCancellable?).self)
+        }
+        
+        set { }
+        
+    }
+    
+
+    
+
+    
+     override func validate(_ login: String, _ password: String)   {
+        return DefaultValueRegistry.defaultValue(for: (Void).self)
+    }
+    
+     override func detailValidation(_ login: String, _ password: String, _ username: String, _ imapServer: String, _ imapPort: String, _ imapEncryption: Int, _ smtpServer: String, _ smtpPort: String, _ smtpEncryption: Int)   {
+        return DefaultValueRegistry.defaultValue(for: (Void).self)
+    }
+    
+     override func startGoogleOauth()   {
+        return DefaultValueRegistry.defaultValue(for: (Void).self)
+    }
+    
+     override func authenticationSucceed()   {
+        return DefaultValueRegistry.defaultValue(for: (Void).self)
+    }
+    
+     override func authenticationFailed(error: MailServerConnectionError)   {
+        return DefaultValueRegistry.defaultValue(for: (Void).self)
+    }
+    
+     override func timeoutNotification()   {
+        return DefaultValueRegistry.defaultValue(for: (Void).self)
+    }
+    
+}
+
diff --git a/enzevalos_iphoneTests/SMIMETests.swift b/enzevalos_iphoneTests/SMIMETests.swift
index c98c2e92c14d1cef1821a022f3c2b92b1322b757..bda280b0d273139922ef084ca58ab5122bbfbea3 100644
--- a/enzevalos_iphoneTests/SMIMETests.swift
+++ b/enzevalos_iphoneTests/SMIMETests.swift
@@ -349,6 +349,7 @@ PkfA6mR7rtcyIbHi34tfkCv/qolV3QivMHov0IJpRyNO
         ourAddr = certi!.eMails![0]
         otherAddr = othercerti!.eMails![0]
         ourPrivateKeyFP = smimeObj.addPrivateKey(keyPlusCertPEM: test_key)
+        let _ = smimeObj.importCA(certs: [testCA])
         let _ = smimeObj.importCertForAddress(cert: test_key, addr: ourAddr!)
         let _ = smimeObj.importCertForAddress(cert: test_key_other, addr: otherAddr!)
     }
@@ -389,7 +390,7 @@ PkfA6mR7rtcyIbHi34tfkCv/qolV3QivMHov0IJpRyNO
         print("cipther string: ", encCryptObj!.chiperString ?? "")
         var decObj : CryptoObject? = nil
         do {
-            decObj = try smimeObj.decrypt(data: (encCryptObj?.chiphertext)!, fromAddr: ourAddr!, ownId: ourAddr!, isMailNew: false)
+            decObj = try smimeObj.decrypt(data: (encCryptObj?.chiphertext)!, fromAddr: ourAddr!, isMailNew: false)
         }catch let error {
             if error is SMIMEError {
                 let smimeError = error as! SMIMEError
@@ -446,6 +447,6 @@ PkfA6mR7rtcyIbHi34tfkCv/qolV3QivMHov0IJpRyNO
             }
         }
         assert(pKey != nil)
-        assert(getFingerprintFromPem(pem: pKey!) == getFingerprintFromPem(pem: test_key))
+        assert(test_key.contains((pKey ?? "     asd    ")))
     }
 }