summaryrefslogtreecommitdiff
path: root/src/KM_util.cpp
diff options
context:
space:
mode:
authorjhurst <jhurst@cinecert.com>2009-12-22 21:46:39 +0000
committerjhurst <>2009-12-22 21:46:39 +0000
commitecfb614c4c7f16db4b9d76e650053ba4896b79cc (patch)
tree1ba363a7b768b09a560911180bba23a0e4b9eea6 /src/KM_util.cpp
parentc063fb19776c6f3f650698e47b27e219958d40fb (diff)
big KLV support
Diffstat (limited to 'src/KM_util.cpp')
-rwxr-xr-xsrc/KM_util.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/KM_util.cpp b/src/KM_util.cpp
index b155362..b5dfce6 100755
--- a/src/KM_util.cpp
+++ b/src/KM_util.cpp
@@ -539,9 +539,6 @@ Kumu::GenRandomValue(SymmetricKey& Key)
//------------------------------------------------------------------------------------------
// read a ber value from the buffer and compare with test value.
// Advances buffer to first character after BER value.
-
-// read a ber value from the buffer and compare with test value.
-// Advances buffer to first character after BER value.
//
bool
Kumu::read_test_BER(byte_t **buf, ui64_t test_value)
@@ -605,6 +602,20 @@ static const ui64_t ber_masks[9] =
0
};
+//
+ui32_t
+Kumu::get_BER_length_for_value(ui64_t val)
+{
+ for ( ui32_t i = 0; i < 9; i++ )
+ {
+ if ( ( val & ber_masks[i] ) == 0 )
+ return i + 1;
+ }
+
+ ui64Printer tmp_i(val);
+ DefaultLogSink().Error("BER integer encoding not supported for large value %s\n", tmp_i.c_str());
+ return 0;
+}
//
bool
@@ -626,14 +637,14 @@ Kumu::write_BER(byte_t* buf, ui64_t val, ui32_t ber_len)
{ // sanity check BER length
if ( ber_len > 9 )
{
- DefaultLogSink().Error("BER size %u exceeds maximum size of 9\n", ber_len);
+ DefaultLogSink().Error("BER integer length %u exceeds maximum size of 9\n", ber_len);
return false;
}
- if ( val & ber_masks[ber_len - 1] )
+ if ( ( val & ber_masks[ber_len - 1] ) != 0 )
{
ui64Printer tmp_i(val);
- DefaultLogSink().Error("BER size %u too small for value %s\n", tmp_i.c_str());
+ DefaultLogSink().Error("BER integer length %u too small for value %s\n", ber_len, tmp_i.c_str());
return false;
}
}