From 9d10c7b552f2eb314f56ff4944ce7481fe6b2433 Mon Sep 17 00:00:00 2001 From: Stefan Suhren Date: Fri, 4 Sep 2015 22:21:44 +0200 Subject: Erste Version der SchlÃsselerzeugung mittel EVP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crypt/hybridcrypt.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'crypt') diff --git a/crypt/hybridcrypt.cpp b/crypt/hybridcrypt.cpp index 0802397..7376459 100644 --- a/crypt/hybridcrypt.cpp +++ b/crypt/hybridcrypt.cpp @@ -61,7 +61,38 @@ void HybridCrypt::decrypt(QString infileName, QString outfileName) void HybridCrypt::createKeypair() { - + if (isCsprngSeeded()) + { + // Lege Schlüsselkontextvariable an + EVP_PKEY_CTX *ctx = NULL; + + // Erzeuge den Schlüsselkontext + if (!(ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, NULL))) + { + throwOpenSslException(); + } + + // Initialisiere den Schlüsselgenerator + if (EVP_PKEY_keygen_init(ctx) <= 0) + { + throwOpenSslException(); + } + + // Lege den Schlüssel mit 2048 Bit an + if (EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, 2048) <= 0) + { + throwOpenSslException(); + } + + // Erzeuge den Schlüssel + if (EVP_PKEY_keygen(ctx, &privateUserkey) <= 0) + { + throwOpenSslException(); + } + + // Räume den Schlüsselkontext ab + EVP_PKEY_CTX_free(ctx); + } } void HybridCrypt::importUserKeypair(QString keyfileName, QString password) -- cgit v1.2.3-70-g09d2