]> git.saurik.com Git - apple/security.git/blob - keychain/securityd/Regressions/secd-202-recoverykey.m
Security-59754.41.1.tar.gz
[apple/security.git] / keychain / securityd / Regressions / secd-202-recoverykey.m
1 //
2 // secd-202-recoverykey.c
3 // sec
4 //
5
6 #import <Security/Security.h>
7 #import <Security/SecKeyPriv.h>
8
9 #import <Foundation/Foundation.h>
10
11 #import <Security/SecRecoveryKey.h>
12
13 #import <stdio.h>
14 #import <stdlib.h>
15 #import <unistd.h>
16
17 #import "secd_regressions.h"
18 #import "SOSTestDataSource.h"
19 #import "SOSTestDevice.h"
20
21 #import "SOSRegressionUtilities.h"
22 #import <utilities/SecCFWrappers.h>
23
24 #import "SecdTestKeychainUtilities.h"
25 #include "SOSAccountTesting.h"
26
27 #if SOS_ENABLED
28
29
30 const int kTestRecoveryKeyCount = 3;
31
32 static void testRecoveryKey(void)
33 {
34 SecRecoveryKey *recoveryKey = NULL;
35
36 recoveryKey = SecRKCreateRecoveryKeyWithError(@"AAAA-AAAA-AAAA-AAAA-AAAA-AAAA-AAGW", NULL);
37 ok(recoveryKey, "got recovery key");
38
39 NSData *publicKey = SecRKCopyBackupPublicKey(recoveryKey);
40 ok(publicKey, "got publicKey");
41 }
42
43 const int kTestRecoveryKeyBasicNumberIterations = 100;
44 const int kTestRecoveryKeyBasicCount = 1 * kTestRecoveryKeyBasicNumberIterations;
45
46 static void testRecoveryKeyBasic(void)
47 {
48 NSString *recoveryKey = NULL;
49 NSError *error = NULL;
50 int n;
51
52 for (n = 0; n < kTestRecoveryKeyBasicNumberIterations; n++) {
53 recoveryKey = SecRKCreateRecoveryKeyString(&error);
54 ok(recoveryKey, "SecRKCreateRecoveryKeyString: %@", error);
55 }
56 }
57
58 #endif
59
60 int secd_202_recoverykey(int argc, char *const *argv)
61 {
62 #if SOS_ENABLED
63 plan_tests(kTestRecoveryKeyCount + kTestRecoveryKeyBasicCount);
64 secd_test_setup_temp_keychain(__FUNCTION__, NULL);
65 testRecoveryKeyBasic();
66 testRecoveryKey();
67 #else
68 plan_tests(0);
69 #endif
70 return 0;
71 }