diff options
author | jsing <> | 2022-07-30 17:11:38 +0000 |
---|---|---|
committer | jsing <> | 2022-07-30 17:11:38 +0000 |
commit | db8899e993c8d6b8af310a3e928b7caf4e76aabb (patch) | |
tree | 95d8ef301aad499e3f372ee8eb44642ad2735304 /src | |
parent | f6c1f53bbc39f55509c203484905804f4bb81678 (diff) | |
download | openbsd-db8899e993c8d6b8af310a3e928b7caf4e76aabb.tar.gz openbsd-db8899e993c8d6b8af310a3e928b7caf4e76aabb.tar.bz2 openbsd-db8899e993c8d6b8af310a3e928b7caf4e76aabb.zip |
Reorder functions and remove unnecessary function prototypes.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/evp/e_chacha.c | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/src/lib/libcrypto/evp/e_chacha.c b/src/lib/libcrypto/evp/e_chacha.c index a27a3c6470..447ce7e9e2 100644 --- a/src/lib/libcrypto/evp/e_chacha.c +++ b/src/lib/libcrypto/evp/e_chacha.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: e_chacha.c,v 1.8 2020/01/26 07:47:26 tb Exp $ */ | 1 | /* $OpenBSD: e_chacha.c,v 1.9 2022/07/30 17:11:38 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -25,10 +25,29 @@ | |||
25 | 25 | ||
26 | #include "evp_locl.h" | 26 | #include "evp_locl.h" |
27 | 27 | ||
28 | static int chacha_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | 28 | static int |
29 | const unsigned char *in, size_t len); | 29 | chacha_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, |
30 | static int chacha_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, | 30 | const unsigned char *openssl_iv, int enc) |
31 | const unsigned char *iv, int enc); | 31 | { |
32 | if (key != NULL) | ||
33 | ChaCha_set_key((ChaCha_ctx *)ctx->cipher_data, key, | ||
34 | EVP_CIPHER_CTX_key_length(ctx) * 8); | ||
35 | if (openssl_iv != NULL) { | ||
36 | const unsigned char *iv = openssl_iv + 8; | ||
37 | const unsigned char *counter = openssl_iv; | ||
38 | |||
39 | ChaCha_set_iv((ChaCha_ctx *)ctx->cipher_data, iv, counter); | ||
40 | } | ||
41 | return 1; | ||
42 | } | ||
43 | |||
44 | static int | ||
45 | chacha_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, | ||
46 | size_t len) | ||
47 | { | ||
48 | ChaCha((ChaCha_ctx *)ctx->cipher_data, out, in, len); | ||
49 | return 1; | ||
50 | } | ||
32 | 51 | ||
33 | static const EVP_CIPHER chacha20_cipher = { | 52 | static const EVP_CIPHER chacha20_cipher = { |
34 | .nid = NID_chacha20, | 53 | .nid = NID_chacha20, |
@@ -56,28 +75,4 @@ EVP_chacha20(void) | |||
56 | return (&chacha20_cipher); | 75 | return (&chacha20_cipher); |
57 | } | 76 | } |
58 | 77 | ||
59 | static int | ||
60 | chacha_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, | ||
61 | const unsigned char *openssl_iv, int enc) | ||
62 | { | ||
63 | if (key != NULL) | ||
64 | ChaCha_set_key((ChaCha_ctx *)ctx->cipher_data, key, | ||
65 | EVP_CIPHER_CTX_key_length(ctx) * 8); | ||
66 | if (openssl_iv != NULL) { | ||
67 | const unsigned char *iv = openssl_iv + 8; | ||
68 | const unsigned char *counter = openssl_iv; | ||
69 | |||
70 | ChaCha_set_iv((ChaCha_ctx *)ctx->cipher_data, iv, counter); | ||
71 | } | ||
72 | return 1; | ||
73 | } | ||
74 | |||
75 | static int | ||
76 | chacha_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, | ||
77 | size_t len) | ||
78 | { | ||
79 | ChaCha((ChaCha_ctx *)ctx->cipher_data, out, in, len); | ||
80 | return 1; | ||
81 | } | ||
82 | |||
83 | #endif | 78 | #endif |