2016-05-18 02:51:26 +08:00
|
|
|
/*
|
2018-04-03 20:57:12 +08:00
|
|
|
* Copyright 1998-2018 The OpenSSL Project Authors. All Rights Reserved.
|
2000-02-05 18:39:54 +08:00
|
|
|
*
|
2016-05-18 02:51:26 +08: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 18:52:47 +08:00
|
|
|
*/
|
|
|
|
|
2000-02-05 18:39:54 +08:00
|
|
|
#include <openssl/des.h>
|
|
|
|
#include <openssl/rand.h>
|
1998-12-21 18:52:47 +08:00
|
|
|
|
2001-10-25 05:21:12 +08:00
|
|
|
int DES_random_key(DES_cblock *ret)
|
2015-01-22 11:40:55 +08:00
|
|
|
{
|
|
|
|
do {
|
2017-11-04 03:59:16 +08:00
|
|
|
if (RAND_priv_bytes((unsigned char *)ret, sizeof(DES_cblock)) != 1)
|
2017-10-17 22:04:09 +08:00
|
|
|
return 0;
|
2015-01-22 11:40:55 +08:00
|
|
|
} while (DES_is_weak_key(ret));
|
|
|
|
DES_set_odd_parity(ret);
|
2017-10-09 19:05:58 +08:00
|
|
|
return 1;
|
2015-01-22 11:40:55 +08:00
|
|
|
}
|