summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Suhren <suhren.stefan@fh-swf.de>2015-09-04 22:21:44 +0200
committerStefan Suhren <suhren.stefan@fh-swf.de>2015-09-04 22:33:42 +0200
commit9d10c7b552f2eb314f56ff4944ce7481fe6b2433 (patch)
treed1f8b29e0eb20153826ff6451a62e67d941eff0b
parent240930cdb922f3fed2442234ce6fdeaf67aaed33 (diff)
downloadsrc-9d10c7b552f2eb314f56ff4944ce7481fe6b2433.tar.gz
src-9d10c7b552f2eb314f56ff4944ce7481fe6b2433.zip
Erste Version der SchlÃsselerzeugung mittel EVP
-rw-r--r--crypt/hybridcrypt.cpp31
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)