botan icon indicating copy to clipboard operation
botan copied to clipboard

Internal: load_be/le should accept a BufferSlicer

Open reneme opened this issue 1 year ago • 0 comments

Additional context here: https://github.com/randombit/botan/pull/3716#discussion_r1584989832

TL;DR: Reduce the boiler-plate when loading integers of a statically known bitlength from a buffer:

// currently
auto a = load_be<uint32_t>(slicer.take<4>());
auto b = load_be<SomeStrongIntegerType>(slicer.take<sizeof(SomeStrongIntegerType)>());

// then
auto a = load_be<uint32_t>(slicer);
auto b = load_be<SomeStrongIntegerType>(slicer);

Note that the BufferSlicer is currently part of stl_util.h which we may or may not want to include in loadstor.h. Perhaps it makes sense to move the BufferSlicer, BufferStuffer and concat() into their own dedicated header.

reneme avatar May 22 '24 14:05 reneme