|
@@ -16,6 +16,14 @@
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
|
|
+#include "iridium-config.h"
|
|
|
|
|
+
|
|
|
|
|
+#ifdef HAVE_LINUX_RANDOM_H
|
|
|
|
|
+#include <linux/random.h>
|
|
|
|
|
+#include <unistd.h>
|
|
|
|
|
+#include <sys/syscall.h>
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
|
#include <string.h>
|
|
#include <string.h>
|
|
|
#include <nettle/aes.h>
|
|
#include <nettle/aes.h>
|
|
@@ -28,6 +36,9 @@
|
|
|
IridiumAuthParams *
|
|
IridiumAuthParams *
|
|
|
iridium_crypto_auth_params_new (void)
|
|
iridium_crypto_auth_params_new (void)
|
|
|
{
|
|
{
|
|
|
|
|
+#if defined(HAVE_LINUX_RANDOM_H) && !defined(HAVE_PREDEFINED_SALT)
|
|
|
|
|
+ guint8 salt[32];
|
|
|
|
|
+#endif
|
|
|
IridiumAuthParams *params;
|
|
IridiumAuthParams *params;
|
|
|
|
|
|
|
|
params = g_new0 (IridiumAuthParams, 1);
|
|
params = g_new0 (IridiumAuthParams, 1);
|
|
@@ -35,7 +46,15 @@ iridium_crypto_auth_params_new (void)
|
|
|
params->hash = IRIDIUM_CRYPTO_SF_HASH_SHA512;
|
|
params->hash = IRIDIUM_CRYPTO_SF_HASH_SHA512;
|
|
|
params->cost = 101000;
|
|
params->cost = 101000;
|
|
|
params->key_size = 512;
|
|
params->key_size = 512;
|
|
|
- params->salt = g_strdup ("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
|
|
|
|
|
|
|
+
|
|
|
|
|
+#if defined(HAVE_PREDEFINED_SALT)
|
|
|
|
|
+ params->salt = g_strdup (PREDEFINED_SALT);
|
|
|
|
|
+#elif defined(HAVE_LINUX_RANDOM_H)
|
|
|
|
|
+ syscall(SYS_getrandom, salt, 32, 0);
|
|
|
|
|
+ params->salt = iridium_crypto_hexlify(salt, 32);
|
|
|
|
|
+#else
|
|
|
|
|
+#error "No random source other than getrandom() implemented yet"
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
return params;
|
|
return params;
|
|
|
}
|
|
}
|