Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c4381f6
Initial demo of secure key generation from password
NMerz Apr 10, 2020
e3336a3
Add public key gen poc
NMerz Apr 10, 2020
7fe4764
POC on private key encryption
NMerz Apr 12, 2020
c574d81
Initial message cipher work
NMerz Apr 12, 2020
81756f6
ignore xcuserdata
arianazhu Apr 12, 2020
75e997d
Merge branch 'dev' into DOC-15-calendarviewpatient
arianazhu Apr 12, 2020
18ca894
Merge branch 'dev' into DOC-15-calendarviewpatient
arianazhu Apr 12, 2020
7243b52
Added appointment deletion, calendar events
arianazhu Apr 13, 2020
5433b4b
Changed delete appointment processor
arianazhu Apr 13, 2020
3c0b526
Added security questions to login view
arianazhu Apr 13, 2020
f21099a
Initial private key retrieval lambda
NMerz Apr 13, 2020
2f2577c
Merge branch 'master' into encryption
NMerz Apr 13, 2020
1581ec1
Lambda casting and error clarify fixes
NMerz Apr 13, 2020
0c8297d
Local Cipher - AES key from Passwod
NMerz Apr 13, 2020
8909a70
Fix add messages
NMerz Apr 15, 2020
c6bcf71
Key storing
NMerz Apr 15, 2020
56ccbb3
Fix null key adder return
NMerz Apr 15, 2020
05b29a8
Initial encrypted message sending
NMerz Apr 16, 2020
3084a94
Message sending
NMerz Apr 16, 2020
0aa828a
Fixed event showing on calendar
arianazhu Apr 17, 2020
ab11e07
Merge branch 'DOC-15-calendarviewpatient' into dev
arianazhu Apr 17, 2020
5cb831e
Merge branch 'dev' into security-questions
arianazhu Apr 17, 2020
5c9c0cf
Started hashing/unhashing security questions
arianazhu Apr 17, 2020
116d093
Updated security question hash
arianazhu Apr 18, 2020
6d459b0
Merge branch 'master' into encryption
NMerz Apr 20, 2020
e6f85e5
Password reset iOS backend
NMerz Apr 20, 2020
c8eff1f
Merge branch 'master' into encryption
NMerz Apr 20, 2020
ab29c9d
Remove jars from repo
NMerz Apr 20, 2020
20d93ee
Merge branch 'security-questions' into encryption
NMerz Apr 22, 2020
5986f2d
Remove duplicate files
NMerz Apr 22, 2020
5d44339
Key integration
NMerz Apr 22, 2020
a4f455d
Tests to verify that message statistics are working
jlmolskness Apr 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ out
.DS_Store
xcuserdata
*.iml
*.jar

