-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.m
46 lines (36 loc) · 1.58 KB
/
main.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#import "YDManager.h"
#import "YDPrettyConsole.h"
int main(void) {
@autoreleasepool {
YDManager *mngr = [[YDManager alloc] init];
if(mngr == NULL)
[YDManager dirtyExit];
YDFindFactors *findfactors = [[YDFindFactors alloc]initWithPubKey:mngr.keyToAnalyze.foundDictItems];
if(findfactors == NULL)
[YDManager dirtyExit];
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
@autoreleasepool {
NSError *error = NULL;
BOOL result = NO;
[findfactors pubKeySummary];
[findfactors.progressBar setRunning:YES];
[findfactors factorize];
[findfactors.progressBar setRunning:NO];
[findfactors postFactorize];
result = [findfactors totient:&error];
if (!result)
[mngr timeTaken:&error];
result = [findfactors deriveMultiplicativeInverse:&error];
if (!result)
[mngr timeTaken:&error];
[findfactors decryptMessage];
}
[mngr timeTaken:NULL];
dispatch_semaphore_signal(semaphore);
});
dispatch_time_t killTimer = dispatch_time(DISPATCH_TIME_NOW, KILLTIMER * NSEC_PER_SEC);
dispatch_semaphore_wait(semaphore, killTimer);
}
return 0;
}