Add HMAC
[iotcloud.git] / version2 / src / C / Crypto.cc
index 3c66c90..9b1da86 100644 (file)
@@ -1 +1,17 @@
 #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;
+}
+
+Array<char> * AESKey::getKey() {
+       return key;
+}