|
|
1524bc |
From 2bdfe3735e50438213359e3c7a070ea873cf30be Mon Sep 17 00:00:00 2001
|
|
|
1524bc |
From: Andrew Bartlett <abartlet@samba.org>
|
|
|
1524bc |
Date: Thu, 15 Aug 2019 14:23:35 +1200
|
|
|
1524bc |
Subject: [PATCH 107/187] lib/crypto: Remove unused RC4 code from Samba
|
|
|
1524bc |
|
|
|
1524bc |
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
|
|
|
1524bc |
Reviewed-by: Andreas Schneider <asn@samba.org>
|
|
|
1524bc |
(cherry picked from commit e9859ad356b42f39585dcef1a38def97a50a3744)
|
|
|
1524bc |
---
|
|
|
1524bc |
lib/crypto/arcfour.c | 93 ----------------------------------------
|
|
|
1524bc |
lib/crypto/arcfour.h | 17 --------
|
|
|
1524bc |
lib/crypto/wscript_build | 9 ----
|
|
|
1524bc |
3 files changed, 119 deletions(-)
|
|
|
1524bc |
delete mode 100644 lib/crypto/arcfour.c
|
|
|
1524bc |
delete mode 100644 lib/crypto/arcfour.h
|
|
|
1524bc |
|
|
|
1524bc |
diff --git a/lib/crypto/arcfour.c b/lib/crypto/arcfour.c
|
|
|
1524bc |
deleted file mode 100644
|
|
|
1524bc |
index af9b20cc01e..00000000000
|
|
|
1524bc |
--- a/lib/crypto/arcfour.c
|
|
|
1524bc |
+++ /dev/null
|
|
|
1524bc |
@@ -1,93 +0,0 @@
|
|
|
1524bc |
-/*
|
|
|
1524bc |
- Unix SMB/CIFS implementation.
|
|
|
1524bc |
-
|
|
|
1524bc |
- An implementation of the arcfour algorithm
|
|
|
1524bc |
-
|
|
|
1524bc |
- Copyright (C) Andrew Tridgell 1998
|
|
|
1524bc |
-
|
|
|
1524bc |
- This program is free software; you can redistribute it and/or modify
|
|
|
1524bc |
- it under the terms of the GNU General Public License as published by
|
|
|
1524bc |
- the Free Software Foundation; either version 3 of the License, or
|
|
|
1524bc |
- (at your option) any later version.
|
|
|
1524bc |
-
|
|
|
1524bc |
- This program is distributed in the hope that it will be useful,
|
|
|
1524bc |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
1524bc |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
1524bc |
- GNU General Public License for more details.
|
|
|
1524bc |
-
|
|
|
1524bc |
- You should have received a copy of the GNU General Public License
|
|
|
1524bc |
- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1524bc |
-*/
|
|
|
1524bc |
-
|
|
|
1524bc |
-#include "replace.h"
|
|
|
1524bc |
-#include "../lib/crypto/arcfour.h"
|
|
|
1524bc |
-
|
|
|
1524bc |
-/* initialise the arcfour sbox with key */
|
|
|
1524bc |
-_PUBLIC_ void arcfour_init(struct arcfour_state *state, const DATA_BLOB *key)
|
|
|
1524bc |
-{
|
|
|
1524bc |
- size_t ind;
|
|
|
1524bc |
- uint8_t j = 0;
|
|
|
1524bc |
- for (ind = 0; ind < sizeof(state->sbox); ind++) {
|
|
|
1524bc |
- state->sbox[ind] = (uint8_t)ind;
|
|
|
1524bc |
- }
|
|
|
1524bc |
-
|
|
|
1524bc |
- for (ind = 0; ind < sizeof(state->sbox); ind++) {
|
|
|
1524bc |
- uint8_t tc;
|
|
|
1524bc |
-
|
|
|
1524bc |
- j += (state->sbox[ind] + key->data[ind%key->length]);
|
|
|
1524bc |
-
|
|
|
1524bc |
- tc = state->sbox[ind];
|
|
|
1524bc |
- state->sbox[ind] = state->sbox[j];
|
|
|
1524bc |
- state->sbox[j] = tc;
|
|
|
1524bc |
- }
|
|
|
1524bc |
- state->index_i = 0;
|
|
|
1524bc |
- state->index_j = 0;
|
|
|
1524bc |
-}
|
|
|
1524bc |
-
|
|
|
1524bc |
-/* crypt the data with arcfour */
|
|
|
1524bc |
-_PUBLIC_ void arcfour_crypt_sbox(struct arcfour_state *state, uint8_t *data,
|
|
|
1524bc |
- int len)
|
|
|
1524bc |
-{
|
|
|
1524bc |
- int ind;
|
|
|
1524bc |
-
|
|
|
1524bc |
- for (ind = 0; ind < len; ind++) {
|
|
|
1524bc |
- uint8_t tc;
|
|
|
1524bc |
- uint8_t t;
|
|
|
1524bc |
-
|
|
|
1524bc |
- state->index_i++;
|
|
|
1524bc |
- state->index_j += state->sbox[state->index_i];
|
|
|
1524bc |
-
|
|
|
1524bc |
- tc = state->sbox[state->index_i];
|
|
|
1524bc |
- state->sbox[state->index_i] = state->sbox[state->index_j];
|
|
|
1524bc |
- state->sbox[state->index_j] = tc;
|
|
|
1524bc |
-
|
|
|
1524bc |
- t = state->sbox[state->index_i] + state->sbox[state->index_j];
|
|
|
1524bc |
- data[ind] = data[ind] ^ state->sbox[t];
|
|
|
1524bc |
- }
|
|
|
1524bc |
-}
|
|
|
1524bc |
-
|
|
|
1524bc |
-/*
|
|
|
1524bc |
- arcfour encryption with a blob key
|
|
|
1524bc |
-*/
|
|
|
1524bc |
-_PUBLIC_ void arcfour_crypt_blob(uint8_t *data, int len, const DATA_BLOB *key)
|
|
|
1524bc |
-{
|
|
|
1524bc |
- struct arcfour_state state;
|
|
|
1524bc |
- arcfour_init(&state, key);
|
|
|
1524bc |
- arcfour_crypt_sbox(&state, data, len);
|
|
|
1524bc |
-}
|
|
|
1524bc |
-
|
|
|
1524bc |
-/*
|
|
|
1524bc |
- a variant that assumes a 16 byte key. This should be removed
|
|
|
1524bc |
- when the last user is gone
|
|
|
1524bc |
-*/
|
|
|
1524bc |
-_PUBLIC_ void arcfour_crypt(uint8_t *data, const uint8_t keystr[16], int len)
|
|
|
1524bc |
-{
|
|
|
1524bc |
- uint8_t keycopy[16];
|
|
|
1524bc |
- DATA_BLOB key = { .data = keycopy, .length = sizeof(keycopy) };
|
|
|
1524bc |
-
|
|
|
1524bc |
- memcpy(keycopy, keystr, sizeof(keycopy));
|
|
|
1524bc |
-
|
|
|
1524bc |
- arcfour_crypt_blob(data, len, &key);
|
|
|
1524bc |
-}
|
|
|
1524bc |
-
|
|
|
1524bc |
-
|
|
|
1524bc |
diff --git a/lib/crypto/arcfour.h b/lib/crypto/arcfour.h
|
|
|
1524bc |
deleted file mode 100644
|
|
|
1524bc |
index a9f80c474d5..00000000000
|
|
|
1524bc |
--- a/lib/crypto/arcfour.h
|
|
|
1524bc |
+++ /dev/null
|
|
|
1524bc |
@@ -1,17 +0,0 @@
|
|
|
1524bc |
-#ifndef ARCFOUR_HEADER_H
|
|
|
1524bc |
-#define ARCFOUR_HEADER_H
|
|
|
1524bc |
-
|
|
|
1524bc |
-#include "../lib/util/data_blob.h"
|
|
|
1524bc |
-
|
|
|
1524bc |
-struct arcfour_state {
|
|
|
1524bc |
- uint8_t sbox[256];
|
|
|
1524bc |
- uint8_t index_i;
|
|
|
1524bc |
- uint8_t index_j;
|
|
|
1524bc |
-};
|
|
|
1524bc |
-
|
|
|
1524bc |
-void arcfour_init(struct arcfour_state *state, const DATA_BLOB *key);
|
|
|
1524bc |
-void arcfour_crypt_sbox(struct arcfour_state *state, uint8_t *data, int len);
|
|
|
1524bc |
-void arcfour_crypt_blob(uint8_t *data, int len, const DATA_BLOB *key);
|
|
|
1524bc |
-void arcfour_crypt(uint8_t *data, const uint8_t keystr[16], int len);
|
|
|
1524bc |
-
|
|
|
1524bc |
-#endif /* ARCFOUR_HEADER_H */
|
|
|
1524bc |
diff --git a/lib/crypto/wscript_build b/lib/crypto/wscript_build
|
|
|
1524bc |
index 9a7c715754d..dcac8fcd30c 100644
|
|
|
1524bc |
--- a/lib/crypto/wscript_build
|
|
|
1524bc |
+++ b/lib/crypto/wscript_build
|
|
|
1524bc |
@@ -12,14 +12,6 @@ bld.SAMBA_SUBSYSTEM('GNUTLS_HELPERS',
|
|
|
1524bc |
''',
|
|
|
1524bc |
deps='gnutls samba-errors');
|
|
|
1524bc |
|
|
|
1524bc |
-# We have a GnuTLS DCEPRC backupkey implementation for the server and the test.
|
|
|
1524bc |
-# However this is only working with GnuTLS >= 3.4.7. So we need to keep this
|
|
|
1524bc |
-# around till we can require at least GnuTLS in a newer version.
|
|
|
1524bc |
-bld.SAMBA_SUBSYSTEM('LIBCRYPTO_RC4',
|
|
|
1524bc |
- source='arcfour.c',
|
|
|
1524bc |
- deps='talloc',
|
|
|
1524bc |
- enabled=not bld.CONFIG_SET('HAVE_GNUTLS_3_4_7'))
|
|
|
1524bc |
-
|
|
|
1524bc |
bld.SAMBA_SUBSYSTEM('LIBCRYPTO_AES_CCM',
|
|
|
1524bc |
source='aes_ccm_128.c',
|
|
|
1524bc |
deps='talloc')
|
|
|
1524bc |
@@ -42,7 +34,6 @@ bld.SAMBA_SUBSYSTEM('LIBCRYPTO',
|
|
|
1524bc |
''',
|
|
|
1524bc |
deps='''
|
|
|
1524bc |
talloc
|
|
|
1524bc |
- LIBCRYPTO_RC4
|
|
|
1524bc |
LIBCRYPTO_AES
|
|
|
1524bc |
LIBCRYPTO_AES_CCM
|
|
|
1524bc |
LIBCRYPTO_AES_GCM
|
|
|
1524bc |
--
|
|
|
1524bc |
2.23.0
|
|
|
1524bc |
|