#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 ());
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;
};
}
#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>
, _frames_written (0)
, _finalized (false)
, _started (false)
- , _encryption_context (new EncryptionContext (mxf->key(), mxf->standard()))
+ , _crypto_context (new EncryptionContext (mxf->key(), mxf->standard()))
{
}
#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.
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;
};
}
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>
#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;
_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))));
}
+++ /dev/null
-/*
- 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;
-}
+++ /dev/null
-/*
- 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
+++ /dev/null
-/*
- 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;
-}
+++ /dev/null
-/*
- 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;
-};
-
-}
#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>
/* 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"));
}
}
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
#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>
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));
}
#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>
/* 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))));
namespace dcp {
class OpenJPEGImage;
-class DecryptionContext;
/** @class MonoPictureFrame
* @brief A single frame of a 2D (monoscopic) picture asset.
/*
- Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
#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>
using boost::is_any_of;
using boost::shared_array;
using boost::dynamic_pointer_cast;
+using boost::optional;
using namespace dcp;
SMPTESubtitleAsset::SMPTESubtitleAsset ()
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 */
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));
}
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);
}
/* 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));
}
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));
}
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
#include "subtitle_asset.h"
#include "local_time.h"
#include "mxf.h"
+#include "crypto_context.h"
#include <boost/filesystem.hpp>
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.
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
#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>
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))));
}
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
#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>
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
);
#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>
/* 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)));
}
}
namespace dcp {
class OpenJPEGImage;
-class DecryptionContext;
/** A single frame of a 3D (stereoscopic) picture asset */
class StereoPictureFrame : public boost::noncopyable
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
certificate.h
chromaticity.h
colour_conversion.h
+ context.h
cpl.h
dcp.h
dcp_assert.h
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
#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"
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))) {
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;