]> git.saurik.com Git - apple/security.git/blob - OSX/sec/securityd/Regressions/secd-202-recoverykey.m
Security-59306.11.20.tar.gz
[apple/security.git] / OSX / sec / 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
26
27 const int kTestRecoveryKeyCount = 3;
28
29 static void testRecoveryKey(void)
30 {
31 SecRecoveryKey *recoveryKey = NULL;
32
33 recoveryKey = SecRKCreateRecoveryKeyWithError(@"AAAA-AAAA-AAAA-AAAA-AAAA-AAAA-AAGW", NULL);
34 ok(recoveryKey, "got recovery key");
35
36 NSData *publicKey = SecRKCopyBackupPublicKey(recoveryKey);
37 ok(publicKey, "got publicKey");
38 }
39
40 const int kTestRecoveryKeyBasicNumberIterations = 100;
41 const int kTestRecoveryKeyBasicCount = 1 * kTestRecoveryKeyBasicNumberIterations;
42
43 static void testRecoveryKeyBasic(void)
44 {
45 NSString *recoveryKey = NULL;
46 NSError *error = NULL;
47 int n;
48
49 for (n = 0; n < kTestRecoveryKeyBasicNumberIterations; n++) {
50 recoveryKey = SecRKCreateRecoveryKeyString(&error);
51 ok(recoveryKey, "SecRKCreateRecoveryKeyString: %@", error);
52 }
53 }
54
55
56 int secd_202_recoverykey(int argc, char *const *argv)
57 {
58 plan_tests(kTestRecoveryKeyCount + kTestRecoveryKeyBasicCount);
59
60 secd_test_setup_temp_keychain(__FUNCTION__, NULL);
61
62 testRecoveryKeyBasic();
63
64 testRecoveryKey();
65
66 return 0;
67 }