diff options
author | tb <> | 2023-12-20 06:28:04 +0000 |
---|---|---|
committer | tb <> | 2023-12-20 06:28:04 +0000 |
commit | a9cfefaa522175c4807d06bc89db37662df921fb (patch) | |
tree | 9d7f2b4d85018c448bfac2b2337cbf21bd97c149 /src/lib/libcrypto/des/set_key.c | |
parent | c5e25d4ccdb27c5439de7f15ac8c6d894c8cdf3b (diff) | |
download | openbsd-a9cfefaa522175c4807d06bc89db37662df921fb.tar.gz openbsd-a9cfefaa522175c4807d06bc89db37662df921fb.tar.bz2 openbsd-a9cfefaa522175c4807d06bc89db37662df921fb.zip |
DES_random_key() sets the key
There's no need to have 60 lines of license for 4 lines of actual code.
Move DES_random_key() to set_key.c.
Diffstat (limited to 'src/lib/libcrypto/des/set_key.c')
-rw-r--r-- | src/lib/libcrypto/des/set_key.c | 15 |
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 | ||
69 | int DES_check_key = 0; /* defaults to false */ | 72 | int 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 | |||
405 | int | ||
406 | DES_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 | } | ||