From the course: iOS Development: Security
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Defining the asymmetric key accessors - iOS Tutorial
From the course: iOS Development: Security
Defining the asymmetric key accessors
- [Instructor] Let's complete the asymmetric key generation by exposing the properties required to access the private and the public key. I create a lazy computed property called private key. Let's scroll up. Lazy var private key of type SecKey. So it's a cryptographic key, obviously, and let's implement it. I declared it as lazy to make sure that it only gets initialized once when we refer to the property for the first time. I first look up the private key in the key chain by calling retrieve private key. I use the guard statement and condition of try when calling the method, and if the key is not valid or anything fails. If the private key has been added to the key chain, I call generate private key to create it. As you may recall, generate private key also adds the private key to the key chain. So I simply return the result of calling generate private key as I return the result of calling the retrieve private key. Next, I define the property for the public key. This is also a lazy…
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)
-