xcshareddata
# Xcode
#
Expand Down
10 changes: 10 additions & 0 deletions DoctorsNote/DoctorsNote.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
9D23056E24105ED00064E6E2 /* Reminder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D23056D24105ED00064E6E2 /* Reminder.swift */; };
9D267F0F24105CD000E787FB /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D267F0E24105CD000E787FB /* Message.swift */; };
9D325395242A765F0057B354 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D267F0124105BDA00E787FB /* User.swift */; };
9D41A4A62443BA880069A1B8 /* MessageCipher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D41A4A52443BA880069A1B8 /* MessageCipher.swift */; };
9D41A4A72443BA8B0069A1B8 /* MessageCipher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D41A4A52443BA880069A1B8 /* MessageCipher.swift */; };
9D90C39B2400666B006FD4C6 /* ConnectionProcessorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D90C38B23F9CF8B006FD4C6 /* ConnectionProcessorTests.swift */; };
9DD1D469242E8B3200925298 /* Appointment.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8E3BA28242C258900820F05 /* Appointment.swift */; };
9DDB41372444072A0021FDDC /* LocalCipher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DDB41362444072A0021FDDC /* LocalCipher.swift */; };
AD4567D3634346E5B3E37C80 /* Pods_DoctorsNoteTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A21B97793A0B6E9F53489841 /* Pods_DoctorsNoteTests.framework */; };
B2E92EDF0D4EB4D291081AEE /* Pods_DoctorsNote_DoctorsNoteUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6F1A60D0FD3CCB8BB833746 /* Pods_DoctorsNote_DoctorsNoteUITests.framework */; };
B51C6A20242C551F00048BCF /* TestChatView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B51C6A1F242C551F00048BCF /* TestChatView.swift */; };
Expand Down Expand Up @@ -116,7 +119,9 @@
9D23056D24105ED00064E6E2 /* Reminder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Reminder.swift; sourceTree = "<group>"; };
9D267F0124105BDA00E787FB /* User.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
9D267F0E24105CD000E787FB /* Message.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Message.swift; sourceTree = "<group>"; };
9D41A4A52443BA880069A1B8 /* MessageCipher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageCipher.swift; sourceTree = "<group>"; };
9D90C38B23F9CF8B006FD4C6 /* ConnectionProcessorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionProcessorTests.swift; sourceTree = "<group>"; };
9DDB41362444072A0021FDDC /* LocalCipher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalCipher.swift; sourceTree = "<group>"; };
A21B97793A0B6E9F53489841 /* Pods_DoctorsNoteTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DoctorsNoteTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
B50173F82408323F003D2224 /* SearchGroupsTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchGroupsTableViewController.swift; sourceTree = "<group>"; };
B51C6A1F242C551F00048BCF /* TestChatView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestChatView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -265,6 +270,8 @@
442F306523F883A8001EBC3C /* ConversationViewController.swift */,
B82083CA24033A1E00CF41D0 /* SupportGroupMessageVC.swift */,
447323FF243184900026DA34 /* SupportGroupConvo.swift */,
9D41A4A52443BA880069A1B8 /* MessageCipher.swift */,
9DDB41362444072A0021FDDC /* LocalCipher.swift */,
);
path = DoctorsNote;
sourceTree = "<group>";
Expand Down Expand Up @@ -639,6 +646,7 @@
B85C61B5242DDB160002D014 /* AppointmentListCell.swift in Sources */,
B54E4F262408ED8300349316 /* DefinedValues.swift in Sources */,
9D137F45242BAC2000A0B0AB /* HealthSystem.swift in Sources */,
9D41A4A62443BA880069A1B8 /* MessageCipher.swift in Sources */,
B587B55A2429710C00B6BF0D /* EditReminderVC.swift in Sources */,
B54E4F3A2408EEA900349316 /* SearchGroupsTableViewController.swift in Sources */,
B85C61B7242DE6950002D014 /* AppointmentListVC.swift in Sources */,
Expand All @@ -656,6 +664,7 @@
B87E49042408F462000E6ABC /* RemindersVC.swift in Sources */,
B52ABE6A23F5B872007B3D6A /* AppDelegate.swift in Sources */,
B5C12168241DCCC400B2905A /* DoctorProfileViewController.swift in Sources */,
9DDB41372444072A0021FDDC /* LocalCipher.swift in Sources */,
B52ABE6C23F5B872007B3D6A /* SceneDelegate.swift in Sources */,
B54E4F332408EDA200349316 /* ForgotPasswordViewController.swift in Sources */,
B54E4F382408EDA200349316 /* PersonalInfoView.swift in Sources */,
Expand All @@ -682,6 +691,7 @@
B51C6A22242C574B00048BCF /* (null) in Sources */,
B51C6A23242C574B00048BCF /* (null) in Sources */,
B5AE734E24156C5B00A9CDAE /* (null) in Sources */,
9D41A4A72443BA8B0069A1B8 /* MessageCipher.swift in Sources */,
9D137F40242BAB6E00A0B0AB /* ConnectionProcessor.swift in Sources */,
9D137F43242BAB7700A0B0AB /* Conversation.swift in Sources */,
9D137F89242C020A00A0B0AB /* Reminder.swift in Sources */,
Expand Down
6 changes: 6 additions & 0 deletions DoctorsNote/DoctorsNote/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import AWSCognito
import AWSMobileClient
import UserNotifications

import CryptoKit
import CommonCrypto



