xca/lib/dhgen.cpp
Christian Hohnstaedt 4d401792a9 OpenSSL: Avoid all FILE pointer operations, use QFile
For interoprability reason.
To enforce it, set "#define OPENSSL_NO_STDIO 1"
All file access is done by reading/writing from/to BioByteArray()
which is filled by QFile:readAll()

Drop CRYPTO_malloc_debug / CRYPTO_mem_leaks
which is unused and disabled since many years.
2021-11-13 23:53:11 +01:00

40 lines
618 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 "BioByteArray.h"
#include <openssl/rand.h>
#include <openssl/pem.h>
#include <openssl/dh.h>
void DHgen::run()
{
DH *dh = NULL;
BioByteArray b;
try {
dh = DH_new();
Q_CHECK_PTR(dh);
DH_generate_parameters_ex(dh, bits, 2, NULL);
openssl_error();
PEM_write_bio_DHparams(b, dh);
openssl_error();
} catch (errorEx &e) {
err = e;
}
XFile file(fname);
file.open_write();
file.write(b);
if (dh)
DH_free(dh);
}