Merge EncryptionContext with DecryptionContext and use HMAC when decrypting.
authorCarl Hetherington <cth@carlh.net>
Tue, 6 Mar 2018 01:15:43 +0000 (01:15 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 13 Mar 2018 22:29:01 +0000 (22:29 +0000)
24 files changed:
src/asset_reader.h
src/asset_writer.cc
src/asset_writer.h
src/atmos_asset.cc
src/atmos_asset_writer.cc
src/decryption_context.cc [deleted file]
src/decryption_context.h [deleted file]
src/encryption_context.cc [deleted file]
src/encryption_context.h [deleted file]
src/frame.h
src/mono_picture_asset.cc
src/mono_picture_asset_writer.cc
src/mono_picture_frame.cc
src/mono_picture_frame.h
src/smpte_subtitle_asset.cc
src/smpte_subtitle_asset.h
src/sound_asset.cc
src/sound_asset_writer.cc
src/stereo_picture_asset.cc
src/stereo_picture_asset_writer.cc
src/stereo_picture_frame.cc
src/stereo_picture_frame.h
src/wscript
tools/dcpdecryptmxf.cc

index eaf2721a31dd355861d74d5d88960b52b5ec9e2b..dbd2761b0798d68b0f17e36bc05db3dfec79cf93 100644 (file)
 
 #include "dcp_assert.h"
 #include "asset.h"
-#include "decryption_context.h"
+#include "crypto_context.h"
 #include <asdcp/AS_DCP.h>
 #include <boost/noncopyable.hpp>
 #include <boost/shared_ptr.hpp>
 
 namespace dcp {
 
-class DecryptionContext;
-
 template <class R, class F>
 class AssetReader : public boost::noncopyable
 {
 public:
-       explicit AssetReader (Asset const * asset, boost::optional<Key> key)
-               : _decryption_context (new DecryptionContext (key))
+       explicit AssetReader (Asset const * asset, boost::optional<Key> key, Standard standard)
+               : _crypto_context (new DecryptionContext (key, standard))
        {
                _reader = new R ();
                DCP_ASSERT (asset->file ());
@@ -68,12 +66,12 @@ public:
 
        boost::shared_ptr<const F> get_frame (int n) const
        {
-               return boost::shared_ptr<const F> (new F (_reader, n, _decryption_context));
+               return boost::shared_ptr<const F> (new F (_reader, n, _crypto_context));
        }
 
 protected:
        R* _reader;
-       boost::shared_ptr<DecryptionContext> _decryption_context;
+       boost::shared_ptr<DecryptionContext> _crypto_context;
 };
 
 }
index 4f5cf4be65876bcaf6d54f880b33e85ab64cb9bd..c4302f4a7b9ffaef8a36e2262e200d2ead183171 100644 (file)
@@ -38,7 +38,7 @@
 #include "asset_writer.h"
 #include "mxf.h"
 #include "dcp_assert.h"
-#include "encryption_context.h"
+#include "crypto_context.h"
 #include <asdcp/AS_DCP.h>
 #include <asdcp/KM_prng.h>
 
@@ -54,7 +54,7 @@ AssetWriter::AssetWriter (MXF* mxf, boost::filesystem::path file)
        , _frames_written (0)
        , _finalized (false)
        , _started (false)
-       , _encryption_context (new EncryptionContext (mxf->key(), mxf->standard()))
+       , _crypto_context (new EncryptionContext (mxf->key(), mxf->standard()))
 {
 
 }
index bc055d700f45cf319032f235d65c62b20c738b05..dcf57aad8ab7064130937a19a63a19cd363186c4 100644 (file)
 #define LIBDCP_ASSET_WRITER_H
 
 #include "types.h"
+#include "crypto_context.h"
 #include <boost/filesystem.hpp>
 
 namespace dcp {
 
 class MXF;
-class EncryptionContext;
 
 /** @class AssetWriter
  *  @brief Parent class for classes which can write MXF-based assets.
@@ -77,7 +77,7 @@ protected:
        bool _finalized;
        /** true if something has been written to this asset */
        bool _started;
-       boost::shared_ptr<EncryptionContext> _encryption_context;
+       boost::shared_ptr<EncryptionContext> _crypto_context;
 };
 
 }
index ab17493d1cc70e2543f915c6468214069fa53f1d..1e4d9c18f7067f71c3cf1010114924cc385da796 100644 (file)
@@ -91,7 +91,7 @@ AtmosAsset::pkl_type (Standard) const
 shared_ptr<AtmosAssetReader>
 AtmosAsset::start_read () const
 {
-       return shared_ptr<AtmosAssetReader> (new AtmosAssetReader (this, key ()));
+       return shared_ptr<AtmosAssetReader> (new AtmosAssetReader (this, key(), SMPTE));
 }
 
 shared_ptr<AtmosAssetWriter>
index 60529a2c6398d3b1b0b426ed5e0c157db036d9a7..07d310f65867bd78e1918e4cbe8bd8adb6ca307d 100644 (file)
@@ -36,7 +36,7 @@
 #include "exceptions.h"
 #include "dcp_assert.h"
 #include "compose.hpp"
-#include "encryption_context.h"
+#include "crypto_context.h"
 #include <asdcp/AS_DCP.h>
 
 using std::min;
@@ -89,7 +89,7 @@ AtmosAssetWriter::write (uint8_t const * data, int size)
        _state->frame_buffer.Size (size);
        memcpy (_state->frame_buffer.Data(), data, size);
 
-       ASDCP::Result_t const r = _state->mxf_writer.WriteFrame (_state->frame_buffer, _encryption_context->encryption(), _encryption_context->hmac());
+       ASDCP::Result_t const r = _state->mxf_writer.WriteFrame (_state->frame_buffer, _crypto_context->context(), _crypto_context->hmac());
        if (ASDCP_FAILURE (r)) {
                boost::throw_exception (MiscError (String::compose ("could not write atmos MXF frame (%1)", int (r))));
        }
diff --git a/src/decryption_context.cc b/src/decryption_context.cc
deleted file mode 100644 (file)
index 1c1838a..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
-
-    This file is part of libdcp.
-
-    libdcp 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.
-
-    libdcp 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 libdcp.  If not, see <http://www.gnu.org/licenses/>.
-
-    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.
-*/
-
-#include "decryption_context.h"
-#include "exceptions.h"
-#include <asdcp/AS_DCP.h>
-#include <asdcp/KM_prng.h>
-
-using boost::optional;
-using namespace dcp;
-
-DecryptionContext::DecryptionContext (optional<Key> key)
-       : _decryption (0)
-{
-       if (!key) {
-               return;
-       }
-
-       _decryption = new ASDCP::AESDecContext;
-       if (ASDCP_FAILURE (_decryption->InitKey (key->value ()))) {
-               throw MiscError ("could not set up decryption context");
-       }
-}
-
-DecryptionContext::~DecryptionContext ()
-{
-       delete _decryption;
-}
diff --git a/src/decryption_context.h b/src/decryption_context.h
deleted file mode 100644 (file)
index fb8342c..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
-
-    This file is part of libdcp.
-
-    libdcp 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.
-
-    libdcp 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 libdcp.  If not, see <http://www.gnu.org/licenses/>.
-
-    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.
-*/
-
-#ifndef LIBDCP_DECRYPTION_CONTEXT_H
-#define LIBDCP_DECRYPTION_CONTEXT_H
-
-#include "key.h"
-#include <boost/optional.hpp>
-
-namespace ASDCP {
-       class AESDecContext;
-}
-
-namespace dcp {
-
-class DecryptionContext
-{
-public:
-       DecryptionContext (boost::optional<Key> key = boost::optional<Key> ());
-       ~DecryptionContext ();
-
-       ASDCP::AESDecContext* decryption () const {
-               return _decryption;
-       }
-
-private:
-       ASDCP::AESDecContext* _decryption;
-};
-
-}
-
-#endif
diff --git a/src/encryption_context.cc b/src/encryption_context.cc
deleted file mode 100644 (file)
index 7712a25..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
-
-    This file is part of libdcp.
-
-    libdcp 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.
-
-    libdcp 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 libdcp.  If not, see <http://www.gnu.org/licenses/>.
-
-    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.
-*/
-
-#include "encryption_context.h"
-#include "exceptions.h"
-#include <asdcp/AS_DCP.h>
-#include <asdcp/KM_prng.h>
-
-using boost::optional;
-using namespace dcp;
-
-EncryptionContext::EncryptionContext (optional<Key> key, Standard standard)
-       : _encryption (0)
-       , _hmac (0)
-{
-       if (!key) {
-               return;
-       }
-
-       _encryption = new ASDCP::AESEncContext;
-       if (ASDCP_FAILURE (_encryption->InitKey (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->SetIVec (rng.FillRandom (cbc_buffer, ASDCP::CBC_BLOCK_SIZE)))) {
-               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;
-       } else {
-               type = ASDCP::LS_MXF_SMPTE;
-       }
-
-       if (ASDCP_FAILURE (_hmac->InitKey (key->value(), type))) {
-               throw MiscError ("could not set up HMAC context");
-       }
-}
-
-EncryptionContext::~EncryptionContext ()
-{
-       delete _encryption;
-       delete _hmac;
-}
diff --git a/src/encryption_context.h b/src/encryption_context.h
deleted file mode 100644 (file)
index 6817395..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
-
-    This file is part of libdcp.
-
-    libdcp 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.
-
-    libdcp 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 libdcp.  If not, see <http://www.gnu.org/licenses/>.
-
-    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.
-*/
-
-#include "key.h"
-#include "types.h"
-#include <boost/optional.hpp>
-
-namespace ASDCP {
-       class AESEncContext;
-       class HMACContext;
-}
-
-namespace dcp {
-
-class EncryptionContext
-{
-public:
-       EncryptionContext (boost::optional<Key> key, Standard standard);
-       ~EncryptionContext ();
-
-       ASDCP::AESEncContext* encryption () const {
-               return _encryption;
-       }
-
-       ASDCP::HMACContext* hmac () const {
-               return _hmac;
-       }
-
-private:
-       ASDCP::AESEncContext* _encryption;
-       ASDCP::HMACContext* _hmac;
-};
-
-}
index f20a1bb36f8d662aac41058d81a54bc8a781afb0..7b5e63662d26c666c0f5230aa22775e4c521deff 100644 (file)
@@ -34,7 +34,7 @@
 #ifndef LIBDCP_FRAME_H
 #define LIBDCP_FRAME_H
 
-#include "decryption_context.h"
+#include "crypto_context.h"
 #include "exceptions.h"
 #include <asdcp/KM_fileio.h>
 #include <asdcp/AS_DCP.h>
@@ -51,7 +51,7 @@ public:
                /* XXX: unfortunate guesswork on this buffer size */
                _buffer = new B (Kumu::Megabyte);
 
-               if (ASDCP_FAILURE (reader->ReadFrame (n, *_buffer, c->decryption()))) {
+               if (ASDCP_FAILURE (reader->ReadFrame (n, *_buffer, c->context(), c->hmac()))) {
                        boost::throw_exception (DCPReadError ("could not read frame"));
                }
        }
index cebd8fa16fe3ae18a7c2860f92172bce3da5ca40..5a01491013e28a4112f9e32c0ba10f372b29f35d 100644 (file)
@@ -176,7 +176,7 @@ MonoPictureAsset::start_write (boost::filesystem::path file, bool overwrite)
 shared_ptr<MonoPictureAssetReader>
 MonoPictureAsset::start_read () const
 {
-       return shared_ptr<MonoPictureAssetReader> (new MonoPictureAssetReader (this, key ()));
+       return shared_ptr<MonoPictureAssetReader> (new MonoPictureAssetReader (this, key(), standard()));
 }
 
 string
index b48e46e990c4375d7cb5210abca8e66efa9c5f1d..30a6ee96959f9c78ec3d9847b82c56c2ce47afaf 100644 (file)
@@ -39,7 +39,7 @@
 #include "exceptions.h"
 #include "picture_asset.h"
 #include "dcp_assert.h"
-#include "encryption_context.h"
+#include "crypto_context.h"
 #include <asdcp/AS_DCP.h>
 #include <asdcp/KM_fileio.h>
 
@@ -87,7 +87,7 @@ MonoPictureAssetWriter::write (uint8_t const * data, int size)
        uint64_t const before_offset = _state->mxf_writer.Tell ();
 
        string hash;
-       ASDCP::Result_t const r = _state->mxf_writer.WriteFrame (_state->frame_buffer, _encryption_context->encryption(), _encryption_context->hmac(), &hash);
+       ASDCP::Result_t const r = _state->mxf_writer.WriteFrame (_state->frame_buffer, _crypto_context->context(), _crypto_context->hmac(), &hash);
        if (ASDCP_FAILURE (r)) {
                boost::throw_exception (MXFFileError ("error in writing video MXF", _file.string(), r));
        }
index 23deb1e8ad3889e1c6411e50cd0e370ec6055ea1..7ac807cba27029c013ca0d00e864e1172a80dc02 100644 (file)
@@ -42,7 +42,7 @@
 #include "colour_conversion.h"
 #include "compose.hpp"
 #include "j2k.h"
-#include "decryption_context.h"
+#include "crypto_context.h"
 #include <asdcp/KM_fileio.h>
 #include <asdcp/AS_DCP.h>
 
@@ -79,7 +79,7 @@ MonoPictureFrame::MonoPictureFrame (ASDCP::JP2K::MXFReader* reader, int n, share
        /* XXX: unfortunate guesswork on this buffer size */
        _buffer = new ASDCP::JP2K::FrameBuffer (4 * Kumu::Megabyte);
 
-       ASDCP::Result_t const r = reader->ReadFrame (n, *_buffer, c->decryption());
+       ASDCP::Result_t const r = reader->ReadFrame (n, *_buffer, c->context(), c->hmac());
 
        if (ASDCP_FAILURE (r)) {
                boost::throw_exception (DCPReadError (String::compose ("could not read video frame %1 (%2)", n, static_cast<int>(r))));
index 612ffa3c86c65433bcfcb128dc9214a6bfa68563..1b818144394e23304e85b3a5ceecd27a89eb0d1a 100644 (file)
@@ -58,7 +58,6 @@ namespace ASDCP {
 namespace dcp {
 
 class OpenJPEGImage;
-class DecryptionContext;
 
 /** @class MonoPictureFrame
  *  @brief A single frame of a 2D (monoscopic) picture asset.
index a0472f3f569436321e01ea466edd629fefad2035..cd692736ac3c6d00744d0f469578556800f60a65 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
@@ -43,8 +43,8 @@
 #include "dcp_assert.h"
 #include "util.h"
 #include "compose.hpp"
-#include "encryption_context.h"
-#include "decryption_context.h"
+#include "crypto_context.h"
+#include "crypto_context.h"
 #include <asdcp/AS_DCP.h>
 #include <asdcp/KM_util.h>
 #include <libxml++/libxml++.h>
@@ -60,6 +60,7 @@ using boost::split;
 using boost::is_any_of;
 using boost::shared_array;
 using boost::dynamic_pointer_cast;
+using boost::optional;
 using namespace dcp;
 
 SMPTESubtitleAsset::SMPTESubtitleAsset ()
@@ -93,7 +94,7 @@ SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file)
                        reader->ReadTimedTextResource (s);
                        xml->read_string (s);
                        parse_xml (xml);
-                       read_mxf_descriptor (reader, shared_ptr<DecryptionContext> (new DecryptionContext ()));
+                       read_mxf_descriptor (reader, shared_ptr<DecryptionContext> (new DecryptionContext (optional<Key>(), SMPTE)));
                }
        } else {
                /* Plain XML */
@@ -175,7 +176,7 @@ SMPTESubtitleAsset::read_mxf_descriptor (shared_ptr<ASDCP::TimedText::MXFReader>
                if (i->Type == ASDCP::TimedText::MT_OPENTYPE) {
                        ASDCP::TimedText::FrameBuffer buffer;
                        buffer.Capacity (10 * 1024 * 1024);
-                       reader->ReadAncillaryResource (i->ResourceID, buffer, dec->decryption());
+                       reader->ReadAncillaryResource (i->ResourceID, buffer, dec->context(), dec->hmac());
 
                        char id[64];
                        Kumu::bin2UUIDhex (i->ResourceID, ASDCP::UUIDlen, id, sizeof (id));
@@ -229,8 +230,8 @@ SMPTESubtitleAsset::set_key (Key key)
        }
 
        string s;
-       shared_ptr<DecryptionContext> dec (new DecryptionContext (key));
-       reader->ReadTimedTextResource (s, dec->decryption());
+       shared_ptr<DecryptionContext> dec (new DecryptionContext (key, SMPTE));
+       reader->ReadTimedTextResource (s, dec->context(), dec->hmac());
        shared_ptr<cxml::Document> xml (new cxml::Document ("SubtitleReel"));
        xml->read_string (s);
        parse_xml (xml);
@@ -329,7 +330,7 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const
        }
 
        /* XXX: no encryption */
-       r = writer.WriteTimedTextResource (xml_as_string (), enc.encryption(), enc.hmac());
+       r = writer.WriteTimedTextResource (xml_as_string (), enc.context(), enc.hmac());
        if (ASDCP_FAILURE (r)) {
                boost::throw_exception (MXFFileError ("could not write XML to timed text resource", p.string(), r));
        }
@@ -343,7 +344,7 @@ SMPTESubtitleAsset::write (boost::filesystem::path p) const
                        ASDCP::TimedText::FrameBuffer buffer;
                        buffer.SetData (j->data.data().get(), j->data.size());
                        buffer.Size (j->data.size());
-                       r = writer.WriteAncillaryResource (buffer, enc.encryption(), enc.hmac());
+                       r = writer.WriteAncillaryResource (buffer, enc.context(), enc.hmac());
                        if (ASDCP_FAILURE (r)) {
                                boost::throw_exception (MXFFileError ("could not write font to timed text resource", p.string(), r));
                        }
index cf7e714de1eb9477e6d9715a3efae4f27458c700..9169a3d64298f315c8944140ebf540e919940756 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
@@ -38,6 +38,7 @@
 #include "subtitle_asset.h"
 #include "local_time.h"
 #include "mxf.h"
+#include "crypto_context.h"
 #include <boost/filesystem.hpp>
 
 namespace ASDCP {
@@ -49,7 +50,6 @@ namespace ASDCP {
 namespace dcp {
 
 class SMPTELoadFontNode;
-class DecryptionContext;
 
 /** @class SMPTESubtitleAsset
  *  @brief A set of subtitles to be read and/or written in the SMPTE format.
index b8ed6fb5555ae942d5768a64f93a29c8e55260d2..641dc09a8a3b3679a9411909fb75ad5a2f420e33 100644 (file)
@@ -202,7 +202,7 @@ SoundAsset::start_write (boost::filesystem::path file)
 shared_ptr<SoundAssetReader>
 SoundAsset::start_read () const
 {
-       return shared_ptr<SoundAssetReader> (new SoundAssetReader (this, key ()));
+       return shared_ptr<SoundAssetReader> (new SoundAssetReader (this, key(), standard()));
 }
 
 string
index 1bb2959dcfd6de738643fab1589397df93f272f8..8df4d911a0334377bbe01f7b71e71581cba0f648 100644 (file)
@@ -36,7 +36,7 @@
 #include "exceptions.h"
 #include "dcp_assert.h"
 #include "compose.hpp"
-#include "encryption_context.h"
+#include "crypto_context.h"
 #include <asdcp/AS_DCP.h>
 #include <iostream>
 
@@ -143,7 +143,7 @@ SoundAssetWriter::write (float const * const * data, int frames)
 void
 SoundAssetWriter::write_current_frame ()
 {
-       ASDCP::Result_t const r = _state->mxf_writer.WriteFrame (_state->frame_buffer, _encryption_context->encryption(), _encryption_context->hmac());
+       ASDCP::Result_t const r = _state->mxf_writer.WriteFrame (_state->frame_buffer, _crypto_context->context(), _crypto_context->hmac());
        if (ASDCP_FAILURE (r)) {
                boost::throw_exception (MiscError (String::compose ("could not write audio MXF frame (%1)", int (r))));
        }
index e5ed363eeceaffeb995da45d5e39ee7139e8744f..d78b4c2c881b5498dd76e1824e44e5d514e0c7ed 100644 (file)
@@ -85,7 +85,7 @@ StereoPictureAsset::start_write (boost::filesystem::path file, bool overwrite)
 shared_ptr<StereoPictureAssetReader>
 StereoPictureAsset::start_read () const
 {
-       return shared_ptr<StereoPictureAssetReader> (new StereoPictureAssetReader (this, key ()));
+       return shared_ptr<StereoPictureAssetReader> (new StereoPictureAssetReader (this, key(), standard()));
 }
 
 bool
index db770e8bc05fc15c029dde3e132a1e5dca2b328f..14900e6dac16efb3d745e818d0aee7a0f66070b2 100644 (file)
@@ -35,7 +35,7 @@
 #include "exceptions.h"
 #include "dcp_assert.h"
 #include "picture_asset.h"
-#include "encryption_context.h"
+#include "crypto_context.h"
 #include <asdcp/AS_DCP.h>
 #include <asdcp/KM_fileio.h>
 
@@ -88,8 +88,8 @@ StereoPictureAssetWriter::write (uint8_t const * data, int size)
        Kumu::Result_t r = _state->mxf_writer.WriteFrame (
                _state->frame_buffer,
                _next_eye == EYE_LEFT ? ASDCP::JP2K::SP_LEFT : ASDCP::JP2K::SP_RIGHT,
-               _encryption_context->encryption(),
-               _encryption_context->hmac(),
+               _crypto_context->context(),
+               _crypto_context->hmac(),
                &hash
                );
 
index e645c7df613412ee1973727409fa4dba396866bc..8b8f9b91e8524b9c00b3deb1a6da8cd6b65dbf7a 100644 (file)
@@ -38,7 +38,7 @@
 #include "colour_conversion.h"
 #include "compose.hpp"
 #include "j2k.h"
-#include "decryption_context.h"
+#include "crypto_context.h"
 #include <asdcp/AS_DCP.h>
 #include <asdcp/KM_fileio.h>
 
@@ -55,7 +55,7 @@ StereoPictureFrame::StereoPictureFrame (ASDCP::JP2K::MXFSReader* reader, int n,
        /* XXX: unfortunate guesswork on this buffer size */
        _buffer = new ASDCP::JP2K::SFrameBuffer (4 * Kumu::Megabyte);
 
-       if (ASDCP_FAILURE (reader->ReadFrame (n, *_buffer, c->decryption()))) {
+       if (ASDCP_FAILURE (reader->ReadFrame (n, *_buffer, c->context(), c->hmac()))) {
                boost::throw_exception (DCPReadError (String::compose ("could not read video frame %1 of %2", n)));
        }
 }
index 8879280438bfd32e07bbfd8cb4efee78f9cfef95..a173b1c14cc7e36c50657b2900358c6f7318c48c 100644 (file)
@@ -53,7 +53,6 @@ namespace ASDCP {
 namespace dcp {
 
 class OpenJPEGImage;
-class DecryptionContext;
 
 /** A single frame of a 3D (stereoscopic) picture asset */
 class StereoPictureFrame : public boost::noncopyable
index a76ca6a145a415b28b07a1984b619389b8f5002b..323ceaee04049d7ed1e3bc57586dba7a7a0bf040 100644 (file)
@@ -47,10 +47,8 @@ def build(bld):
              dcp.cc
              dcp_time.cc
              decrypted_kdm.cc
-             decryption_context.cc
              decrypted_kdm_key.cc
              encrypted_kdm.cc
-             encryption_context.cc
              exceptions.cc
              file.cc
              font_asset.cc
@@ -116,6 +114,7 @@ def build(bld):
               certificate.h
               chromaticity.h
               colour_conversion.h
+              context.h
               cpl.h
               dcp.h
               dcp_assert.h
@@ -123,9 +122,7 @@ def build(bld):
               data.h
               decrypted_kdm.h
               decrypted_kdm_key.h
-              decryption_context.h
               encrypted_kdm.h
-              encryption_context.h
               exceptions.h
               font_asset.h
               frame.h
index b6e28b254e2777d598480c486afd5ee5db4dbc2d..6a10c6415c54ad447848fd5e1703d64711692e4a 100644 (file)
@@ -33,7 +33,7 @@
 
 #include "encrypted_kdm.h"
 #include "decrypted_kdm.h"
-#include "decryption_context.h"
+#include "crypto_context.h"
 #include "key.h"
 #include "util.h"
 #include "atmos_asset.h"
@@ -98,7 +98,7 @@ atmos (
                exit (EXIT_FAILURE);
        }
 
-       dcp::DecryptionContext dc (key.get());
+       dcp::DecryptionContext dc (key.get(), dcp::SMPTE);
 
        ASDCP::ATMOS::AtmosDescriptor desc;
        if (ASDCP_FAILURE (reader.FillAtmosDescriptor (desc))) {
@@ -109,7 +109,7 @@ atmos (
        ASDCP::DCData::FrameBuffer buffer (Kumu::Megabyte);
 
        for (size_t i = 0; i < desc.ContainerDuration; ++i) {
-               reader.ReadFrame (i, buffer, dc.decryption(), 0);
+               reader.ReadFrame (i, buffer, dc.context(), 0);
        }
 
        return 0;