Remove unused code.
authorCarl Hetherington <cth@carlh.net>
Mon, 16 Oct 2023 09:30:27 +0000 (11:30 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 16 Oct 2023 09:30:27 +0000 (11:30 +0200)
src/lib/config.cc
src/lib/crypto.cc [deleted file]
src/lib/crypto.h [deleted file]
src/lib/util.cc
src/lib/wscript
test/crypto_test.cc [deleted file]
test/wscript

index 063fbcab9b16f922151485045c44ec88a6f5e17b..d032e6c64b165049c1fd79efd202548cbb2e4447 100644 (file)
@@ -25,7 +25,6 @@
 #include "config.h"
 #include "constants.h"
 #include "cross.h"
-#include "crypto.h"
 #include "dcp_content_type.h"
 #include "dkdm_recipient.h"
 #include "dkdm_wrapper.h"
diff --git a/src/lib/crypto.cc b/src/lib/crypto.cc
deleted file mode 100644 (file)
index 777969c..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
-    Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
-
-    This file is part of DCP-o-matic.
-
-    DCP-o-matic is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    DCP-o-matic is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-
-/* Based on code from https://wiki.openssl.org/index.php/EVP_Symmetric_Encryption_and_Decryption */
-
-
-#include "crypto.h"
-#include "exceptions.h"
-#include <openssl/conf.h>
-#include <openssl/evp.h>
-#include <openssl/err.h>
-#include <openssl/rand.h>
-#include <boost/scoped_array.hpp>
-
-
-using std::string;
-using namespace dcpomatic;
-
-
-/** The cipher that this code uses */
-#define CIPHER EVP_aes_256_cbc()
-
-
-dcp::ArrayData
-dcpomatic::random_iv ()
-{
-       EVP_CIPHER const * cipher = CIPHER;
-       dcp::ArrayData iv (EVP_CIPHER_iv_length(cipher));
-       RAND_bytes (iv.data(), iv.size());
-       return iv;
-}
-
-
-dcp::ArrayData
-dcpomatic::encrypt (string plaintext, dcp::ArrayData key, dcp::ArrayData iv)
-{
-       auto ctx = EVP_CIPHER_CTX_new ();
-       if (!ctx) {
-               throw CryptoError ("could not create cipher context");
-       }
-
-       int r = EVP_EncryptInit_ex (ctx, CIPHER, 0, key.data(), iv.data());
-       if (r != 1) {
-               throw CryptoError ("could not initialise cipher context for encryption");
-       }
-
-       dcp::ArrayData ciphertext (plaintext.size() * 2);
-
-       int len;
-       r = EVP_EncryptUpdate (ctx, ciphertext.data(), &len, (uint8_t const *) plaintext.c_str(), plaintext.size());
-       if (r != 1) {
-               throw CryptoError ("could not encrypt data");
-       }
-
-       int ciphertext_len = len;
-
-       r = EVP_EncryptFinal_ex (ctx, ciphertext.data() + len, &len);
-       if (r != 1) {
-               throw CryptoError ("could not finish encryption");
-       }
-
-       ciphertext.set_size (ciphertext_len + len);
-
-       EVP_CIPHER_CTX_free (ctx);
-
-       return ciphertext;
-}
-
-
-string
-dcpomatic::decrypt (dcp::ArrayData ciphertext, dcp::ArrayData key, dcp::ArrayData iv)
-{
-       auto ctx = EVP_CIPHER_CTX_new ();
-       if (!ctx) {
-               throw CryptoError ("could not create cipher context");
-       }
-
-       int r = EVP_DecryptInit_ex (ctx, CIPHER, 0, key.data(), iv.data());
-       if (r != 1) {
-               throw CryptoError ("could not initialise cipher context for decryption");
-       }
-
-       dcp::ArrayData plaintext (ciphertext.size() * 2);
-
-       int len;
-       r = EVP_DecryptUpdate (ctx, plaintext.data(), &len, ciphertext.data(), ciphertext.size());
-       if (r != 1) {
-               throw CryptoError ("could not decrypt data");
-       }
-
-       int plaintext_len = len;
-
-       r = EVP_DecryptFinal_ex (ctx, plaintext.data() + len, &len);
-       if (r != 1) {
-               throw CryptoError ("could not finish decryption");
-       }
-
-       plaintext_len += len;
-       plaintext.set_size (plaintext_len + 1);
-       plaintext.data()[plaintext_len] = '\0';
-
-       EVP_CIPHER_CTX_free (ctx);
-
-       return string ((char *) plaintext.data());
-}
-
-
-int
-dcpomatic::crypto_key_length ()
-{
-       return EVP_CIPHER_key_length (CIPHER);
-}
diff --git a/src/lib/crypto.h b/src/lib/crypto.h
deleted file mode 100644 (file)
index 41a9301..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-    Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
-
-    This file is part of DCP-o-matic.
-
-    DCP-o-matic is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    DCP-o-matic is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-
-#include <dcp/array_data.h>
-
-
-namespace dcpomatic {
-
-
-dcp::ArrayData random_iv ();
-dcp::ArrayData encrypt (std::string plaintext, dcp::ArrayData key, dcp::ArrayData iv);
-std::string decrypt (dcp::ArrayData ciphertext, dcp::ArrayData key, dcp::ArrayData iv);
-int crypto_key_length ();
-
-
-}
-
index 1a340cbcee16358402c1ea24d334e87e83965d84..e0b5a294fe655dcb042a9014562ce8c26be4f114 100644 (file)
@@ -33,7 +33,6 @@
 #include "config.h"
 #include "constants.h"
 #include "cross.h"
-#include "crypto.h"
 #include "dcp_content_type.h"
 #include "dcpomatic_log.h"
 #include "digester.h"
index 56ffc39fef41b80670a77c743a714c97b21d1a04..dad8947b19d670fa50ace23264026669300e3cce 100644 (file)
@@ -62,7 +62,6 @@ sources = """
           create_cli.cc
           crop.cc
           cross_common.cc
-          crypto.cc
           curl_uploader.cc
           datasat_ap2x.cc
           dcp_content.cc
diff --git a/test/crypto_test.cc b/test/crypto_test.cc
deleted file mode 100644 (file)
index 53451b3..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-    Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
-
-    This file is part of DCP-o-matic.
-
-    DCP-o-matic is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    DCP-o-matic is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
-
-*/
-
-
-#include "lib/crypto.h"
-#include "lib/exceptions.h"
-#include "test.h"
-#include <openssl/rand.h>
-#include <boost/test/unit_test.hpp>
-
-
-using std::string;
-using std::list;
-
-
-BOOST_AUTO_TEST_CASE (crypto_test)
-{
-       dcp::ArrayData key (dcpomatic::crypto_key_length());
-       dcp::ArrayData iv = dcpomatic::random_iv ();
-
-       RAND_bytes (key.data(), dcpomatic::crypto_key_length());
-
-       auto ciphertext = dcpomatic::encrypt ("Can you see any fish?", key, iv);
-       BOOST_REQUIRE_EQUAL (dcpomatic::decrypt (ciphertext, key, iv), "Can you see any fish?");
-
-       key.data()[5]++;
-       key.data()[6]++;
-       BOOST_REQUIRE_THROW (dcpomatic::decrypt (ciphertext, key, iv), CryptoError);
-}
-
index 0c9db38893ba583ae646fca2ead0fb840679c393..e8762009c736c1d5409e361b742ed7ceffba23f9 100644 (file)
@@ -70,7 +70,6 @@ def build(bld):
                  cpl_hash_test.cc
                  cpl_metadata_test.cc
                  create_cli_test.cc
-                 crypto_test.cc
                  dcpomatic_time_test.cc
                  dcp_decoder_test.cc
                  dcp_digest_file_test.cc