summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormsheby <msheby@cinecert.com>2007-10-29 21:24:32 +0000
committermsheby <>2007-10-29 21:24:32 +0000
commitaff131e971b71a648caaae20b6a9c84207085321 (patch)
treee5158febbc7cb462716f5bfa391ccff4cfc0e2b8 /src
parent57ddb7894042229bbc5f14e9257068afcc6f8725 (diff)
Windows portability fixes.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/AS_DCP.h2
-rwxr-xr-xsrc/AS_DCP_AES.cpp81
-rwxr-xr-xsrc/AS_DCP_JP2K.cpp20
-rw-r--r--src/AS_DCP_TimedText.cpp23
-rwxr-xr-xsrc/AS_DCP_internal.h2
-rwxr-xr-xsrc/KM_error.h10
-rwxr-xr-xsrc/KM_util.cpp6
-rwxr-xr-xsrc/h__Reader.cpp6
8 files changed, 79 insertions, 71 deletions
diff --git a/src/AS_DCP.h b/src/AS_DCP.h
index 5f75521..1cefa98 100755
--- a/src/AS_DCP.h
+++ b/src/AS_DCP.h
@@ -155,7 +155,7 @@ namespace ASDCP {
// 1.0.1. If changes were also required in AS_DCP.h, the new version would be 1.1.1.
const ui32_t VERSION_MAJOR = 1;
const ui32_t VERSION_APIMINOR = 2;
- const ui32_t VERSION_IMPMINOR = 16;
+ const ui32_t VERSION_IMPMINOR = 17;
const char* Version();
// UUIDs are passed around as strings of UUIDlen bytes
diff --git a/src/AS_DCP_AES.cpp b/src/AS_DCP_AES.cpp
index cd3e41b..dbaa3d5 100755
--- a/src/AS_DCP_AES.cpp
+++ b/src/AS_DCP_AES.cpp
@@ -241,11 +241,19 @@ ASDCP::AESDecContext::DecryptBlock(const byte_t* ct_buf, byte_t* pt_buf, ui32_t
static const ui32_t B_len = 64; // rfc 2104, Sec. 2
-static byte_t ipad[KeyLen] = { 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
- 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36 };
+static byte_t ipad[B_len] = {
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
+ 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36
+};
-static byte_t opad[KeyLen] = { 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
- 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c };
+static byte_t opad[B_len] = {
+ 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
+ 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
+ 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
+ 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c
+};
class HMACContext::h__HMACContext
{
@@ -255,7 +263,6 @@ class HMACContext::h__HMACContext
public:
byte_t m_SHAValue[HMAC_SIZE];
- LabelSet_t m_SetType;
bool m_Final;
h__HMACContext() : m_Final(false) {}
@@ -267,7 +274,6 @@ public:
byte_t rng_buf[SHA_DIGEST_LENGTH*2];
Kumu::Gen_FIPS_186_Value(key, KeyLen, rng_buf, SHA_DIGEST_LENGTH*2);
memcpy(m_key, rng_buf+SHA_DIGEST_LENGTH, KeyLen);
- m_SetType = LS_MXF_SMPTE;
Reset();
}
@@ -285,7 +291,6 @@ public:
SHA1_Update(&SHA, key_nonce, KeyLen);
SHA1_Final(sha_buf, &SHA);
memcpy(m_key, sha_buf, KeyLen);
- m_SetType = LS_MXF_INTEROP;
Reset();
}
@@ -294,28 +299,19 @@ public:
Reset()
{
byte_t xor_buf[B_len];
+ memset(xor_buf, 0, B_len);
+ memcpy(xor_buf, m_key, KeyLen);
+
memset(m_SHAValue, 0, HMAC_SIZE);
m_Final = false;
SHA1_Init(&m_SHA);
// H(K XOR opad, H(K XOR ipad, text))
// ^^^^^^^^^^
- ui32_t i = 0;
-
- for ( ; i < KeyLen; i++ )
- xor_buf[i] = m_key[i] ^ ipad[i];
-
- if ( m_SetType == LS_MXF_SMPTE )
- {
- for ( ; i < B_len; i++ )
- xor_buf[i] = 0 ^ ipad[0];
-
- SHA1_Update(&m_SHA, xor_buf, B_len);
- }
- else
- {
- SHA1_Update(&m_SHA, xor_buf, KeyLen);
- }
+ for ( ui32_t i = 0; i < B_len; i++ )
+ xor_buf[i] ^= ipad[i];
+
+ SHA1_Update(&m_SHA, xor_buf, B_len);
}
//
@@ -331,34 +327,29 @@ public:
void
Finalize()
{
- // H(K XOR opad, H(K XOR ipad, text))
- // ^^^^^^^^^^^^^^^
- SHA1_Final(m_SHAValue, &m_SHA);
-
SHA_CTX SHA;
SHA1_Init(&SHA);
byte_t xor_buf[B_len];
- ui32_t i = 0;
-
- for ( ; i < KeyLen; i++ )
- xor_buf[i] = m_key[i] ^ opad[i];
-
- if ( m_SetType == LS_MXF_SMPTE )
- {
- for ( ; i < B_len; i++ )
- xor_buf[i] = 0 ^ opad[0];
-
- SHA1_Update(&m_SHA, xor_buf, B_len);
- }
- else
- {
- SHA1_Update(&m_SHA, xor_buf, KeyLen);
- }
-
- SHA1_Update(&SHA, xor_buf, KeyLen);
+ memset(xor_buf, 0, B_len);
+ memcpy(xor_buf, m_key, KeyLen);
+
+ SHA1_Init(&SHA);
+
+ // H(K XOR opad, H(K XOR ipad, text))
+ // ^^^^^^^^^^
+ for ( ui32_t i = 0; i < B_len; i++ )
+ xor_buf[i] ^= opad[i];
+
+ SHA1_Update(&SHA, xor_buf, B_len);
+
+ // H(K XOR opad, H(K XOR ipad, text))
+ // ^
+ SHA1_Final(m_SHAValue, &m_SHA);
SHA1_Update(&SHA, m_SHAValue, HMAC_SIZE);
+ // H(K XOR opad, H(K XOR ipad, text))
+ // ^
SHA1_Final(m_SHAValue, &SHA);
m_Final = true;
}
diff --git a/src/AS_DCP_JP2K.cpp b/src/AS_DCP_JP2K.cpp
index f5ce335..a1d9514 100755
--- a/src/AS_DCP_JP2K.cpp
+++ b/src/AS_DCP_JP2K.cpp
@@ -213,10 +213,12 @@ lh__Reader::OpenRead(const char* filename, EssenceType_t type)
if( ASDCP_SUCCESS(result) )
{
- m_HeaderPart.GetMDObjectByType(OBJ_TYPE_ARGS(RGBAEssenceDescriptor),
- (InterchangeObject**)&m_EssenceDescriptor);
- m_HeaderPart.GetMDObjectByType(OBJ_TYPE_ARGS(JPEG2000PictureSubDescriptor),
- (InterchangeObject**)&m_EssenceSubDescriptor);
+ InterchangeObject* tmp_iobj = 0;
+ m_HeaderPart.GetMDObjectByType(OBJ_TYPE_ARGS(RGBAEssenceDescriptor), &tmp_iobj);
+ m_EssenceDescriptor = static_cast<RGBAEssenceDescriptor*>(tmp_iobj);
+
+ m_HeaderPart.GetMDObjectByType(OBJ_TYPE_ARGS(JPEG2000PictureSubDescriptor), &tmp_iobj);
+ m_EssenceSubDescriptor = static_cast<JPEG2000PictureSubDescriptor*>(tmp_iobj);
std::list<InterchangeObject*> ObjectList;
m_HeaderPart.GetMDObjectsByType(OBJ_TYPE_ARGS(Track), ObjectList);
@@ -452,7 +454,11 @@ public:
}
if( ASDCP_SUCCESS(result) )
- result = ReadEKLVPacket(FrameNum, FrameBuf, Dict::ul(MDD_JPEG2000Essence), Ctx, HMAC);
+ {
+ ui32_t SequenceNum = FrameNum * 2;
+ SequenceNum += ( phase == SP_RIGHT ) ? 2 : 1;
+ result = ReadEKLVPacket(FrameNum, SequenceNum, FrameBuf, Dict::ul(MDD_JPEG2000Essence), Ctx, HMAC);
+ }
return result;
}
@@ -718,9 +724,9 @@ lh__Writer::WriteFrame(const JP2K::FrameBuffer& FrameBuf, bool add_index,
IndexTableSegment::IndexEntry Entry;
Entry.StreamOffset = StreamOffset;
m_FooterPart.PushIndexEntry(Entry);
- m_FramesWritten++;
}
+ m_FramesWritten++;
return result;
}
@@ -839,6 +845,8 @@ public:
if ( m_NextPhase != SP_LEFT )
return RESULT_SPHASE;
+ assert( m_FramesWritten % 2 == 0 );
+ m_FramesWritten /= 2;
return lh__Writer::Finalize();
}
};
diff --git a/src/AS_DCP_TimedText.cpp b/src/AS_DCP_TimedText.cpp
index bab3a6a..7f89b1f 100644
--- a/src/AS_DCP_TimedText.cpp
+++ b/src/AS_DCP_TimedText.cpp
@@ -98,8 +98,8 @@ typedef std::map<UUID, UUID> ResourceMap_t;
class ASDCP::TimedText::MXFReader::h__Reader : public ASDCP::h__Reader
{
- TimedTextDescriptor* m_EssenceDescriptor;
- ResourceMap_t m_ResourceMap;
+ DCTimedTextDescriptor* m_EssenceDescriptor;
+ ResourceMap_t m_ResourceMap;
ASDCP_NO_COPY_CONSTRUCT(h__Reader);
@@ -136,7 +136,9 @@ ASDCP::TimedText::MXFReader::h__Reader::MD_to_TimedText_TDesc(TimedText::TimedTe
for ( ; sdi != TDescObj->SubDescriptors.end() && KM_SUCCESS(result); sdi++ )
{
- result = m_HeaderPart.GetMDObjectByID(*sdi, (InterchangeObject**)&DescObject);
+ InterchangeObject* tmp_iobj = 0;
+ result = m_HeaderPart.GetMDObjectByID(*sdi, &tmp_iobj);
+ DescObject = static_cast<DCTimedTextResourceDescriptor*>(tmp_iobj);
if ( KM_SUCCESS(result) )
{
@@ -174,9 +176,14 @@ ASDCP::TimedText::MXFReader::h__Reader::OpenRead(char const* filename)
if( ASDCP_SUCCESS(result) )
{
if ( m_EssenceDescriptor == 0 )
- m_HeaderPart.GetMDObjectByType(OBJ_TYPE_ARGS(DCTimedTextDescriptor), (InterchangeObject**)&m_EssenceDescriptor);
+ {
+ InterchangeObject* tmp_iobj = 0;
+ result = m_HeaderPart.GetMDObjectByType(OBJ_TYPE_ARGS(DCTimedTextDescriptor), &tmp_iobj);
+ m_EssenceDescriptor = static_cast<DCTimedTextDescriptor*>(tmp_iobj);
+ }
- result = MD_to_TimedText_TDesc(m_TDesc);
+ if( ASDCP_SUCCESS(result) )
+ result = MD_to_TimedText_TDesc(m_TDesc);
}
if( ASDCP_SUCCESS(result) )
@@ -225,7 +232,9 @@ ASDCP::TimedText::MXFReader::h__Reader::ReadAncillaryResource(const byte_t* uuid
DCTimedTextResourceDescriptor* DescObject = 0;
// get the subdescriptor
- Result_t result = m_HeaderPart.GetMDObjectByID((*ri).second, (InterchangeObject**)&DescObject);
+ InterchangeObject* tmp_iobj = 0;
+ Result_t result = m_HeaderPart.GetMDObjectByID((*ri).second, &tmp_iobj);
+ DescObject = static_cast<DCTimedTextResourceDescriptor*>(tmp_iobj);
if ( KM_SUCCESS(result) )
{
@@ -279,7 +288,7 @@ ASDCP::TimedText::MXFReader::h__Reader::ReadAncillaryResource(const byte_t* uuid
// read the essence packet
if( ASDCP_SUCCESS(result) )
- result = ReadEKLVPacket(0, FrameBuf, Dict::ul(MDD_DCTimedTextDescriptor), Ctx, HMAC);
+ result = ReadEKLVPacket(0, 1, FrameBuf, Dict::ul(MDD_DCTimedTextDescriptor), Ctx, HMAC);
}
}
}
diff --git a/src/AS_DCP_internal.h b/src/AS_DCP_internal.h
index 143bccf..ed9eec7 100755
--- a/src/AS_DCP_internal.h
+++ b/src/AS_DCP_internal.h
@@ -134,7 +134,7 @@ namespace ASDCP
const byte_t* EssenceUL, AESDecContext* Ctx, HMACContext* HMAC);
// reads from current position
- Result_t ReadEKLVPacket(ui32_t FrameNum, ASDCP::FrameBuffer& FrameBuf,
+ Result_t ReadEKLVPacket(ui32_t FrameNum, ui32_t SequenceNum, ASDCP::FrameBuffer& FrameBuf,
const byte_t* EssenceUL, AESDecContext* Ctx, HMACContext* HMAC);
void Close();
};
diff --git a/src/KM_error.h b/src/KM_error.h
index 2d3513a..31d4f3e 100755
--- a/src/KM_error.h
+++ b/src/KM_error.h
@@ -43,14 +43,14 @@ namespace Kumu
class Result_t
{
- long value;
+ int value;
const char* label;
Result_t();
public:
- static const Result_t& Find(long);
+ static const Result_t& Find(int);
- Result_t(long v, const char* l);
+ Result_t(int v, const char* l);
~Result_t();
inline bool operator==(const Result_t& rhs) const { return value == rhs.value; }
@@ -58,8 +58,8 @@ namespace Kumu
inline bool Success() const { return ( value >= 0 ); }
inline bool Failure() const { return ( value < 0 ); }
- inline long Value() const { return value; }
- inline operator long() const { return value; }
+ inline int Value() const { return value; }
+ inline operator int() const { return value; }
inline const char* Label() const { return label; }
inline operator const char*() const { return label; }
diff --git a/src/KM_util.cpp b/src/KM_util.cpp
index f9a88cd..76b7939 100755
--- a/src/KM_util.cpp
+++ b/src/KM_util.cpp
@@ -45,7 +45,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
struct map_entry_t
{
- long rcode;
+ int rcode;
Kumu::Result_t* result;
};
@@ -56,7 +56,7 @@ static struct map_entry_t s_ResultMap[MapSize];
//
const Kumu::Result_t&
-Kumu::Result_t::Find(long v)
+Kumu::Result_t::Find(int v)
{
if ( v == 0 )
return RESULT_OK;
@@ -72,7 +72,7 @@ Kumu::Result_t::Find(long v)
}
//
-Kumu::Result_t::Result_t(long v, const char* l) : value(v), label(l)
+Kumu::Result_t::Result_t(int v, const char* l) : value(v), label(l)
{
assert(l);
diff --git a/src/h__Reader.cpp b/src/h__Reader.cpp
index 8035ac8..8d844f3 100755
--- a/src/h__Reader.cpp
+++ b/src/h__Reader.cpp
@@ -194,14 +194,14 @@ ASDCP::h__Reader::ReadEKLVFrame(ui32_t FrameNum, ASDCP::FrameBuffer& FrameBuf,
}
if( ASDCP_SUCCESS(result) )
- result = ReadEKLVPacket(FrameNum, FrameBuf, EssenceUL, Ctx, HMAC);
+ result = ReadEKLVPacket(FrameNum, FrameNum + 1, FrameBuf, EssenceUL, Ctx, HMAC);
return result;
}
Result_t
-ASDCP::h__Reader::ReadEKLVPacket(ui32_t FrameNum, ASDCP::FrameBuffer& FrameBuf,
+ASDCP::h__Reader::ReadEKLVPacket(ui32_t FrameNum, ui32_t SequenceNum, ASDCP::FrameBuffer& FrameBuf,
const byte_t* EssenceUL, AESDecContext* Ctx, HMACContext* HMAC)
{
KLReader Reader;
@@ -326,7 +326,7 @@ ASDCP::h__Reader::ReadEKLVPacket(ui32_t FrameNum, ASDCP::FrameBuffer& FrameBuf,
if ( ASDCP_SUCCESS(result) && m_Info.UsesHMAC && HMAC )
{
IntegrityPack IntPack;
- result = IntPack.TestValues(TmpWrapper, m_Info.AssetUUID, FrameNum + 1, HMAC);
+ result = IntPack.TestValues(TmpWrapper, m_Info.AssetUUID, SequenceNum, HMAC);
}
}
else // return ciphertext to caller