diff options
| -rw-r--r-- | crypt/hybridcrypt.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
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) |
