/*
- Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
+
#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;
-using boost::shared_array;
+
BOOST_AUTO_TEST_CASE (crypto_test)
{
- dcp::Data key (dcpomatic::crypto_key_length());
- dcp::Data iv = dcpomatic::random_iv ();
+ dcp::ArrayData key (dcpomatic::crypto_key_length());
+ dcp::ArrayData iv = dcpomatic::random_iv ();
- RAND_bytes (key.data().get(), dcpomatic::crypto_key_length());
+ RAND_bytes (key.data(), dcpomatic::crypto_key_length());
- dcp::Data ciphertext = dcpomatic::encrypt ("Can you see any fish?", key, iv);
+ 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);
}