123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- #include "config.h"
- #include <assert.h>
- #include <string.h>
- #include <bsd/sys/queue.h>
- #include <openssl/x509.h>
- #include <openssl/rsa.h>
- #include <openssl/ssl.h>
- #include <mpi.h>
- #include "qa/questions/questions.h"
- void QA_library_init(void)
- {
-
- SSL_library_init();
- SSL_load_error_strings();
- #ifdef HAVE_OPENMPI
-
- MPI_Init(0 , NULL);
- #endif
- }
- void select_question(const char *sq)
- {
- qa_question_t *q, *tmpq;
- select_all_questions();
- assert(questions.lh_first);
- LIST_FOREACH_SAFE(q, &questions, qs, tmpq)
- if (strcmp(q->name, sq))
- LIST_REMOVE(q, qs);
- }
- int run_question(qa_question_t *q, X509 *crt, RSA *pub)
- {
- RSA *priv;
-
- if (q->setup && q->setup() <= 0)
- return -2;
-
- if (q->test && q->test(crt) < 0)
- return -1;
-
- if (crt && q->ask_crt)
- q->ask_crt(crt);
-
- if (q->ask_rsa &&
- (priv = q->ask_rsa(pub))) {
- #ifdef DEBUG
- PEM_write_RSAPrivateKey(stdout, priv, NULL, NULL, 0, NULL, NULL);
- #endif
- RSA_free(priv);
- return 1;
- }
-
- if (q->teardown && q->teardown() <= 0)
- return -3;
- return 0;
- }
- void select_all_questions(void)
- {
- LIST_INIT(&questions);
- REGISTER_QUESTION(ExampleQuestion);
- REGISTER_QUESTION(WienerQuestion);
- REGISTER_QUESTION(PollardQuestion);
- REGISTER_QUESTION(FermatQuestion);
- REGISTER_QUESTION(MetadataQuestion);
- REGISTER_QUESTION(PollardRhoQuestion);
- REGISTER_QUESTION(WilliamsQuestion);
- REGISTER_QUESTION(DixonQuestion);
- REGISTER_QUESTION(PollardBrentRhoQuestion);
- }
|