From the course: iOS Development: Security
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Performing asymmetric decryption - iOS Tutorial
From the course: iOS Development: Security
Performing asymmetric decryption
- [Narrator] The KeychainFacade class can generate the asymmetric key pair and it can also encrypt the string. Now, let's add the decrypt feature, too. I declare a new method called decrypt. It takes the encrypted data as input. The method returns the decrypted data, or nil if something goes wrong. So let's return an optional Data. The method may also throw an error, so let's mark it as such. Let me scroll up a bit, alright. Next, we'll check if we have a private key. We need the private key for asymmetric decryption. Guard let secKey equals privateKey. If there is no privateKey, we should throw a dedicated error, KeychainFacadeError, and we need a new case when there is no privateKey defined. So let's scroll back, and I'm going to add a case noPrivateKey. Next, I check if the hardware supports the given algorithm. It's the same logic we used in the encrypt method, so I can copy and paste those lines of code, and let's paste it here. To decrypt the data, we'll rely on the secKey…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
(Locked)
Asymmetric cryptography overview1m 25s
-
(Locked)
Creating the private key5m 49s
-
(Locked)
Retrieving the private key from the Keychain4m 32s
-
(Locked)
Defining the asymmetric key accessors2m 9s
-
(Locked)
Performing asymmetric encryption4m 10s
-
(Locked)
Performing asymmetric encryption continued2m 26s
-
(Locked)
Performing asymmetric decryption3m 41s
-
(Locked)
Asymmetric encryption and decryption demo3m 9s
-
(Locked)
-