]>
git.saurik.com Git - apple/security.git/blob - Security/sec/SOSCircle/Regressions/sc-31-peerinfo-simplefuzz.c
4 * Copyright (c) 2012-2014 Apple Inc. All Rights Reserved.
9 #include <Security/SecBase.h>
10 #include <Security/SecItem.h>
11 #include <Security/SecKey.h>
12 #include <Security/SecKeyPriv.h>
14 #include <SecureObjectSync/SOSCircle.h>
15 #include <SecureObjectSync/SOSPeerInfo.h>
16 #include <SecureObjectSync/SOSInternal.h>
17 #include <SecureObjectSync/SOSUserKeygen.h>
19 #include <utilities/SecCFWrappers.h>
21 #include <CoreFoundation/CoreFoundation.h>
26 #include "SOSCircle_regressions.h"
28 #include "SOSRegressionUtilities.h"
31 #include <MobileGestalt.h>
34 static unsigned long kTestCount
= 2;
35 static unsigned long kTestFuzzerCount
= 20000;
37 static void tests(void)
39 SecKeyRef signingKey
= NULL
;
40 SOSFullPeerInfoRef fpi
= SOSCreateFullPeerInfoFromName(CFSTR("Test Peer"), &signingKey
, NULL
);
41 SOSPeerInfoRef pi
= SOSFullPeerInfoGetPeerInfo(fpi
);
46 ok(NULL
!= pi
, "info creation");
50 const uint8_t *buffer_p
= SOSPeerInfoEncodeToDER(pi
, NULL
, buffer
, buffer
+ sizeof(buffer
));
52 ok(buffer_p
!= NULL
, "encode");
54 size_t length
= (buffer
+ sizeof(buffer
)) - buffer_p
;
56 uint8_t buffer2
[length
];
57 if(buffer_p
== NULL
) goto errOut
;
59 for (count
= 0; count
< kTestFuzzerCount
; count
++) {
60 memcpy(buffer2
, buffer_p
, length
);
62 const uint8_t *startp
= buffer2
;
64 buffer2
[arc4random_uniform((u_int32_t
)length
)] = arc4random() & 0xff;
66 SOSPeerInfoRef pi2
= SOSPeerInfoCreateFromDER(NULL
, NULL
, &startp
, buffer2
+ length
);
72 CFReleaseNull(signingKey
);
76 int sc_31_peerinfo(int argc
, char *const *argv
)
78 plan_tests((int)(kTestCount
+ kTestFuzzerCount
));