| Glenn Strauss | 6f545ac | 2022-10-25 15:02:14 -0400 | [diff] [blame] | 1 | /** | 
|  | 2 | * \file x509_invasive.h | 
|  | 3 | * | 
|  | 4 | * \brief x509 module: interfaces for invasive testing only. | 
|  | 5 | * | 
|  | 6 | * The interfaces in this file are intended for testing purposes only. | 
|  | 7 | * They SHOULD NOT be made available in library integrations except when | 
|  | 8 | * building the library for testing. | 
|  | 9 | */ | 
|  | 10 | /* | 
|  | 11 | *  Copyright The Mbed TLS Contributors | 
|  | 12 | *  SPDX-License-Identifier: Apache-2.0 | 
|  | 13 | * | 
|  | 14 | *  Licensed under the Apache License, Version 2.0 (the "License"); you may | 
|  | 15 | *  not use this file except in compliance with the License. | 
|  | 16 | *  You may obtain a copy of the License at | 
|  | 17 | * | 
|  | 18 | *  http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 19 | * | 
|  | 20 | *  Unless required by applicable law or agreed to in writing, software | 
|  | 21 | *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | 
|  | 22 | *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 23 | *  See the License for the specific language governing permissions and | 
|  | 24 | *  limitations under the License. | 
|  | 25 | */ | 
|  | 26 |  | 
|  | 27 | #ifndef MBEDTLS_X509_INVASIVE_H | 
|  | 28 | #define MBEDTLS_X509_INVASIVE_H | 
|  | 29 |  | 
|  | 30 | #include "common.h" | 
|  | 31 |  | 
|  | 32 | #if defined(MBEDTLS_TEST_HOOKS) | 
|  | 33 |  | 
|  | 34 | /** | 
|  | 35 | * \brief          This function parses a CN string as an IP address. | 
|  | 36 | * | 
|  | 37 | * \param cn       The CN string to parse. CN string MUST be NUL-terminated. | 
|  | 38 | * \param dst      The target buffer to populate with the binary IP address. | 
|  | 39 | *                 The buffer MUST be 16 bytes to save IPv6, and should be | 
|  | 40 | *                 4-byte aligned if the result will be used as struct in_addr. | 
|  | 41 | *                 e.g. uint32_t dst[4] | 
|  | 42 | * | 
|  | 43 | * \note           \cn is parsed as an IPv6 address if string contains ':', | 
|  | 44 | *                 else \cn is parsed as an IPv4 address. | 
|  | 45 | * | 
|  | 46 | * \return         Length of binary IP address; num bytes written to target. | 
|  | 47 | * \return         \c 0 on failure to parse CN string as an IP address. | 
|  | 48 | */ | 
|  | 49 | size_t mbedtls_x509_crt_parse_cn_inet_pton(const char *cn, void *dst); | 
|  | 50 |  | 
|  | 51 | #endif /* MBEDTLS_TEST_HOOKS */ | 
|  | 52 |  | 
|  | 53 | #endif /* MBEDTLS_X509_INVASIVE_H */ |