Add key generation
[iotcloud.git] / version2 / src / C / Crypto.cc
index 3c66c90..e54d541 100644 (file)
@@ -1 +1,13 @@
 #include "Crypto.h"
+#include "pbkdf2-sha256.h"
+
+AESKey::AESKey(Array<char> *password, Array<char> *salt, int iterationCount, int keyLength) {
+       key = new Array<char>(keyLength);
+       PKCS5_PBKDF2_HMAC((unsigned char *) password->internalArray(), password->length(),
+                                                                               (unsigned char *) salt->internalArray(), salt->length(),
+                                                                               iterationCount, keyLength, (unsigned char *) key->internalArray());
+}
+
+AESKey::~AESKey() {
+       delete key;
+}