summaryrefslogtreecommitdiff
path: root/src/asdcp-test.cpp
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/asdcp-test.cpp
parente1e8fdd9d0715c9df4ab12190cb27b02f3a1c5d8 (diff)
Added OpenSSL and Xerces build options to allow stand-alone compilation
Diffstat (limited to 'src/asdcp-test.cpp')
-rwxr-xr-xsrc/asdcp-test.cpp45
1 files changed, 34 insertions, 11 deletions
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",