1 /** Helper functions for tests that manipulate ASN.1 data. 2 */ 3 /* 4 * Copyright The Mbed TLS Contributors 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 6 */ 7 8 #ifndef ASN1_HELPERS_H 9 #define ASN1_HELPERS_H 10 11 #include "test/helpers.h" 12 13 /** Skip past an INTEGER in an ASN.1 buffer. 14 * 15 * Mark the current test case as failed in any of the following conditions: 16 * - The buffer does not start with an ASN.1 INTEGER. 17 * - The integer's size or parity does not match the constraints expressed 18 * through \p min_bits, \p max_bits and \p must_be_odd. 19 * 20 * \param p Upon entry, `*p` points to the first byte of the 21 * buffer to parse. 22 * On successful return, `*p` points to the first byte 23 * after the parsed INTEGER. 24 * On failure, `*p` is unspecified. 25 * \param end The end of the ASN.1 buffer. 26 * \param min_bits Fail the test case if the integer does not have at 27 * least this many significant bits. 28 * \param max_bits Fail the test case if the integer has more than 29 * this many significant bits. 30 * \param must_be_odd Fail the test case if the integer is even. 31 * 32 * \return \c 0 if the test failed, otherwise 1. 33 */ 34 int mbedtls_test_asn1_skip_integer(unsigned char **p, const unsigned char *end, 35 size_t min_bits, size_t max_bits, 36 int must_be_odd); 37 38 #endif /* ASN1_HELPERS_H */ 39