Revert "Imported upstream version 1.6.7"
[platform/upstream/cryptsetup.git] / lib / crypto_backend / crypto_nettle.c
index 2fc2ce6..21820d9 100644 (file)
@@ -2,18 +2,20 @@
  * Nettle crypto backend implementation
  *
  * Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2011-2012, Milan Broz
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
+ * This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful,
+ * This file is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
@@ -274,3 +276,18 @@ int crypt_backend_rng(char *buffer, size_t length, int quality, int fips)
 {
        return -EINVAL;
 }
+
+/* PBKDF */
+int crypt_pbkdf(const char *kdf, const char *hash,
+               const char *password, size_t password_length,
+               const char *salt, size_t salt_length,
+               char *key, size_t key_length,
+               unsigned int iterations)
+{
+       if (!kdf || strncmp(kdf, "pbkdf2", 6))
+               return -EINVAL;
+
+       /* FIXME: switch to internal implementation in Nettle 2.6 */
+       return pkcs5_pbkdf2(hash, password, password_length, salt, salt_length,
+                           iterations, key_length, key);
+}