diff options
Diffstat (limited to 'src')
| -rwxr-xr-x | src/AS_DCP.h | 5 | ||||
| -rwxr-xr-x | src/AS_DCP_AES.cpp | 21 | ||||
| -rwxr-xr-x | src/AS_DCP_JP2K.cpp | 2 | ||||
| -rw-r--r-- | src/h__02_Writer.cpp | 12 | ||||
| -rwxr-xr-x | src/h__Writer.cpp | 12 |
5 files changed, 47 insertions, 5 deletions
diff --git a/src/AS_DCP.h b/src/AS_DCP.h index f089f06..fa8b00a 100755 --- a/src/AS_DCP.h +++ b/src/AS_DCP.h @@ -508,6 +508,11 @@ namespace ASDCP { // point to a readable area of memory that is at least HMAC_SIZE bytes in length. // Returns error if the buf argument is NULL or if the values do ot match. Result_t TestHMACValue(const byte_t* buf) const; + + // Writes MIC key to given buffer. buf must point to a writable area of + // memory that is at least KeyLen bytes in length. Returns error if the + // buf argument is NULL. + Result_t GetMICKey(byte_t* buf) const; }; //--------------------------------------------------------------------------------- diff --git a/src/AS_DCP_AES.cpp b/src/AS_DCP_AES.cpp index 379e8ab..6409f5b 100755 --- a/src/AS_DCP_AES.cpp +++ b/src/AS_DCP_AES.cpp @@ -349,6 +349,13 @@ public: SHA1_Final(m_SHAValue, &SHA); m_Final = true; } + + // + void + GetMICKey(byte_t* buf) const + { + memcpy(buf, m_key, KeyLen); + } }; @@ -444,6 +451,20 @@ HMACContext::TestHMACValue(const byte_t* buf) const } +// +Result_t +HMACContext::GetMICKey(byte_t* buf) const +{ + KM_TEST_NULL_L(buf); + + if ( m_Context.empty() ) + return RESULT_INIT; + + m_Context->GetMICKey(buf); + return RESULT_OK; +} + + // // end AS_DCP_AES.cpp diff --git a/src/AS_DCP_JP2K.cpp b/src/AS_DCP_JP2K.cpp index 129f53d..d5fddaa 100755 --- a/src/AS_DCP_JP2K.cpp +++ b/src/AS_DCP_JP2K.cpp @@ -319,7 +319,7 @@ ASDCP::JP2K_PDesc_to_MD(const JP2K::PictureDescriptor& PDesc, EssenceSubDescriptor.PictureComponentSizing.set_has_value(); ui32_t precinct_set_size = 0; - for ( ui32_t i = 0; PDesc.CodingStyleDefault.SPcod.PrecinctSize[i] != 0 && i < MaxPrecincts; ++i ) + for ( ui32_t i = 0; i < MaxPrecincts && PDesc.CodingStyleDefault.SPcod.PrecinctSize[i] != 0; ++i ) precinct_set_size++; ui32_t csd_size = sizeof(CodingStyleDefault_t) - MaxPrecincts + precinct_set_size; diff --git a/src/h__02_Writer.cpp b/src/h__02_Writer.cpp index 9b1c6c6..d7cfaa3 100644 --- a/src/h__02_Writer.cpp +++ b/src/h__02_Writer.cpp @@ -161,7 +161,17 @@ AS_02::MXF::AS02IndexWriterVBR::PushIndexEntry(const IndexTableSegment::IndexEnt m_CurrentSegment->DeltaEntryArray.push_back(IndexTableSegment::DeltaEntry()); m_CurrentSegment->IndexEditRate = m_EditRate; m_CurrentSegment->IndexStartPosition = 0; - } + } else if (m_CurrentSegment->IndexEntryArray.size() >= CBRIndexEntriesPerSegment) { // no, this one is full, start another + m_CurrentSegment->IndexDuration = m_CurrentSegment->IndexEntryArray.size(); + ui64_t StartPosition = m_CurrentSegment->IndexStartPosition + m_CurrentSegment->IndexDuration; + + m_CurrentSegment = new IndexTableSegment(m_Dict); + assert(m_CurrentSegment); + AddChildObject(m_CurrentSegment); + m_CurrentSegment->DeltaEntryArray.push_back(IndexTableSegment::DeltaEntry()); + m_CurrentSegment->IndexEditRate = m_EditRate; + m_CurrentSegment->IndexStartPosition = StartPosition; + } m_CurrentSegment->IndexEntryArray.push_back(Entry); } diff --git a/src/h__Writer.cpp b/src/h__Writer.cpp index fc7f060..0c56b4c 100755 --- a/src/h__Writer.cpp +++ b/src/h__Writer.cpp @@ -374,6 +374,15 @@ ASDCP::Write_EKLV_Packet(Kumu::FileWriter& File, const ASDCP::Dictionary& Dict, byte_t overhead[128]; Kumu::MemIOWriter Overhead(overhead, 128); + // We declare HMACOverhead and its buffer in the outer scope, even though it is not used on + // unencrypted content: the reason is that File.Writev(const byte_t* buf, ui32_t buf_len) doesn't + // write data right away but saves a pointer on the buffer. And we write all the buffers at the end + // when calling File.writev(). + // Declaring the buffer variable in an inner scope means the buffer will go out of scope + // before the data it contains has been actually written, which means its content could be + // overwritten/get corrupted. + byte_t hmoverhead[512]; + Kumu::MemIOWriter HMACOverhead(hmoverhead, 512); if ( FrameBuf.Size() == 0 ) { @@ -455,9 +464,6 @@ ASDCP::Write_EKLV_Packet(Kumu::FileWriter& File, const ASDCP::Dictionary& Dict, { StreamOffset += CtFrameBuf.Size(); - byte_t hmoverhead[512]; - Kumu::MemIOWriter HMACOverhead(hmoverhead, 512); - // write the HMAC if ( Info.UsesHMAC ) { |
