|  | @@ -75,19 +75,59 @@ int qa_init(const struct qa_conf* conf)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  void qa_dispose(X509 *crt)
 | 
	
		
			
				|  |  |  {
 | 
	
		
			
				|  |  | -  RSA *rsa;
 | 
	
		
			
				|  |  | +  RSA *pub = X509_get_pubkey(crt)->pkey.rsa;
 | 
	
		
			
				|  |  | +  RSA *priv;
 | 
	
		
			
				|  |  |    qa_question_t *q;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  rsa = X509_get_pubkey(crt)->pkey.rsa;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |    printf("[+] Certificate acquired\n");
 | 
	
		
			
				|  |  |    LIST_FOREACH(q, &questions, qs) {
 | 
	
		
			
				|  |  |      printf( "[-] Running: %s\n", q->pretty_name);
 | 
	
		
			
				|  |  | -    if (q->setup)    q->setup();
 | 
	
		
			
				|  |  | -    if (q->test)     q->test(crt);
 | 
	
		
			
				|  |  | -    if (q->ask_rsa)  q->ask_rsa(rsa);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /*
 | 
	
		
			
				|  |  | +     * Run setup. If it fails, then print an error message and go to the next
 | 
	
		
			
				|  |  | +     * question.
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    if (q->setup && q->setup() <= 0)  {
 | 
	
		
			
				|  |  | +      fprintf(stderr, "[x] Unexpected error loading question %s\n", q->pretty_name);
 | 
	
		
			
				|  |  | +      continue;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /*
 | 
	
		
			
				|  |  | +     * Run test. If the test is undecidible or either okk, go on. Otherwise,
 | 
	
		
			
				|  |  | +     * print an error message and go to the next question.
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    if (q->test && q->test(crt) < 0) {
 | 
	
		
			
				|  |  | +      fprintf(stderr, "[|] Question %s cannot attack the given certificate.\n", q->pretty_name);
 | 
	
		
			
				|  |  | +      continue;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /*
 | 
	
		
			
				|  |  | +     * Attempt to attack RSA. If the attack went ok, there's no need to go
 | 
	
		
			
				|  |  | +     * on. Print out a nice message and then quit.
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    if (q->ask_rsa &&
 | 
	
		
			
				|  |  | +        (priv = q->ask_rsa(pub))) {
 | 
	
		
			
				|  |  | +      fprintf(stderr, "[\\] Key Broken using %s.\n", q->pretty_name);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /*
 | 
	
		
			
				|  |  | +     * Attempt to attack the X509 certificate.
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  |      if (q->ask_crt)  q->ask_crt(crt);
 | 
	
		
			
				|  |  | -    if (q->teardown) q->teardown();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /*
 | 
	
		
			
				|  |  | +     * Shut down the given question. If it fails, print an error messae and go
 | 
	
		
			
				|  |  | +     * on.
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    if (q->teardown && q->teardown() <= 0) {
 | 
	
		
			
				|  |  | +      fprintf(stderr, "[x] Unexpected error shutting down question %s.\n", q->pretty_name);
 | 
	
		
			
				|  |  | +      continue;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +  /*
 | 
	
		
			
				|  |  | +   *  Key seems resistent: exit with status -1
 | 
	
		
			
				|  |  | +   */
 | 
	
		
			
				|  |  | +  exit(-1);
 | 
	
		
			
				|  |  |  }
 |