Quellcode durchsuchen

Oops, forgot primes.h header and indiana.c.

Michele Orrù vor 11 Jahren
Ursprung
Commit
579a54f77b
2 geänderte Dateien mit 70 neuen und 0 gelöschten Zeilen
  1. 52 0
      src/indiana.c
  2. 18 0
      src/questions/include/primes.h

+ 52 - 0
src/indiana.c

@@ -0,0 +1,52 @@
+/**
+ * \file indiana.c
+ * \brief Exploring random ssl connections, experimening with the cluster.
+ *
+ */
+#include <stdlib.h>
+
+#include <mpi.h>
+#include <openssl/x509.h>
+#include <openssl/rsa.h>
+
+#include "qa/qa_sock.h"
+#include "qa/questions/questions.h"
+
+extern qa_question_t MetadataQuestion;
+
+int main(int argc, char **argv)
+{
+  int proc, procs;
+  long i;
+  char *file = "sites.txt";
+  FILE *fp;
+  char site[128];
+  X509 *crt;
+  RSA *rsa;
+
+  QA_library_init();
+
+  MPI_Comm_rank(MPI_COMM_WORLD, &proc);
+  MPI_Comm_size(MPI_COMM_WORLD, &procs);
+
+  fp = fopen(file, "r");
+  if (!fp) return EXIT_FAILURE;
+
+  for (i=0; fscanf(fp, "%s", site) == 1; i = (i+1) % procs) {
+    if (i != proc) continue;
+
+    crt = get_remote_cert(site);
+    if (!crt) {
+      fprintf(stderr, "NO SSL: '%s'\n", site);
+      continue;
+    }
+
+    rsa = X509_get_pubkey(crt)->pkey.rsa;
+    run_question(&MetadataQuestion, crt, rsa);
+    X509_free(crt);
+  }
+
+  QA_library_del();
+  return EXIT_SUCCESS;
+
+}

+ 18 - 0
src/questions/include/primes.h

@@ -0,0 +1,18 @@
+#ifndef _QA_PRIMES_H_
+#define _QA_PRIMES_H_
+
+
+/* prime iterator object, now a file descriptor. */
+typedef FILE pit_t;
+
+pit_t *primes_init(void);
+
+int primes_next(pit_t *, BIGNUM *p);
+
+void prime_iterator_free(pit_t *it);
+
+int smooth(BIGNUM *x, BN_CTX *ctx, char* v, size_t thresh);
+
+#define primes_tell(it) ftell(it)
+#define primes_seek(it, offset) fseek(it, offset, SEEK_SET)
+#endif /* _QA_PRIMES_H_ */