summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjhurst <jhurst@cinecert.com>2020-09-08 09:33:17 -0700
committerjhurst <jhurst@cinecert.com>2020-09-08 09:33:17 -0700
commit2b52b1cc03707a4c876b38fdd8879a27a218d498 (patch)
tree6510eb7fef08bf66d7a52f097f31109866ce4791 /src
parente1e8fdd9d0715c9df4ab12190cb27b02f3a1c5d8 (diff)
Added OpenSSL and Xerces build options to allow stand-alone compilation
Diffstat (limited to 'src')
-rw-r--r--src/KM_aes.h4
-rw-r--r--src/Makefile.am17
-rwxr-xr-xsrc/as-02-unwrap.cpp8
-rwxr-xr-xsrc/as-02-wrap.cpp45
-rwxr-xr-xsrc/asdcp-test.cpp45
-rwxr-xr-xsrc/asdcp-unwrap.cpp12
-rwxr-xr-xsrc/asdcp-wrap.cpp40
-rwxr-xr-xsrc/kmfilegen.cpp35
-rwxr-xr-xsrc/phdr-unwrap.cpp2
-rwxr-xr-xsrc/phdr-wrap.cpp7
10 files changed, 157 insertions, 58 deletions
diff --git a/src/KM_aes.h b/src/KM_aes.h
index a5ba1d1..9f3aeaf 100644
--- a/src/KM_aes.h
+++ b/src/KM_aes.h
@@ -24,9 +24,9 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
- /*! \file KM_sha1.h
+ /*! \file KM_aes.h
\version $Id$
- \brief SHA-1 message digest
+ \brief AES (Rijndael) encryption
*/
#ifndef _KM_AES_H_
diff --git a/src/Makefile.am b/src/Makefile.am
index da0f8dc..65ab3e0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -54,9 +54,12 @@ include_HEADERS = \
KM_aes.h \
KM_util.h \
KM_tai.h \
- KM_xml.h \
AS_DCP.h
+if HAVE_XERCESC
+#include_HEADERS += KM_xml.h
+endif
+
if DEV_HEADERS
include_HEADERS += \
S12MTimecode.h \
@@ -104,9 +107,13 @@ endif
# sources for kumu library
libkumu_la_SOURCES = KM_error.h KM_fileio.cpp KM_fileio.h KM_log.cpp KM_log.h \
KM_memio.h KM_mutex.h KM_platform.h KM_prng.cpp KM_prng.h KM_util.cpp \
- KM_util.h KM_xml.cpp KM_xml.h KM_tai.h KM_tai.cpp \
+ KM_util.h KM_tai.h KM_tai.cpp \
KM_sha1.cpp KM_sha1.h KM_aes.h KM_aes.cpp
+if HAVE_XERCESC
+#libkumu_la_SOURCES += KM_xml.cpp KM_xml.h
+endif
+
# linker flags (*not* including libraries to link against) for a library
libkumu_la_LDFLAGS = -release @VERSION@
@@ -114,11 +121,12 @@ libkumu_la_LDFLAGS = -release @VERSION@
# sources for asdcp library that don't get added to a distribution
nodist_libasdcp_la_SOURCES = Metadata_h.tt2 Metadata_cpp.tt2 \
mxfgen.pl MXF_def.pl ullist.pl ULList.xml dict.xml DMS_Crypto.xml
+
# sources for asdcp library
libasdcp_la_SOURCES = MPEG2_Parser.cpp MPEG.cpp JP2K_Codestream_Parser.cpp \
JP2K_Sequence_Parser.cpp JP2K.cpp PCM_Parser.cpp Wav.cpp \
TimedText_Parser.cpp KLV.cpp Dict.cpp MXFTypes.cpp MXF.cpp \
- Index.cpp Metadata.cpp AS_DCP.cpp AS_DCP_MXF.cpp AS_DCP_AES.cpp \
+ Index.cpp Metadata.cpp AS_DCP.cpp AS_DCP_MXF.cpp \
h__Reader.cpp h__Writer.cpp AS_DCP_MPEG2.cpp AS_DCP_JP2K.cpp \
AS_DCP_PCM.cpp AS_DCP_TimedText.cpp PCMParserList.cpp \
Wav.h WavFileWriter.h MXF.h Metadata.h \
@@ -133,6 +141,9 @@ libasdcp_la_SOURCES = MPEG2_Parser.cpp MPEG.cpp JP2K_Codestream_Parser.cpp \
UUIDInformation.c UUIDInformation.h \
ST2095_PinkNoise.cpp
+if HAVE_OPENSSL
+libasdcp_la_SOURCES += AS_DCP_AES.cpp
+endif
libasdcp_la_LDFLAGS = -release @VERSION@
# additional libraries to link against for a library
diff --git a/src/as-02-unwrap.cpp b/src/as-02-unwrap.cpp
index f0b3ba3..48cfe93 100755
--- a/src/as-02-unwrap.cpp
+++ b/src/as-02-unwrap.cpp
@@ -356,6 +356,7 @@ read_JP2K_file(CommandOptions& Options)
}
}
+#ifdef HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) && Options.key_flag )
{
Context = new AESDecContext;
@@ -377,6 +378,7 @@ read_JP2K_file(CommandOptions& Options)
}
}
}
+#endif // HAVE_OPENSSL
ui32_t last_frame = Options.start_frame + ( Options.duration ? Options.duration : frame_count);
if ( last_frame > frame_count )
@@ -479,6 +481,7 @@ read_ACES_file(CommandOptions& Options)
}
}
+#ifdef HAVE_OPENSSL
if (ASDCP_SUCCESS(result) && Options.key_flag)
{
Context = new AESDecContext;
@@ -500,6 +503,7 @@ read_ACES_file(CommandOptions& Options)
}
}
}
+#endif
ui32_t last_frame = Options.start_frame + (Options.duration ? Options.duration : frame_count);
if (last_frame > frame_count)
@@ -727,6 +731,7 @@ read_PCM_file(CommandOptions& Options)
}
}
+#ifdef HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) && Options.key_flag )
{
Context = new AESDecContext;
@@ -748,6 +753,7 @@ read_PCM_file(CommandOptions& Options)
}
}
}
+#endif // HAVE_OPENSSL
for ( ui32_t i = Options.start_frame; ASDCP_SUCCESS(result) && i < last_frame; i++ )
{
@@ -889,6 +895,7 @@ read_isxd_file(CommandOptions& Options)
}
}
+#ifdef HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) && Options.key_flag )
{
Context = new AESDecContext;
@@ -910,6 +917,7 @@ read_isxd_file(CommandOptions& Options)
}
}
}
+#endif // HAVE_OPENSSL
ui32_t last_frame = Options.start_frame + ( Options.duration ? Options.duration : frame_count);
if ( last_frame > frame_count )
diff --git a/src/as-02-wrap.cpp b/src/as-02-wrap.cpp
index db76e19..f512084 100755
--- a/src/as-02-wrap.cpp
+++ b/src/as-02-wrap.cpp
@@ -37,13 +37,15 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <KM_fileio.h>
-#include <KM_prng.h>
-#include <KM_xml.h>
#include <AS_02.h>
#include "AS_02_ACES.h"
#include <PCMParserList.h>
#include <Metadata.h>
+#ifdef HAVE_XERCES_C
+#include <KM_xml.h>
+#endif
+
using namespace ASDCP;
const ui32_t FRAME_BUFFER_SIZE = 4 * Kumu::Megabyte;
@@ -987,8 +989,6 @@ write_JP2K_file(CommandOptions& Options)
AS_02::JP2K::MXFWriter Writer;
JP2K::FrameBuffer FrameBuffer(Options.fb_size);
JP2K::SequenceParser Parser;
- byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
ASDCP::MXF::FileDescriptor *essence_descriptor = 0;
ASDCP::MXF::InterchangeObject_list_t essence_sub_descriptors;
@@ -1098,9 +1098,12 @@ write_JP2K_file(CommandOptions& Options)
else
Kumu::GenRandomUUID(Info.AssetUUID);
+#ifdef HAVE_OPENSSL
// configure encryption
if( Options.key_flag )
{
+ byte_t IV_buf[CBC_BLOCK_SIZE];
+ Kumu::FortunaRNG RNG;
Kumu::GenRandomUUID(Info.ContextID);
Info.EncryptedEssence = true;
@@ -1126,6 +1129,7 @@ write_JP2K_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) )
{
@@ -1191,8 +1195,6 @@ write_ACES_file(CommandOptions& Options)
AS_02::ACES::MXFWriter Writer;
AS_02::ACES::FrameBuffer FrameBuffer(Options.fb_size);
AS_02::ACES::SequenceParser Parser;
- byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
ASDCP::MXF::FileDescriptor *essence_descriptor = 0;
ASDCP::MXF::InterchangeObject_list_t essence_sub_descriptors;
AS_02::ACES::PictureDescriptor PDesc;
@@ -1314,6 +1316,10 @@ write_ACES_file(CommandOptions& Options)
else
Kumu::GenRandomUUID(Info.AssetUUID);
+#ifdef HAVE_OPENSSL
+ byte_t IV_buf[CBC_BLOCK_SIZE];
+ Kumu::FortunaRNG RNG;
+
// configure encryption
if (Options.key_flag)
{
@@ -1342,6 +1348,7 @@ write_ACES_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif
if (ASDCP_SUCCESS(result))
{
@@ -1435,8 +1442,6 @@ write_PCM_file(CommandOptions& Options)
PCMParserList Parser;
AS_02::PCM::MXFWriter Writer;
PCM::FrameBuffer FrameBuffer;
- byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
ASDCP::MXF::WaveAudioDescriptor *essence_descriptor = 0;
// set up essence parser
@@ -1511,9 +1516,12 @@ write_PCM_file(CommandOptions& Options)
else
Kumu::GenRandomUUID(Info.AssetUUID);
+#ifdef HAVE_OPENSSL
// configure encryption
if( Options.key_flag )
{
+ byte_t IV_buf[CBC_BLOCK_SIZE];
+ Kumu::FortunaRNG RNG;
Kumu::GenRandomUUID(Info.ContextID);
Info.EncryptedEssence = true;
@@ -1539,6 +1547,7 @@ write_PCM_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) )
{
@@ -1587,7 +1596,7 @@ write_PCM_file(CommandOptions& Options)
-
+#ifdef HAVE_XERCES_C
//------------------------------------------------------------------------------------------
// TimedText essence
@@ -1605,7 +1614,6 @@ write_timed_text_file(CommandOptions& Options)
TimedText::FrameBuffer FrameBuffer;
TimedText::TimedTextDescriptor TDesc;
byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
// set up essence parser
Result_t result = Parser.OpenRead(Options.filenames.front());
@@ -1640,9 +1648,11 @@ write_timed_text_file(CommandOptions& Options)
else
Kumu::GenRandomUUID(Info.AssetUUID);
+#ifdef HAVE_OPENSSL
// configure encryption
if( Options.key_flag )
{
+ Kumu::FortunaRNG RNG;
Kumu::GenRandomUUID(Info.ContextID);
Info.EncryptedEssence = true;
@@ -1668,6 +1678,7 @@ write_timed_text_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) )
result = Writer.OpenWrite(Options.out_file.c_str(), Info, TDesc);
@@ -1715,6 +1726,7 @@ write_timed_text_file(CommandOptions& Options)
return result;
}
+#endif // HAVE_XERCES_C
//
bool
@@ -1745,8 +1757,6 @@ write_isxd_file(CommandOptions& Options)
AS_02::ISXD::MXFWriter Writer;
DCData::FrameBuffer FrameBuffer(Options.fb_size);
DCData::SequenceParser Parser;
- byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
// set up essence parser
Result_t result = Parser.OpenRead(Options.filenames.front());
@@ -1772,9 +1782,12 @@ write_isxd_file(CommandOptions& Options)
Info.LabelSetType = LS_MXF_SMPTE;
+#ifdef HAVE_OPENSSL
// configure encryption
if( Options.key_flag )
{
+ byte_t IV_buf[CBC_BLOCK_SIZE];
+ Kumu::FortunaRNG RNG;
Kumu::GenRandomUUID(Info.ContextID);
Info.EncryptedEssence = true;
@@ -1800,9 +1813,11 @@ write_isxd_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) )
{
+#ifdef HAVE_XERCES_C
if ( Options.isxd_document_namespace == "auto" )
{
// get ns of first item
@@ -1826,6 +1841,7 @@ write_isxd_file(CommandOptions& Options)
return RESULT_FAIL;
}
}
+#endif
result = Writer.OpenWrite(Options.out_file, Info, Options.isxd_document_namespace, Options.edit_rate);
}
@@ -1897,11 +1913,12 @@ write_isxd_file(CommandOptions& Options)
return RESULT_READFAIL;
global_metadata.Size(read_count);
-
+#ifdef HAVE_XERCES_C
std::string ns_prefix, type_name;
Kumu::AttributeList doc_attr_list;
result = GetXMLDocType(global_metadata.RoData(), global_metadata.Size(), ns_prefix, type_name,
namespace_name, doc_attr_list) ? RESULT_OK : RESULT_FAIL;
+#endif
}
if ( KM_SUCCESS(result) )
@@ -1984,9 +2001,11 @@ main(int argc, const char** argv)
result = write_PCM_file(Options);
break;
+#ifdef HAVE_XERCES_C
case ESS_TIMED_TEXT:
result = write_timed_text_file(Options);
break;
+#endif //HAVE_XERCES_C
case ESS_DCDATA_UNKNOWN:
if ( ! Options.isxd_document_namespace.empty() )
diff --git a/src/asdcp-test.cpp b/src/asdcp-test.cpp
index fbb952d..29f8c6e 100755
--- a/src/asdcp-test.cpp
+++ b/src/asdcp-test.cpp
@@ -555,7 +555,6 @@ write_MPEG2_file(CommandOptions& Options)
MPEG2::MXFWriter Writer;
MPEG2::VideoDescriptor VDesc;
byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
// set up essence parser
Result_t result = Parser.OpenRead(Options.filenames[0]);
@@ -588,9 +587,12 @@ write_MPEG2_file(CommandOptions& Options)
fprintf(stderr, "ATTENTION! Writing SMPTE Universal Labels\n");
}
+#ifdef HAVE_OPENSSL
// configure encryption
if( Options.key_flag )
{
+ Kumu::FortunaRNG RNG;
+
Kumu::GenRandomUUID(Info.ContextID);
Info.EncryptedEssence = true;
@@ -612,6 +614,7 @@ write_MPEG2_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) )
result = Writer.OpenWrite(Options.out_file, Info, VDesc);
@@ -698,6 +701,7 @@ read_MPEG2_file(CommandOptions& Options)
result = OutFile.OpenWrite(filename);
}
+#ifdef HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) && Options.key_flag )
{
Context = new AESDecContext;
@@ -719,6 +723,7 @@ read_MPEG2_file(CommandOptions& Options)
}
}
}
+#endif // HAVE_OPENSSL
ui32_t last_frame = Options.start_frame + ( Options.duration ? Options.duration : frame_count);
if ( last_frame > frame_count )
@@ -806,7 +811,6 @@ write_JP2K_S_file(CommandOptions& Options)
JP2K::PictureDescriptor PDesc;
JP2K::SequenceParser ParserLeft, ParserRight;
byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
if ( Options.file_count != 2 )
{
@@ -848,9 +852,12 @@ write_JP2K_S_file(CommandOptions& Options)
fprintf(stderr, "ATTENTION! Writing SMPTE Universal Labels\n");
}
+#ifdef HAVE_OPENSSL
// configure encryption
if( Options.key_flag )
{
+ Kumu::FortunaRNG RNG;
+
Kumu::GenRandomUUID(Info.ContextID);
Info.EncryptedEssence = true;
@@ -872,6 +879,7 @@ write_JP2K_S_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) )
result = Writer.OpenWrite(Options.out_file, Info, PDesc);
@@ -953,6 +961,7 @@ read_JP2K_S_file(CommandOptions& Options)
}
}
+#ifdef HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) && Options.key_flag )
{
Context = new AESDecContext;
@@ -974,6 +983,7 @@ read_JP2K_S_file(CommandOptions& Options)
}
}
}
+#endif // HAVE_OPENSSL
const int filename_max = 1024;
char filename[filename_max];
@@ -1036,7 +1046,6 @@ write_JP2K_file(CommandOptions& Options)
JP2K::PictureDescriptor PDesc;
JP2K::SequenceParser Parser;
byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
// set up essence parser
Result_t result = Parser.OpenRead(Options.filenames[0], Options.j2c_pedantic);
@@ -1070,9 +1079,11 @@ write_JP2K_file(CommandOptions& Options)
fprintf(stderr, "ATTENTION! Writing SMPTE Universal Labels\n");
}
+#ifdef HAVE_OPENSSL
// configure encryption
if( Options.key_flag )
{
+ Kumu::FortunaRNG RNG;
Kumu::GenRandomUUID(Info.ContextID);
Info.EncryptedEssence = true;
@@ -1094,6 +1105,7 @@ write_JP2K_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif
if ( ASDCP_SUCCESS(result) )
result = Writer.OpenWrite(Options.out_file, Info, PDesc);
@@ -1172,6 +1184,7 @@ read_JP2K_file(CommandOptions& Options)
}
}
+#ifdef HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) && Options.key_flag )
{
Context = new AESDecContext;
@@ -1193,6 +1206,7 @@ read_JP2K_file(CommandOptions& Options)
}
}
}
+#endif // HAVE_OPENSSL
ui32_t last_frame = Options.start_frame + ( Options.duration ? Options.duration : frame_count);
if ( last_frame > frame_count )
@@ -1242,7 +1256,6 @@ write_PCM_file(CommandOptions& Options)
PCM::AudioDescriptor ADesc;
Rational PictureRate = Options.PictureRate();
byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
// set up essence parser
Result_t result = Parser.OpenRead(Options.file_count, Options.filenames, PictureRate);
@@ -1286,9 +1299,11 @@ write_PCM_file(CommandOptions& Options)
fprintf(stderr, "ATTENTION! Writing SMPTE Universal Labels\n");
}
+#ifdef HAVE_OPENSSL
// configure encryption
if( Options.key_flag )
{
+ Kumu::FortunaRNG RNG;
Kumu::GenRandomUUID(Info.ContextID);
Info.EncryptedEssence = true;
@@ -1310,6 +1325,7 @@ write_PCM_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) )
result = Writer.OpenWrite(Options.out_file, Info, ADesc);
@@ -1421,6 +1437,7 @@ read_PCM_file(CommandOptions& Options)
( Options.mono_wav ? WavFileWriter::ST_MONO : WavFileWriter::ST_NONE ) ));
}
+#ifdef HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) && Options.key_flag )
{
Context = new AESDecContext;
@@ -1442,6 +1459,7 @@ read_PCM_file(CommandOptions& Options)
}
}
}
+#endif // HAVE_OPENSSL
for ( ui32_t i = Options.start_frame; ASDCP_SUCCESS(result) && i < last_frame; i++ )
{
@@ -1460,6 +1478,7 @@ read_PCM_file(CommandOptions& Options)
}
+#ifdef HAVE_XERCES_C
//------------------------------------------------------------------------------------------
// TimedText essence
@@ -1477,7 +1496,6 @@ write_timed_text_file(CommandOptions& Options)
TimedText::FrameBuffer FrameBuffer;
TimedText::TimedTextDescriptor TDesc;
byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
// set up essence parser
Result_t result = Parser.OpenRead(Options.filenames[0]);
@@ -1509,9 +1527,11 @@ write_timed_text_file(CommandOptions& Options)
fprintf(stderr, "ATTENTION! Writing SMPTE Universal Labels\n");
}
+#ifdef HAVE_OPENSSL
// configure encryption
if( Options.key_flag )
{
+ Kumu::FortunaRNG RNG;
Kumu::GenRandomUUID(Info.ContextID);
Info.EncryptedEssence = true;
@@ -1533,6 +1553,7 @@ write_timed_text_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) )
result = Writer.OpenWrite(Options.out_file, Info, TDesc);
@@ -1580,6 +1601,7 @@ write_timed_text_file(CommandOptions& Options)
return result;
}
+#endif //HAVE_XERCES_C
// Read one or more timed text streams from a plaintext ASDCP file
@@ -1606,6 +1628,7 @@ read_timed_text_file(CommandOptions& Options)
TimedText::DescriptorDump(TDesc);
}
+#ifdef HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) && Options.key_flag )
{
Context = new AESDecContext;
@@ -1627,6 +1650,7 @@ read_timed_text_file(CommandOptions& Options)
}
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_FAILURE(result) )
return result;
@@ -1880,7 +1904,6 @@ show_file_info(CommandOptions& Options)
return result;
}
-
//
Result_t
digest_file(const char* filename)
@@ -1962,11 +1985,9 @@ main(int argc, const char** argv)
}
else if ( Options.mode == MMT_GEN_KEY )
{
- Kumu::FortunaRNG RNG;
- byte_t bin_buf[KeyLen];
-
- RNG.FillRandom(bin_buf, KeyLen);
- printf("%s\n", Kumu::bin2hex(bin_buf, KeyLen, str_buf, 64));
+ Kumu::SymmetricKey key;
+ GenRandomValue(key);
+ printf("%s\n", Kumu::bin2hex(key.Value(), key.Size(), str_buf, 64));
}
else if ( Options.mode == MMT_GEN_ID )
{
@@ -2058,9 +2079,11 @@ main(int argc, const char** argv)
result = write_PCM_file(Options);
break;
+#ifdef HAVE_XERCES_C
case ESS_TIMED_TEXT:
result = write_timed_text_file(Options);
break;
+#endif //HAVE_XERCES_C
default:
fprintf(stderr, "%s: Unknown file type, not ASDCP-compatible essence.\n",
diff --git a/src/asdcp-unwrap.cpp b/src/asdcp-unwrap.cpp
index a24219f..7b607d9 100755
--- a/src/asdcp-unwrap.cpp
+++ b/src/asdcp-unwrap.cpp
@@ -356,6 +356,7 @@ read_MPEG2_file(CommandOptions& Options)
result = OutFile.OpenWrite(filename);
}
+#ifdef HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) && Options.key_flag )
{
Context = new AESDecContext;
@@ -377,6 +378,7 @@ read_MPEG2_file(CommandOptions& Options)
}
}
}
+#endif // HAVE_OPENSSL
ui32_t last_frame = Options.start_frame + ( Options.duration ? Options.duration : frame_count);
if ( last_frame > frame_count )
@@ -483,6 +485,7 @@ read_JP2K_S_file(CommandOptions& Options)
}
}
+#ifdef HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) && Options.key_flag )
{
Context = new AESDecContext;
@@ -504,6 +507,7 @@ read_JP2K_S_file(CommandOptions& Options)
}
}
}
+#endif // HAVE_OPENSSL
const int filename_max = 1024;
char filename[filename_max];
@@ -589,6 +593,7 @@ read_JP2K_file(CommandOptions& Options)
}
}
+#ifdef HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) && Options.key_flag )
{
Context = new AESDecContext;
@@ -610,6 +615,7 @@ read_JP2K_file(CommandOptions& Options)
}
}
}
+#endif // HAVE_OPENSSL
ui32_t last_frame = Options.start_frame + ( Options.duration ? Options.duration : frame_count);
if ( last_frame > frame_count )
@@ -721,6 +727,7 @@ read_PCM_file(CommandOptions& Options)
}
}
+#ifdef HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) && Options.key_flag )
{
Context = new AESDecContext;
@@ -742,6 +749,7 @@ read_PCM_file(CommandOptions& Options)
}
}
}
+#endif // HAVE_OPENSSL
for ( ui32_t i = Options.start_frame; ASDCP_SUCCESS(result) && i < last_frame; i++ )
{
@@ -790,6 +798,7 @@ read_timed_text_file(CommandOptions& Options)
TimedText::DescriptorDump(TDesc);
}
+#ifdef HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) && Options.key_flag )
{
Context = new AESDecContext;
@@ -811,6 +820,7 @@ read_timed_text_file(CommandOptions& Options)
}
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_FAILURE(result) )
return result;
@@ -881,6 +891,7 @@ read_DCData_file(CommandOptions& Options)
}
}
+#ifdef HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) && Options.key_flag )
{
Context = new AESDecContext;
@@ -902,6 +913,7 @@ read_DCData_file(CommandOptions& Options)
}
}
}
+#endif // HAVE_OPENSSL
ui32_t last_frame = Options.start_frame + ( Options.duration ? Options.duration : frame_count);
if ( last_frame > frame_count )
diff --git a/src/asdcp-wrap.cpp b/src/asdcp-wrap.cpp
index 66f291a..362ff3b 100755
--- a/src/asdcp-wrap.cpp
+++ b/src/asdcp-wrap.cpp
@@ -534,8 +534,6 @@ write_MPEG2_file(CommandOptions& Options)
MPEG2::Parser Parser;
MPEG2::MXFWriter Writer;
MPEG2::VideoDescriptor VDesc;
- byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
// set up essence parser
Result_t result = Parser.OpenRead(Options.filenames.front());
@@ -568,9 +566,12 @@ write_MPEG2_file(CommandOptions& Options)
fprintf(stderr, "ATTENTION! Writing SMPTE Universal Labels\n");
}
+#ifdef HAVE_OPENSSL
// configure encryption
if( Options.key_flag )
{
+ byte_t IV_buf[CBC_BLOCK_SIZE];
+ Kumu::FortunaRNG RNG;
Kumu::GenRandomUUID(Info.ContextID);
Info.EncryptedEssence = true;
@@ -596,6 +597,7 @@ write_MPEG2_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) )
result = Writer.OpenWrite(Options.out_file, Info, VDesc);
@@ -690,7 +692,6 @@ write_JP2K_S_file(CommandOptions& Options)
JP2K::PictureDescriptor PDesc;
JP2K::SequenceParser ParserLeft, ParserRight;
byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
if ( Options.filenames.size() != 2 )
{
@@ -738,9 +739,11 @@ write_JP2K_S_file(CommandOptions& Options)
fprintf(stderr, "ATTENTION! Writing SMPTE Universal Labels\n");
}
+#ifdef HAVE_OPENSSL
// configure encryption
if( Options.key_flag )
{
+ Kumu::FortunaRNG RNG;
Kumu::GenRandomUUID(Info.ContextID);
Info.EncryptedEssence = true;
@@ -766,6 +769,7 @@ write_JP2K_S_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) )
result = Writer.OpenWrite(Options.out_file, Info, PDesc);
@@ -840,7 +844,6 @@ write_JP2K_file(CommandOptions& Options)
JP2K::PictureDescriptor PDesc;
JP2K::SequenceParser Parser;
byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
// set up essence parser
Result_t result = Parser.OpenRead(Options.filenames.front(), Options.j2c_pedantic);
@@ -877,9 +880,11 @@ write_JP2K_file(CommandOptions& Options)
fprintf(stderr, "ATTENTION! Writing SMPTE Universal Labels\n");
}
+#ifdef HAVE_OPENSSL
// configure encryption
if( Options.key_flag )
{
+ Kumu::FortunaRNG RNG;
Kumu::GenRandomUUID(Info.ContextID);
Info.EncryptedEssence = true;
@@ -905,6 +910,7 @@ write_JP2K_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) )
result = Writer.OpenWrite(Options.out_file, Info, PDesc);
@@ -977,7 +983,6 @@ write_PCM_file(CommandOptions& Options)
PCM::AudioDescriptor ADesc;
Rational PictureRate = Options.PictureRate();
byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
// set up essence parser
Result_t result = Parser.OpenRead(Options.filenames, PictureRate);
@@ -1021,9 +1026,11 @@ write_PCM_file(CommandOptions& Options)
fprintf(stderr, "ATTENTION! Writing SMPTE Universal Labels\n");
}
+#ifdef HAVE_OPENSSL
// configure encryption
if( Options.key_flag )
{
+ Kumu::FortunaRNG RNG;
Kumu::GenRandomUUID(Info.ContextID);
Info.EncryptedEssence = true;
@@ -1049,6 +1056,7 @@ write_PCM_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) )
result = Writer.OpenWrite(Options.out_file, Info, ADesc);
@@ -1171,7 +1179,6 @@ write_PCM_with_ATMOS_sync_file(CommandOptions& Options)
PCM::AudioDescriptor ADesc;
Rational PictureRate = Options.PictureRate();
byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
WriterInfo Info = s_MyInfo; // fill in your favorite identifiers here
if ( Options.asset_id_flag )
@@ -1213,9 +1220,11 @@ write_PCM_with_ATMOS_sync_file(CommandOptions& Options)
Info.LabelSetType = LS_MXF_SMPTE;
fprintf(stderr, "ATTENTION! Writing SMPTE Universal Labels\n");
+#ifdef HAVE_OPENSSL
// configure encryption
if( Options.key_flag )
{
+ Kumu::FortunaRNG RNG;
Kumu::GenRandomUUID(Info.ContextID);
Info.EncryptedEssence = true;
@@ -1241,6 +1250,7 @@ write_PCM_with_ATMOS_sync_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) )
result = Writer.OpenWrite(Options.out_file, Info, ADesc);
@@ -1297,6 +1307,8 @@ write_PCM_with_ATMOS_sync_file(CommandOptions& Options)
}
+#ifdef HAVE_XERCES_C
+
//------------------------------------------------------------------------------------------
// TimedText essence
@@ -1314,7 +1326,6 @@ write_timed_text_file(CommandOptions& Options)
TimedText::FrameBuffer FrameBuffer;
TimedText::TimedTextDescriptor TDesc;
byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
// set up essence parser
Result_t result = Parser.OpenRead(Options.filenames.front());
@@ -1344,9 +1355,11 @@ write_timed_text_file(CommandOptions& Options)
Info.LabelSetType = LS_MXF_SMPTE;
fprintf(stderr, "ATTENTION! Writing SMPTE Universal Labels\n");
+#ifdef HAVE_OPENSSL
// configure encryption
if( Options.key_flag )
{
+ Kumu::FortunaRNG RNG;
Kumu::GenRandomUUID(Info.ContextID);
Info.EncryptedEssence = true;
@@ -1372,6 +1385,7 @@ write_timed_text_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) )
result = Writer.OpenWrite(Options.out_file, Info, TDesc);
@@ -1420,6 +1434,8 @@ write_timed_text_file(CommandOptions& Options)
return result;
}
+#endif //HAVE_XERCES_C
+
// Write one or more plaintext Dolby ATMOS bytestreams to a plaintext ASDCP file
// Write one or more plaintext Dolby ATMOS bytestreams to a ciphertext ASDCP file
//
@@ -1433,7 +1449,6 @@ write_dolby_atmos_file(CommandOptions& Options)
ATMOS::AtmosDescriptor ADesc;
DCData::SequenceParser Parser;
byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
// set up essence parser
Result_t result = Parser.OpenRead(Options.filenames.front());
@@ -1468,9 +1483,11 @@ write_dolby_atmos_file(CommandOptions& Options)
Info.LabelSetType = LS_MXF_SMPTE;
+#ifdef HAVE_OPENSSL
// configure encryption
if( Options.key_flag )
{
+ Kumu::FortunaRNG RNG;
Kumu::GenRandomUUID(Info.ContextID);
Info.EncryptedEssence = true;
@@ -1496,6 +1513,7 @@ write_dolby_atmos_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif
if ( ASDCP_SUCCESS(result) )
result = Writer.OpenWrite(Options.out_file, Info, ADesc);
@@ -1555,7 +1573,6 @@ write_aux_data_file(CommandOptions& Options)
DCData::DCDataDescriptor DDesc;
DCData::SequenceParser Parser;
byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
// set up essence parser
Result_t result = Parser.OpenRead(Options.filenames.front());
@@ -1585,9 +1602,11 @@ write_aux_data_file(CommandOptions& Options)
Info.LabelSetType = LS_MXF_SMPTE;
+#ifdef HAVE_OPENSSL
// configure encryption
if( Options.key_flag )
{
+ Kumu::FortunaRNG RNG;
Kumu::GenRandomUUID(Info.ContextID);
Info.EncryptedEssence = true;
@@ -1613,6 +1632,7 @@ write_aux_data_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) )
result = Writer.OpenWrite(Options.out_file, Info, DDesc);
@@ -1726,9 +1746,11 @@ main(int argc, const char** argv)
}
break;
+#ifdef HAVE_XERCES_C
case ESS_TIMED_TEXT:
result = write_timed_text_file(Options);
break;
+#endif //HAVE_XERCES_C
case ESS_DCDATA_DOLBY_ATMOS:
result = write_dolby_atmos_file(Options);
diff --git a/src/kmfilegen.cpp b/src/kmfilegen.cpp
index 2ce0332..21b1d8e 100755
--- a/src/kmfilegen.cpp
+++ b/src/kmfilegen.cpp
@@ -34,7 +34,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <iostream>
#include <KM_fileio.h>
#include <KM_prng.h>
-#include <openssl/aes.h>
+#include <KM_aes.h>
#include <assert.h>
using namespace Kumu;
@@ -43,7 +43,7 @@ using namespace Kumu;
static const char* PROGRAM_NAME = "kmfilegen"; // program name for messages
const ui32_t RNG_KEY_SIZE = 16;
const ui32_t RNG_KEY_SIZE_BITS = 128;
-const ui32_t RNG_BLOCK_SIZE = 16;
+const ui32_t RNG_BLOCK_SIZE = AES_BLOCKLEN;
// globals
ui32_t s_Nonce = 0;
@@ -239,7 +239,7 @@ public:
#pragma pack(4)
class CTR_Setup
{
- AES_KEY m_Context;
+ AES_ctx m_Context;
byte_t m_key[RNG_KEY_SIZE];
byte_t m_preamble[8];
ui32_t m_nonce;
@@ -264,7 +264,7 @@ public:
m_nonce = KM_i32_LE(s_Nonce--);
m_ctr &= KM_i32_LE(0x7fffffff); // make sure we have 2GB headroom
memcpy(buf, m_key, WriteSize());
- AES_set_encrypt_key(m_key, RNG_KEY_SIZE_BITS, &m_Context);
+ AES_init_ctx(&m_Context, m_key);
}
//
@@ -272,7 +272,7 @@ public:
{
assert(buf);
memcpy(m_key, buf, WriteSize());
- AES_set_encrypt_key(m_key, RNG_KEY_SIZE_BITS, &m_Context);
+ AES_init_ctx(&m_Context, m_key);
}
//
@@ -281,7 +281,8 @@ public:
ui32_t gen_count = 0;
while ( gen_count + RNG_BLOCK_SIZE <= buf_len )
{
- AES_encrypt(m_preamble, buf + gen_count, &m_Context);
+ memcpy(buf + gen_count, m_preamble, RNG_BLOCK_SIZE);
+ AES_encrypt(&m_Context, buf + gen_count);
m_ctr = KM_i32_LE(KM_i32_LE(m_ctr) + 1);
gen_count += RNG_BLOCK_SIZE;
}
@@ -308,9 +309,9 @@ CreateLargeFile(CommandOptions& Options)
{
if ( KM_SUCCESS(result))
{
- CTR_Setup CTR;
- CTR.SetupWrite(FB.Data());
- CTR.FillRandom(FB.Data() + CTR.WriteSize(), Megabyte - CTR.WriteSize());
+ CTR_Setup counter;
+ counter.SetupWrite(FB.Data());
+ counter.FillRandom(FB.Data() + counter.WriteSize(), Megabyte - counter.WriteSize());
result = Writer.Write(FB.RoData(), Megabyte, &write_count);
assert(write_count == Megabyte);
fprintf(stderr, "\r%8u ", ++write_total);
@@ -327,21 +328,21 @@ Result_t
validate_chunk(ByteString& FB, ByteString& CB, ui32_t* nonce_value)
{
assert(nonce_value);
- CTR_Setup CTR;
- CTR.SetupRead(FB.RoData());
+ CTR_Setup counter;
+ counter.SetupRead(FB.RoData());
- CTR.FillRandom(CB.Data() + CTR.WriteSize(),
- Megabyte - CTR.WriteSize());
+ counter.FillRandom(CB.Data() + counter.WriteSize(),
+ Megabyte - counter.WriteSize());
- if ( memcmp(FB.RoData() + CTR.WriteSize(),
- CB.RoData() + CTR.WriteSize(),
- Megabyte - CTR.WriteSize()) != 0 )
+ if ( memcmp(FB.RoData() + counter.WriteSize(),
+ CB.RoData() + counter.WriteSize(),
+ Megabyte - counter.WriteSize()) != 0 )
{
fprintf(stderr, "Check data mismatched in chunk\n");
return RESULT_FAIL;
}
- *nonce_value = CTR.Nonce();
+ *nonce_value = counter.Nonce();
return RESULT_OK;
}
diff --git a/src/phdr-unwrap.cpp b/src/phdr-unwrap.cpp
index bd5a5a3..0c00ea9 100755
--- a/src/phdr-unwrap.cpp
+++ b/src/phdr-unwrap.cpp
@@ -322,6 +322,7 @@ read_JP2K_file(CommandOptions& Options)
}
}
+#ifdef HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) && Options.key_flag )
{
Context = new AESDecContext;
@@ -343,6 +344,7 @@ read_JP2K_file(CommandOptions& Options)
}
}
}
+#endif // HAVE_OPENSSL
ui32_t last_frame = Options.start_frame + ( Options.duration ? Options.duration : frame_count);
if ( last_frame > frame_count )
diff --git a/src/phdr-wrap.cpp b/src/phdr-wrap.cpp
index b919b96..1632508 100755
--- a/src/phdr-wrap.cpp
+++ b/src/phdr-wrap.cpp
@@ -471,9 +471,6 @@ write_JP2K_file(CommandOptions& Options)
AESEncContext* Context = 0;
HMACContext* HMAC = 0;
- byte_t IV_buf[CBC_BLOCK_SIZE];
- Kumu::FortunaRNG RNG;
-
ASDCP::MXF::FileDescriptor *essence_descriptor = 0;
ASDCP::MXF::InterchangeObject_list_t essence_sub_descriptors;
@@ -545,9 +542,12 @@ write_JP2K_file(CommandOptions& Options)
else
Kumu::GenRandomUUID(Info.AssetUUID);
+#ifdef HAVE_OPENSSL
// configure encryption
if( Options.key_flag )
{
+ byte_t IV_buf[CBC_BLOCK_SIZE];
+ Kumu::FortunaRNG RNG;
Kumu::GenRandomUUID(Info.ContextID);
Info.EncryptedEssence = true;
@@ -569,6 +569,7 @@ write_JP2K_file(CommandOptions& Options)
result = HMAC->InitKey(Options.key_value, Info.LabelSetType);
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_SUCCESS(result) )
{