Blame crypto/des/rand_key.c

Packit Service 084de1
/*
Packit Service 084de1
 * Copyright 1998-2018 The OpenSSL Project Authors. All Rights Reserved.
Packit Service 084de1
 *
Packit Service 084de1
 * Licensed under the OpenSSL license (the "License").  You may not use
Packit Service 084de1
 * this file except in compliance with the License.  You can obtain a copy
Packit Service 084de1
 * in the file LICENSE in the source distribution or at
Packit Service 084de1
 * https://www.openssl.org/source/license.html
Packit Service 084de1
 */
Packit Service 084de1
Packit Service 084de1
#include <openssl/des.h>
Packit Service 084de1
#include <openssl/rand.h>
Packit Service 084de1
Packit Service 084de1
int DES_random_key(DES_cblock *ret)
Packit Service 084de1
{
Packit Service 084de1
    do {
Packit Service 084de1
        if (RAND_priv_bytes((unsigned char *)ret, sizeof(DES_cblock)) != 1)
Packit Service 084de1
            return 0;
Packit Service 084de1
    } while (DES_is_weak_key(ret));
Packit Service 084de1
    DES_set_odd_parity(ret);
Packit Service 084de1
    return 1;
Packit Service 084de1
}