diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-08-17 20:28:24 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-08-17 21:49:09 +0200 |
| commit | 56a6b3277b7acb7fcfac97ef9667467d764ea490 (patch) | |
| tree | a695d68bb0f1205a0008a3c22b9f6ee3df7e3be0 | |
| parent | 3e07c602fdbce92a2562980ebefb39a8df95eefe (diff) | |
Make use of HMAC optional.ignore-hmac
| -rw-r--r-- | src/asset_reader.h | 4 | ||||
| -rw-r--r-- | src/asset_writer.cc | 4 | ||||
| -rw-r--r-- | src/asset_writer.h | 2 | ||||
| -rw-r--r-- | src/crypto_context.h | 11 | ||||
| -rw-r--r-- | src/mono_picture_asset.cc | 6 | ||||
| -rw-r--r-- | src/mono_picture_asset.h | 4 | ||||
| -rw-r--r-- | src/smpte_subtitle_asset.cc | 6 | ||||
| -rw-r--r-- | src/sound_asset.cc | 6 | ||||
| -rw-r--r-- | src/sound_asset.h | 4 |
9 files changed, 24 insertions, 23 deletions
diff --git a/src/asset_reader.h b/src/asset_reader.h index dbd2761b..380474af 100644 --- a/src/asset_reader.h +++ b/src/asset_reader.h @@ -47,8 +47,8 @@ template <class R, class F> class AssetReader : public boost::noncopyable { public: - explicit AssetReader (Asset const * asset, boost::optional<Key> key, Standard standard) - : _crypto_context (new DecryptionContext (key, standard)) + explicit AssetReader (Asset const * asset, boost::optional<Key> key, Standard standard, bool check_hmac = true) + : _crypto_context (new DecryptionContext(key, standard, check_hmac)) { _reader = new R (); DCP_ASSERT (asset->file ()); diff --git a/src/asset_writer.cc b/src/asset_writer.cc index c4302f4a..055f2844 100644 --- a/src/asset_writer.cc +++ b/src/asset_writer.cc @@ -48,13 +48,13 @@ using namespace dcp; * @param mxf MXF that we are writing. * @param file File to write to. */ -AssetWriter::AssetWriter (MXF* mxf, boost::filesystem::path file) +AssetWriter::AssetWriter (MXF* mxf, boost::filesystem::path file, bool write_hmac) : _mxf (mxf) , _file (file) , _frames_written (0) , _finalized (false) , _started (false) - , _crypto_context (new EncryptionContext (mxf->key(), mxf->standard())) + , _crypto_context (new EncryptionContext(mxf->key(), mxf->standard(), write_hmac)) { } diff --git a/src/asset_writer.h b/src/asset_writer.h index 2970b8d3..5f7dbd95 100644 --- a/src/asset_writer.h +++ b/src/asset_writer.h @@ -64,7 +64,7 @@ public: } protected: - AssetWriter (MXF* mxf, boost::filesystem::path file); + AssetWriter (MXF* mxf, boost::filesystem::path file, bool write_hmac = true); /** MXF that we are writing */ MXF* _mxf; diff --git a/src/crypto_context.h b/src/crypto_context.h index b01efce4..e8ed5857 100644 --- a/src/crypto_context.h +++ b/src/crypto_context.h @@ -47,7 +47,7 @@ template <class T> class CryptoContext { public: - CryptoContext (boost::optional<Key> key, Standard standard) + CryptoContext (boost::optional<Key> key, Standard standard, bool use_hmac) : _context (0) , _hmac (0) { @@ -67,8 +67,6 @@ public: throw MiscError ("could not set up CBC initialization vector"); } - _hmac = new ASDCP::HMACContext; - ASDCP::LabelSet_t type; if (standard == INTEROP) { type = ASDCP::LS_MXF_INTEROP; @@ -76,8 +74,11 @@ public: type = ASDCP::LS_MXF_SMPTE; } - if (ASDCP_FAILURE (_hmac->InitKey (key->value(), type))) { - throw MiscError ("could not set up HMAC context"); + if (use_hmac) { + _hmac = new ASDCP::HMACContext; + if (ASDCP_FAILURE(_hmac->InitKey(key->value(), type))) { + throw MiscError ("could not set up HMAC context"); + } } } diff --git a/src/mono_picture_asset.cc b/src/mono_picture_asset.cc index 47fc8f55..3797fbec 100644 --- a/src/mono_picture_asset.cc +++ b/src/mono_picture_asset.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -174,9 +174,9 @@ MonoPictureAsset::start_write (boost::filesystem::path file, bool overwrite) } shared_ptr<MonoPictureAssetReader> -MonoPictureAsset::start_read () const +MonoPictureAsset::start_read (bool check_hmac) const { - return shared_ptr<MonoPictureAssetReader> (new MonoPictureAssetReader (this, key(), standard())); + return shared_ptr<MonoPictureAssetReader> (new MonoPictureAssetReader(this, key(), standard(), check_hmac)); } string diff --git a/src/mono_picture_asset.h b/src/mono_picture_asset.h index 7a1c0d0a..6f34dbe4 100644 --- a/src/mono_picture_asset.h +++ b/src/mono_picture_asset.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -60,7 +60,7 @@ public: /** Start a progressive write to a MonoPictureAsset */ boost::shared_ptr<PictureAssetWriter> start_write (boost::filesystem::path, bool); - boost::shared_ptr<MonoPictureAssetReader> start_read () const; + boost::shared_ptr<MonoPictureAssetReader> start_read (bool check_hmac = true) const; bool equals ( boost::shared_ptr<const Asset> other, diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc index 6a62bc1d..29a423a4 100644 --- a/src/smpte_subtitle_asset.cc +++ b/src/smpte_subtitle_asset.cc @@ -97,7 +97,7 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file) reader->ReadTimedTextResource (_raw_xml); xml->read_string (_raw_xml); parse_xml (xml); - read_mxf_descriptor (reader, shared_ptr<DecryptionContext> (new DecryptionContext (optional<Key>(), SMPTE))); + read_mxf_descriptor (reader, shared_ptr<DecryptionContext> (new DecryptionContext (optional<Key>(), SMPTE, true))); } } else { /* Plain XML */ @@ -278,7 +278,7 @@ SMPTESubtitleAsset::set_key (Key key) ); } - shared_ptr<DecryptionContext> dec (new DecryptionContext (key, SMPTE)); + shared_ptr<DecryptionContext> dec (new DecryptionContext(key, SMPTE, true)); reader->ReadTimedTextResource (_raw_xml, dec->context(), dec->hmac()); shared_ptr<cxml::Document> xml (new cxml::Document ("SubtitleReel")); xml->read_string (_raw_xml); @@ -345,7 +345,7 @@ SMPTESubtitleAsset::xml_as_string () const void SMPTESubtitleAsset::write (boost::filesystem::path p) const { - EncryptionContext enc (key(), SMPTE); + EncryptionContext enc (key(), SMPTE, true); ASDCP::WriterInfo writer_info; fill_writer_info (&writer_info, _id); diff --git a/src/sound_asset.cc b/src/sound_asset.cc index 7f2bf5e3..2295d138 100644 --- a/src/sound_asset.cc +++ b/src/sound_asset.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -203,9 +203,9 @@ SoundAsset::start_write (boost::filesystem::path file, bool atmos_sync) } shared_ptr<SoundAssetReader> -SoundAsset::start_read () const +SoundAsset::start_read (bool check_hmac) const { - return shared_ptr<SoundAssetReader> (new SoundAssetReader (this, key(), standard())); + return shared_ptr<SoundAssetReader> (new SoundAssetReader (this, key(), standard(), check_hmac)); } string diff --git a/src/sound_asset.h b/src/sound_asset.h index 9656cf90..b0bb01be 100644 --- a/src/sound_asset.h +++ b/src/sound_asset.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -59,7 +59,7 @@ public: SoundAsset (Fraction edit_rate, int sampling_rate, int channels, Standard standard); boost::shared_ptr<SoundAssetWriter> start_write (boost::filesystem::path file, bool atmos_sync = false); - boost::shared_ptr<SoundAssetReader> start_read () const; + boost::shared_ptr<SoundAssetReader> start_read (bool check_hmac = true) const; bool equals ( boost::shared_ptr<const Asset> other, |
