xca/lib/dhgen.cpp
Christian Hohnstaedt 0e5af2e452 Replace check_oom() by Q_CHECK_PTR()
Qt offers the functionality. No need to invent it ourselves.
2021-06-01 17:48:37 +02:00

36 lines
564 B
C++

/* vi: set sw=4 ts=4:
*
* Copyright (C) 2001 Christian Hohnstaedt.
*
* All rights reserved.
*/
#include "func.h"
#include "dhgen.h"
#include "entropy.h"
#include "xfile.h"
#include <openssl/rand.h>
#include <openssl/pem.h>
#include <openssl/dh.h>
void DHgen::run()
{
DH *dh = NULL;
try {
dh = DH_new();
Q_CHECK_PTR(dh);
DH_generate_parameters_ex(dh, bits, 2, NULL);
openssl_error();
XFile file(fname);
file.open_write();
PEM_write_DHparams(file.fp(), dh);
openssl_error();
} catch (errorEx &e) {
err = e;
}
if (dh)
DH_free(dh);
}