2016-05-17 18:51:26 +00:00
|
|
|
/*
|
|
|
|
* Copyright 1998-2016 The OpenSSL Project Authors. All Rights Reserved.
|
2000-02-05 10:39:54 +00:00
|
|
|
*
|
2016-05-17 18:51:26 +00:00
|
|
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
1998-12-21 10:52:47 +00:00
|
|
|
*/
|
|
|
|
|
2000-02-05 10:39:54 +00:00
|
|
|
#include <openssl/des.h>
|
|
|
|
#include <openssl/rand.h>
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2001-10-24 21:21:12 +00:00
|
|
|
int DES_random_key(DES_cblock *ret)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
|
|
|
do {
|
2017-11-03 19:59:16 +00:00
|
|
|
if (RAND_priv_bytes((unsigned char *)ret, sizeof(DES_cblock)) != 1)
|
2017-10-17 14:04:09 +00:00
|
|
|
return 0;
|
2015-01-22 03:40:55 +00:00
|
|
|
} while (DES_is_weak_key(ret));
|
|
|
|
DES_set_odd_parity(ret);
|
2017-10-09 11:05:58 +00:00
|
|
|
return 1;
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|