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"
25 #include "SOSAccountTesting.h"
30 const int kTestRecoveryKeyCount = 3;
32 static void testRecoveryKey(void)
34 SecRecoveryKey *recoveryKey = NULL;
36 recoveryKey = SecRKCreateRecoveryKeyWithError(@"AAAA-AAAA-AAAA-AAAA-AAAA-AAAA-AAGW", NULL);
37 ok(recoveryKey, "got recovery key");
39 NSData *publicKey = SecRKCopyBackupPublicKey(recoveryKey);
40 ok(publicKey, "got publicKey");
43 const int kTestRecoveryKeyBasicNumberIterations = 100;
44 const int kTestRecoveryKeyBasicCount = 1 * kTestRecoveryKeyBasicNumberIterations;
46 static void testRecoveryKeyBasic(void)
48 NSString *recoveryKey = NULL;
49 NSError *error = NULL;
52 for (n = 0; n < kTestRecoveryKeyBasicNumberIterations; n++) {
53 recoveryKey = SecRKCreateRecoveryKeyString(&error);
54 ok(recoveryKey, "SecRKCreateRecoveryKeyString: %@", error);
60 int secd_202_recoverykey(int argc, char *const *argv)
63 plan_tests(kTestRecoveryKeyCount + kTestRecoveryKeyBasicCount);
64 secd_test_setup_temp_keychain(__FUNCTION__, NULL);
65 testRecoveryKeyBasic();