summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/des/set_key.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/des/set_key.c')
-rw-r--r--src/lib/libcrypto/des/set_key.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/lib/libcrypto/des/set_key.c b/src/lib/libcrypto/des/set_key.c
index c1fd02846f..d1b6fa6e8d 100644
--- a/src/lib/libcrypto/des/set_key.c
+++ b/src/lib/libcrypto/des/set_key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: set_key.c,v 1.24 2023/12/20 06:22:27 tb Exp $ */ 1/* $OpenBSD: set_key.c,v 1.25 2023/12/20 06:28:04 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -63,7 +63,10 @@
63 * 1.1 added norm_expand_bits 63 * 1.1 added norm_expand_bits
64 * 1.0 First working version 64 * 1.0 First working version
65 */ 65 */
66#include <stdlib.h>
67
66#include <openssl/crypto.h> 68#include <openssl/crypto.h>
69
67#include "des_local.h" 70#include "des_local.h"
68 71
69int DES_check_key = 0; /* defaults to false */ 72int DES_check_key = 0; /* defaults to false */
@@ -398,3 +401,13 @@ DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule)
398{ 401{
399 return (DES_set_key(key, schedule)); 402 return (DES_set_key(key, schedule));
400} 403}
404
405int
406DES_random_key(DES_cblock *ret)
407{
408 do {
409 arc4random_buf(ret, sizeof(DES_cblock));
410 DES_set_odd_parity(ret);
411 } while (DES_is_weak_key(ret));
412 return (1);
413}