summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/e_des.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/evp/e_des.c')
-rw-r--r--src/lib/libcrypto/evp/e_des.c56
1 files changed, 24 insertions, 32 deletions
diff --git a/src/lib/libcrypto/evp/e_des.c b/src/lib/libcrypto/evp/e_des.c
index 1064c0b7cc..bf037591be 100644
--- a/src/lib/libcrypto/evp/e_des.c
+++ b/src/lib/libcrypto/evp/e_des.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: e_des.c,v 1.16 2022/09/04 08:18:07 jsing Exp $ */ 1/* $OpenBSD: e_des.c,v 1.17 2022/09/04 13:17:18 jsing 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 *
@@ -68,9 +68,29 @@
68 68
69#include "evp_locl.h" 69#include "evp_locl.h"
70 70
71static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 71static int
72 const unsigned char *iv, int enc); 72des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
73static int des_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr); 73 const unsigned char *iv, int enc)
74{
75 DES_cblock *deskey = (DES_cblock *)key;
76
77 DES_set_key_unchecked(deskey, ctx->cipher_data);
78 return 1;
79}
80
81static int
82des_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
83{
84 switch (type) {
85 case EVP_CTRL_RAND_KEY:
86 if (DES_random_key((DES_cblock *)ptr) == 0)
87 return 0;
88 return 1;
89
90 default:
91 return -1;
92 }
93}
74 94
75static int 95static int
76des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 96des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
@@ -278,7 +298,6 @@ EVP_des_ecb(void)
278 return &des_ecb; 298 return &des_ecb;
279} 299}
280 300
281
282static const EVP_CIPHER des_cfb1 = { 301static const EVP_CIPHER des_cfb1 = {
283 .nid = NID_des_cfb1, 302 .nid = NID_des_cfb1,
284 .block_size = 1, 303 .block_size = 1,
@@ -301,7 +320,6 @@ EVP_des_cfb1(void)
301 return &des_cfb1; 320 return &des_cfb1;
302} 321}
303 322
304
305static const EVP_CIPHER des_cfb8 = { 323static const EVP_CIPHER des_cfb8 = {
306 .nid = NID_des_cfb8, 324 .nid = NID_des_cfb8,
307 .block_size = 1, 325 .block_size = 1,
@@ -323,30 +341,4 @@ EVP_des_cfb8(void)
323{ 341{
324 return &des_cfb8; 342 return &des_cfb8;
325} 343}
326
327
328static int
329des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
330 const unsigned char *iv, int enc)
331{
332 DES_cblock *deskey = (DES_cblock *)key;
333
334 DES_set_key_unchecked(deskey, ctx->cipher_data);
335 return 1;
336}
337
338static int
339des_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
340{
341 switch (type) {
342 case EVP_CTRL_RAND_KEY:
343 if (DES_random_key((DES_cblock *)ptr) == 0)
344 return 0;
345 return 1;
346
347 default:
348 return -1;
349 }
350}
351
352#endif 344#endif