Standardize progress callback for dhparam, dsaparam, etc.
[openssl.git] / apps / lib / s_cb.c
index 77ddbc9d7b5152c67676af370634727be007c195..d6d49d666cac9227e78eb745c04b7fc62d0d29d7 100644 (file)
@@ -1574,3 +1574,16 @@ void ssl_print_secure_renegotiation_notes(BIO *bio, SSL *s)
         BIO_printf(bio, "This TLS version forbids renegotiation.\n");
     }
 }
+
+int progress_cb(EVP_PKEY_CTX *ctx)
+{
+    BIO *b = EVP_PKEY_CTX_get_app_data(ctx);
+    int p = EVP_PKEY_CTX_get_keygen_info(ctx, 0);
+    static const char symbols[] = ".+*\n";
+    char c = (p >= 0 && (size_t)p <= sizeof(symbols) - 1) ? symbols[p] : '?';
+
+    BIO_write(b, &c, 1);
+    (void)BIO_flush(b);
+    return 1;
+}
+