2 // secd-202-recoverykey.c
6 #import <Security/Security.h>
7 #import <Security/SecKeyPriv.h>
9 #import <Foundation/Foundation.h>
11 #import <Security/SecRecoveryKey.h>
17 #import "secd_regressions.h"
18 #import "SOSTestDataSource.h"
19 #import "SOSTestDevice.h"
21 #import "SOSRegressionUtilities.h"
22 #import <utilities/SecCFWrappers.h>
24 #import "SecdTestKeychainUtilities.h"
27 const int kTestRecoveryKeyCount = 3;
29 static void testRecoveryKey(void)
31 SecRecoveryKey *recoveryKey = NULL;
33 recoveryKey = SecRKCreateRecoveryKey(@"AAAA-AAAA-AAAA-AAAA-AAAA-AAAA-AAGW");
34 ok(recoveryKey, "got recovery key");
36 NSData *publicKey = SecRKCopyBackupPublicKey(recoveryKey);
37 ok(publicKey, "got publicKey");
40 const int kTestRecoveryKeyBasicNumberIterations = 100;
41 const int kTestRecoveryKeyBasicCount = 1 * kTestRecoveryKeyBasicNumberIterations;
43 static void testRecoveryKeyBasic(void)
45 NSString *recoveryKey = NULL;
46 NSError *error = NULL;
49 for (n = 0; n < kTestRecoveryKeyBasicNumberIterations; n++) {
50 recoveryKey = SecRKCreateRecoveryKeyString(&error);
51 ok(recoveryKey, "SecRKCreateRecoveryKeyString: %@", error);
56 int secd_202_recoverykey(int argc, char *const *argv)
58 plan_tests(kTestRecoveryKeyCount + kTestRecoveryKeyBasicCount);
60 secd_test_setup_temp_keychain(__FUNCTION__, NULL);
62 testRecoveryKeyBasic();