summaryrefslogtreecommitdiff
path: root/src/asdcp-test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/asdcp-test.cpp')
-rwxr-xr-xsrc/asdcp-test.cpp45
1 files changed, 32 insertions, 13 deletions
diff --git a/src/asdcp-test.cpp b/src/asdcp-test.cpp
index df108c3..ecf6f21 100755
--- a/src/asdcp-test.cpp
+++ b/src/asdcp-test.cpp
@@ -49,11 +49,11 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <KM_fileio.h>
#include <KM_prng.h>
+#include <KM_sha1.h>
#include <PCMParserList.h>
#include <WavFileWriter.h>
#include <MXF.h>
#include <Metadata.h>
-#include <openssl/sha.h>
#include <iostream>
#include <assert.h>
@@ -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++ )
{
@@ -1477,7 +1495,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 +1526,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 +1552,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);
@@ -1606,6 +1626,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 +1648,7 @@ read_timed_text_file(CommandOptions& Options)
}
}
}
+#endif // HAVE_OPENSSL
if ( ASDCP_FAILURE(result) )
return result;
@@ -1880,7 +1902,6 @@ show_file_info(CommandOptions& Options)
return result;
}
-
//
Result_t
digest_file(const char* filename)
@@ -1889,7 +1910,7 @@ digest_file(const char* filename)
ASDCP_TEST_NULL_STR(filename);
FileReader Reader;
- SHA_CTX Ctx;
+ SHA1_CTX Ctx;
SHA1_Init(&Ctx);
ByteString Buf(8192);
@@ -1962,11 +1983,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 )
{