|
@@ -48,6 +48,38 @@ void select_question(const char *sq)
|
|
|
}
|
|
|
|
|
|
|
|
|
+/**
|
|
|
+ * \brief Print out a valid RSA Private Key.
|
|
|
+ *
|
|
|
+ */
|
|
|
+static void
|
|
|
+print_rsa_private(RSA *rsa)
|
|
|
+{
|
|
|
+ size_t i;
|
|
|
+ char *dec, *hex;
|
|
|
+ const struct {
|
|
|
+ const char *desc;
|
|
|
+ BIGNUM *n;
|
|
|
+ } items[5] = {
|
|
|
+ {"Public Modulus", rsa->n},
|
|
|
+ {"Prime Factor p", rsa->p},
|
|
|
+ {"Prime Factor q", rsa->q},
|
|
|
+ {"Public Exponent", rsa->e},
|
|
|
+ {"Private Exponent", rsa->d},
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ assert(rsa); /* && rsa->p && rsa->q && rsa->e); */
|
|
|
+ for (i=0; i!=5; i++) {
|
|
|
+ if (!items[i].n) continue;
|
|
|
+ dec = BN_bn2dec(items[i].n);
|
|
|
+ hex = BN_bn2hex(items[i].n);
|
|
|
+ fprintf(stdout, "\t%-22s : %-15s (0x%s)\n", items[i].desc, dec, hex);
|
|
|
+ OPENSSL_free(dec);
|
|
|
+ OPENSSL_free(hex);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* \brief Run a specific question, returning the measure of security probed.
|
|
|
* \return -1 if the question `q` is not suited for attacking the certificate.
|
|
@@ -74,8 +106,8 @@ int run_question(qa_question_t *q, X509 *crt, RSA *pub)
|
|
|
if (q->ask_rsa &&
|
|
|
(priv = q->ask_rsa(pub))) {
|
|
|
#ifdef DEBUG
|
|
|
- PEM_write_RSAPrivateKey(stdout, priv, NULL, NULL, 0, NULL, NULL);
|
|
|
- // print_rsa_private(priv);
|
|
|
+ //PEM_write_RSAPrivateKey(stdout, priv, NULL, NULL, 0, NULL, NULL);
|
|
|
+ print_rsa_private(priv);
|
|
|
#endif
|
|
|
RSA_free(priv);
|
|
|
return 1;
|