X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fasset_writer.cc;h=b9bac1874335cd770c7d371401cc0ae76fee5027;hb=9486066c29b91a8d9ac25be1c596cad62387208f;hp=64ffee10c46c9d43f62b3d0e8f899b2cd5e9252f;hpb=f9cba324c8160a70b108d9e5b60a4ccad6ee9be2;p=libdcp.git diff --git a/src/asset_writer.cc b/src/asset_writer.cc index 64ffee10..b9bac187 100644 --- a/src/asset_writer.cc +++ b/src/asset_writer.cc @@ -16,6 +16,19 @@ You should have received a copy of the GNU General Public License along with libdcp. If not, see . + In addition, as a special exception, the copyright holders give + permission to link the code of portions of this program with the + OpenSSL library under certain conditions as described in each + individual source file, and distribute linked combinations + including the two. + + You must obey the GNU General Public License in all respects + for all of the code used other than OpenSSL. If you modify + file(s) with this exception, you may extend this exception to your + version of the file(s), but you are not obligated to do so. If you + do not wish to do so, delete this exception statement from your + version. If you delete this exception statement from all source + files in the program, then also delete it here. */ /** @file src/asset_writer.h @@ -25,8 +38,9 @@ #include "asset_writer.h" #include "mxf.h" #include "dcp_assert.h" -#include "AS_DCP.h" -#include "KM_prng.h" +#include "encryption_context.h" +#include +#include using namespace dcp; @@ -40,41 +54,9 @@ AssetWriter::AssetWriter (MXF* mxf, boost::filesystem::path file, Standard stand , _frames_written (0) , _finalized (false) , _started (false) - , _encryption_context (0) - , _hmac_context (0) + , _encryption_context (new EncryptionContext (mxf->key(), standard)) { - if (mxf->key ()) { - _encryption_context = new ASDCP::AESEncContext; - if (ASDCP_FAILURE (_encryption_context->InitKey (mxf->key()->value ()))) { - throw MiscError ("could not set up encryption context"); - } - uint8_t cbc_buffer[ASDCP::CBC_BLOCK_SIZE]; - - Kumu::FortunaRNG rng; - if (ASDCP_FAILURE (_encryption_context->SetIVec (rng.FillRandom (cbc_buffer, ASDCP::CBC_BLOCK_SIZE)))) { - throw MiscError ("could not set up CBC initialization vector"); - } - - _hmac_context = new ASDCP::HMACContext; - - ASDCP::LabelSet_t type; - if (standard == INTEROP) { - type = ASDCP::LS_MXF_INTEROP; - } else { - type = ASDCP::LS_MXF_SMPTE; - } - - if (ASDCP_FAILURE (_hmac_context->InitKey (mxf->key()->value(), type))) { - throw MiscError ("could not set up HMAC context"); - } - } -} - -AssetWriter::~AssetWriter () -{ - delete _encryption_context; - delete _hmac_context; } /** @return true if anything was written by this writer */