extension AWSMobileClientError {
var message: String {
switch self {
Expand Down Expand Up @@ -86,6 +91,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

requestNotificationAuthorization(application: application)

// Override point for customization after application launch.
Expand Down
2 changes: 1 addition & 1 deletion DoctorsNote/DoctorsNote/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@
<rect key="frame" x="20" y="632" width="374" height="40"/>
<accessibility key="accessibilityConfiguration" label="Pending"/>
<fontDescription key="fontDescription" type="system" pointSize="23"/>
<state key="normal" title="View Pending Appointments"/>
<state key="normal" title="View Appointments"/>
<connections>
<segue destination="8ZG-ZQ-VdB" kind="show" id="btf-lT-HBh"/>
</connections>
Expand Down
95 changes: 71 additions & 24 deletions DoctorsNote/DoctorsNote/ChatLogController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,23 @@ class ChatLogController: UIViewController, UICollectionViewDelegate, UICollectio
// Do any additional setup after loading the view.
messagesShown = 20;
do {
messages = try (connectionProcessor.processMessages(url: "https://o2lufnhpee.execute-api.us-east-2.amazonaws.com/Development/messagelist/", conversationID: conversation!.getConversationID(), numberToRetrieve: messagesShown) ?? messages)
if conversation?.getConverserID() == "N/A" {
messages = try connectionProcessor.processMessages(url: "https://o2lufnhpee.execute-api.us-east-2.amazonaws.com/Development/messagelist/", conversationID: conversation!.getConversationID(), numberToRetrieve: messagesShown)

} else {
let cipher = LocalCipher()
messages = try connectionProcessor.processMessages(url: "https://o2lufnhpee.execute-api.us-east-2.amazonaws.com/Development/messagelist/", conversationID: conversation!.getConversationID(), numberToRetrieve: messagesShown, cipher: MessageCipher(uniqueID: CognitoHelper.user!.getUID(), localAESKey: cipher.getAESFromPass(password: CognitoHelper.password!, username: CognitoHelper.user!.getUID())))
}
print(messages)
} catch let error as CipherError {
print ((error).getMessage())
print("Cipher ERROR!!!!!!!!!!!!")
} catch let error {
print ((error as! ConnectionError).getMessage())
print("ERROR!!!!!!!!!!!!")
} catch let error {
print (error.localizedDescription)
print("ERROR!!!!!!!!!!!!")
}

let item = self.collectionView(self.collectionView, numberOfItemsInSection: 0) - 1
Expand Down Expand Up @@ -99,22 +111,50 @@ class ChatLogController: UIViewController, UICollectionViewDelegate, UICollectio
}
let newMessage = Message(messageID: -1, conversationID: conversation!.getConversationID(), content: (messageText!.text?.data(using: .utf8))!, contentType: 0, numFails: CognitoHelper.numFails)
print(newMessage.getBase64Content())
let err = connectionProcessor.processNewMessage(url: "https://o2lufnhpee.execute-api.us-east-2.amazonaws.com/Development/messageadd", message: newMessage)
if (err != nil) {
CognitoHelper.numFails += 1
let alertController = UIAlertController(title: "Error Sending Message", message: "The message failed to send.", preferredStyle: .alert)
let okAction = UIAlertAction(title: "Ok", style: .default, handler: nil)
alertController.addAction(okAction)
// Turn this into a reminder eventually because it takes so long to determine that the message failed to send.
self.present(alertController, animated: true, completion: nil)
} else {
// Reset the number of failed sends to 0
CognitoHelper.numFails = 0
}
sendMessage(toSend: newMessage)

reloadMessages()
print("Pressed2")
}

func sendMessage(toSend: Message) {
if conversation?.getConverserID() != "N/A" {
do {
let cipher = try MessageCipher(uniqueID: CognitoHelper.user!.getUID(), localAESKey: LocalCipher().getAESFromPass(password: CognitoHelper.password!, username: CognitoHelper.user!.getUID()))
let err = connectionProcessor.processNewMessage(url: "https://o2lufnhpee.execute-api.us-east-2.amazonaws.com/Development/messageadd", message: toSend, cipher: cipher, publicKeyExternalBase64: conversation?.getConverserPublicKey(), adminPublicKeyExternalBase64: conversation?.getAdminPublicKey())
if (err != nil) {
CognitoHelper.numFails += 1
throw err!
} else {
CognitoHelper.numFails = 0
}
} catch let error {
if error as? ConnectionError != nil {
print((error as! ConnectionError).getMessage())
} else {
print("Error: " + error.localizedDescription)
}
let alertController = UIAlertController(title: "Error Sending Message", message: "The message failed to send.", preferredStyle: .alert)
let okAction = UIAlertAction(title: "Ok", style: .default, handler: nil)
alertController.addAction(okAction)
// Turn this into a reminder eventually because it takes so long to determine that the message failed to send.
self.present(alertController, animated: true, completion: nil)
}
} else {
let err = connectionProcessor.processNewMessage(url: "https://o2lufnhpee.execute-api.us-east-2.amazonaws.com/Development/messageadd", message: toSend)
if (err != nil) {
CognitoHelper.numFails += 1
let alertController = UIAlertController(title: "Error Sending Message", message: "The message failed to send.", preferredStyle: .alert)
let okAction = UIAlertAction(title: "Ok", style: .default, handler: nil)
alertController.addAction(okAction)
// Turn this into a reminder eventually because it takes so long to determine that the message failed to send.
self.present(alertController, animated: true, completion: nil)
} else {
CognitoHelper.numFails = 0
}
}
}

//Credit for how to set up the ImagePickerDelagate goes to: https://www.youtube.com/watch?v=v8r_wD_P3B8
@IBAction
func imageSend() {
Expand Down Expand Up @@ -150,24 +190,31 @@ class ChatLogController: UIViewController, UICollectionViewDelegate, UICollectio
print(content.base64EncodedString().count)
}
let newMessage = Message(messageID: -1, conversationID: conversation!.getConversationID(), content: content, contentType: 1, numFails: CognitoHelper.numFails)

sendMessage(toSend: newMessage)

//print(newMessage.getContent())
let potentialError = connectionProcessor.processNewMessage(url: "https://o2lufnhpee.execute-api.us-east-2.amazonaws.com/Development/messageadd", message: newMessage)
if (potentialError != nil) {
print(potentialError?.getMessage())
}
dismiss(animated: false)
reloadMessages()
}

