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.
Retrieving the private key from the Keychain - iOS Tutorial
From the course: iOS Development: Security
Retrieving the private key from the Keychain
- [Instructor] We should prevent generating multiple keys for the same tag. Thus I'm going to add a method that checks whether a key with a given tag has been added to the keychain. It's a private method. Private func, and I'm going to call it retrievePrivateKey. The method returns an optional cryptographic key object and it may throw an error. Next, I create a query dictionary by providing the attributes that identify the key. Let privateKeyQuery. it has a key of type string and the value should be any, and now let's initialize it. The items class should be kSecClass key, which denotes a cryptographic key item. Again, I need to cast it to a string in order to use it in a Swift dictionary, and the value is kSecClassKey. The application tag is the unique tag data. So, for the key kSecAttrApplicationTag, again as string. I'm going to set the tag data. The key type should be of type RSA. kSecAttrKeyType and I set it to a constant which translates to RSA keys. And finally I indicate that…
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)
-