Skip to content

Commit 2665fd7

Browse files
author
dbullock
committed
Add more output on HMAC compare failure.
- ASDCP::IntegrityPack::TestValues - dump an error message that includes expected and found HMAC
1 parent 5c74d64 commit 2665fd7

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

src/AS_DCP_MXF.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3636
#include "ACES.h"
3737
#include "MPEG.h"
3838
#include "Wav.h"
39+
#include "KM_util.h"
3940
#include <iostream>
4041
#include <iomanip>
4142

@@ -688,7 +689,33 @@ ASDCP::IntegrityPack::TestValues(const ASDCP::FrameBuffer& FB, const byte_t* Ass
688689
HMAC->Update(FB.RoData(), FB.Size() - HMAC_SIZE);
689690
HMAC->Finalize();
690691

691-
return HMAC->TestHMACValue(p);
692+
Result_t result = RESULT_OK;
693+
result = HMAC->TestHMACValue(p);
694+
695+
if (KM_FAILURE(result))
696+
{
697+
Result_t r = RESULT_OK;
698+
char hmac_str[HMAC_SIZE*10];
699+
char found_str[HMAC_SIZE*10];
700+
byte_t hmac_buf[HMAC_SIZE];
701+
702+
703+
Kumu::bin2hex(p, HMAC_SIZE, found_str, HMAC_SIZE*10);
704+
705+
r = HMAC->GetHMACValue(hmac_buf);
706+
if ( KM_SUCCESS( r ) )
707+
{
708+
Kumu::bin2hex(hmac_buf, HMAC_SIZE, hmac_str, HMAC_SIZE*10);
709+
}
710+
else
711+
{
712+
snprintf(hmac_str, HMAC_SIZE*10, " - read error - ");
713+
}
714+
715+
DefaultLogSink().Error("IntegrityPack failure: HMAC is %s, expecting %s.\n", found_str, hmac_str);
716+
}
717+
718+
return result;
692719
}
693720

694721
//

0 commit comments

Comments
 (0)