From 77e4f485e15d6b7a53531242407bf2388f02f512 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Mon, 22 Feb 2021 16:46:06 +0000 Subject: [PATCH] Move illustration of (un)supported cases in MPS reader documentation Signed-off-by: Hanno Becker --- library/mps_reader.c | 126 +++++++++++++++++++++---------------------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/library/mps_reader.c b/library/mps_reader.c index ee2312c9c..ac2955fec 100644 --- a/library/mps_reader.c +++ b/library/mps_reader.c @@ -247,75 +247,75 @@ int mbedtls_mps_reader_get( mbedtls_mps_reader *rd, /* Check if we're still serving from the accumulator. */ if( mps_reader_serving_from_accumulator( rd ) ) { + /* Illustration of supported and unsupported cases: + * + * - Allowed #1 + * + * +-----------------------------------+ + * | frag | + * +-----------------------------------+ + * + * end end+desired + * | | + * +-----v-------v-------------+ + * | acc | + * +---------------------------+ + * | | + * fo/frag_offset aa/acc_available + * + * - Allowed #2 + * + * +-----------------------------------+ + * | frag | + * +-----------------------------------+ + * + * end end+desired + * | | + * +----------v----------------v + * | acc | + * +---------------------------+ + * | | + * fo/frag_offset aa/acc_available + * + * - Not allowed #1 (could be served, but we don't actually use it): + * + * +-----------------------------------+ + * | frag | + * +-----------------------------------+ + * + * end end+desired + * | | + * +------v-------------v------+ + * | acc | + * +---------------------------+ + * | | + * fo/frag_offset aa/acc_available + * + * + * - Not allowed #2 (can't be served with a contiguous buffer): + * + * +-----------------------------------+ + * | frag | + * +-----------------------------------+ + * + * end end + desired + * | | + * +------v--------------------+ v + * | acc | + * +---------------------------+ + * | | + * fo/frag_offset aa/acc_available + * + * In case of Allowed #2 we're switching to serve from + * `frag` starting from the next call to mbedtls_mps_reader_get(). + */ + unsigned char *acc; MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment, "Serve the request from the accumulator" ); if( frag_offset - end < desired ) { - /* Illustration of supported and unsupported cases: - * - * - Allowed #1 - * - * +-----------------------------------+ - * | frag | - * +-----------------------------------+ - * - * end end+desired - * | | - * +-----v-------v-------------+ - * | acc | - * +---------------------------+ - * | | - * fo/frag_offset aa/acc_available - * - * - Allowed #2 - * - * +-----------------------------------+ - * | frag | - * +-----------------------------------+ - * - * end end+desired - * | | - * +----------v----------------v - * | acc | - * +---------------------------+ - * | | - * fo/frag_offset aa/acc_available - * - * - Not allowed #1 (could be served, but we don't actually use it): - * - * +-----------------------------------+ - * | frag | - * +-----------------------------------+ - * - * end end+desired - * | | - * +------v-------------v------+ - * | acc | - * +---------------------------+ - * | | - * fo/frag_offset aa/acc_available - * - * - * - Not allowed #2 (can't be served with a contiguous buffer): - * - * +-----------------------------------+ - * | frag | - * +-----------------------------------+ - * - * end end + desired - * | | - * +------v--------------------+ v - * | acc | - * +---------------------------+ - * | | - * fo/frag_offset aa/acc_available - * - * In case of Allowed #1 and #2 we're switching to serve from - * `frag` starting from the next call to mbedtls_mps_reader_get(). - */ - mbedtls_mps_size_t acc_available; acc_available = rd->acc_available; if( acc_available - end != desired )