summaryrefslogtreecommitdiff
path: root/src/smpte_subtitle_asset.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-03-06 01:15:43 +0000
committerCarl Hetherington <cth@carlh.net>2018-03-13 22:29:01 +0000
commit380d7af94562883cdcaa60726d0ffa36f3dab304 (patch)
treea36f4828d8ebf54efcf0f3155f49b54b430b67f6 /src/smpte_subtitle_asset.cc
parent0e29e68e94daade47167ac5bc6b51362ef02b5c3 (diff)
Merge EncryptionContext with DecryptionContext and use HMAC when decrypting.
Diffstat (limited to 'src/smpte_subtitle_asset.cc')
-rw-r--r--src/smpte_subtitle_asset.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc
index a0472f3f..cd692736 100644
--- a/src/smpte_subtitle_asset.cc
+++ b/src/smpte_subtitle_asset.cc
@@ -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));
}