func reloadMessages() {
messagesShown += 1
do {
messages = try connectionProcessor.processMessages(url: "https://o2lufnhpee.execute-api.us-east-2.amazonaws.com/Development/messagelist/", conversationID: conversation!.getConversationID(), numberToRetrieve: messagesShown)
print(try connectionProcessor.processMessages(url: "https://o2lufnhpee.execute-api.us-east-2.amazonaws.com/Development/messagelist/", conversationID: conversation!.getConversationID(), numberToRetrieve: messagesShown))
} catch let error {
print ((error as! ConnectionError).getMessage())
print("ERROR!!!!!!!!!!!!")
if conversation?.getConverserID() != "N/A" {
do {
let cipher = LocalCipher()
messages = try connectionProcessor.processMessages(url: "https://o2lufnhpee.execute-api.us-east-2.amazonaws.com/Development/messagelist/", conversationID: conversation!.getConversationID(), numberToRetrieve: messagesShown, cipher: MessageCipher(uniqueID: CognitoHelper.user!.getUID(), localAESKey: cipher.getAESFromPass(password: CognitoHelper.password!, username: CognitoHelper.user!.getUID())))
print(messages)
} catch let error {
print (error.localizedDescription)
print("ERROR!!!!!!!!!!!!")
}
} else {
do {
messages = try connectionProcessor.processMessages(url: "https://o2lufnhpee.execute-api.us-east-2.amazonaws.com/Development/messagelist/", conversationID: conversation!.getConversationID(), numberToRetrieve: messagesShown)
} catch let error {
print (error.localizedDescription)
print("ERROR!!!!!!!!!!!!")
}
}
collectionView.reloadData()
}
Expand Down
10 changes: 10 additions & 0 deletions DoctorsNote/DoctorsNote/CognitoHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ class CognitoHelper {

public static let sharedHelper = CognitoHelper()
public static var user: User?
public static var password: String?
public static var numFails: Int = 0

func login(email: String, password: String, onDone: @escaping (_ success: Bool, _ err: AWSMobileClientError)->()) {
print("Password: " + password)
CognitoHelper.password = password
AWSMobileClient.default().signIn(username: email, password: password) { (result, err) in
if let err = err as? AWSMobileClientError {
print("\(err.message)")
Expand Down Expand Up @@ -91,6 +94,13 @@ class CognitoHelper {
if let workHours = attributeMap["custom:work_hours"] {
CognitoHelper.user?.setWorkHours(workHours: workHours)
}
if let question = attributeMap["custom:securityquestion"] {
CognitoHelper.user?.setSecurityQuestion(securityQuestion: question)
}
if let answer = attributeMap["custom:securityanswer"] {
CognitoHelper.user?.setSecurityAnswer(securityAnswer: answer)
}

}

func setHealthcareInformation(role:String, hospital:String, hospitalWebsite: String, healthcareProvider: String, healthcareWebsite:String, onDone: @escaping (_ success: Bool, _ errMessage: String)->Void) {
Expand Down
Loading