1*2c2f96dcSApple OSS Distributions /* Copyright (c) (2012,2014-2019,2021,2022) Apple Inc. All rights reserved. 2*2c2f96dcSApple OSS Distributions * 3*2c2f96dcSApple OSS Distributions * corecrypto is licensed under Apple Inc.’s Internal Use License Agreement (which 4*2c2f96dcSApple OSS Distributions * is contained in the License.txt file distributed with corecrypto) and only to 5*2c2f96dcSApple OSS Distributions * people who accept that license. IMPORTANT: Any license rights granted to you by 6*2c2f96dcSApple OSS Distributions * Apple Inc. (if any) are limited to internal use within your organization only on 7*2c2f96dcSApple OSS Distributions * devices and computers you own or control, for the sole purpose of verifying the 8*2c2f96dcSApple OSS Distributions * security characteristics and correct functioning of the Apple Software. You may 9*2c2f96dcSApple OSS Distributions * not, directly or indirectly, redistribute the Apple Software or any portions thereof. 10*2c2f96dcSApple OSS Distributions * 11*2c2f96dcSApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 12*2c2f96dcSApple OSS Distributions * 13*2c2f96dcSApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code 14*2c2f96dcSApple OSS Distributions * as defined in and that are subject to the Apple Public Source License 15*2c2f96dcSApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in 16*2c2f96dcSApple OSS Distributions * compliance with the License. The rights granted to you under the License 17*2c2f96dcSApple OSS Distributions * may not be used to create, or enable the creation or redistribution of, 18*2c2f96dcSApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to 19*2c2f96dcSApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any 20*2c2f96dcSApple OSS Distributions * terms of an Apple operating system software license agreement. 21*2c2f96dcSApple OSS Distributions * 22*2c2f96dcSApple OSS Distributions * Please obtain a copy of the License at 23*2c2f96dcSApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file. 24*2c2f96dcSApple OSS Distributions * 25*2c2f96dcSApple OSS Distributions * The Original Code and all software distributed under the License are 26*2c2f96dcSApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 27*2c2f96dcSApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 28*2c2f96dcSApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 29*2c2f96dcSApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 30*2c2f96dcSApple OSS Distributions * Please see the License for the specific language governing rights and 31*2c2f96dcSApple OSS Distributions * limitations under the License. 32*2c2f96dcSApple OSS Distributions * 33*2c2f96dcSApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 34*2c2f96dcSApple OSS Distributions */ 35*2c2f96dcSApple OSS Distributions 36*2c2f96dcSApple OSS Distributions //debug configuration header file 37*2c2f96dcSApple OSS Distributions #ifndef _CORECRYPTO_CCN_DEBUG_H_ 38*2c2f96dcSApple OSS Distributions #define _CORECRYPTO_CCN_DEBUG_H_ 39*2c2f96dcSApple OSS Distributions 40*2c2f96dcSApple OSS Distributions #include <corecrypto/cc_config.h> 41*2c2f96dcSApple OSS Distributions 42*2c2f96dcSApple OSS Distributions // DO NOT INCLUDE this HEADER file in CoreCrypto files added for XNU project or headers 43*2c2f96dcSApple OSS Distributions // included by external clients. 44*2c2f96dcSApple OSS Distributions 45*2c2f96dcSApple OSS Distributions // ======================== 46*2c2f96dcSApple OSS Distributions // Printf for corecrypto 47*2c2f96dcSApple OSS Distributions // ======================== 48*2c2f96dcSApple OSS Distributions #if CC_KERNEL 49*2c2f96dcSApple OSS Distributions #include <pexpert/pexpert.h> 50*2c2f96dcSApple OSS Distributions #define cc_printf(x...) kprintf(x) 51*2c2f96dcSApple OSS Distributions #if !CONFIG_EMBEDDED 52*2c2f96dcSApple OSS Distributions extern int printf(const char *format, ...) __cc_printflike(1, 2); 53*2c2f96dcSApple OSS Distributions #endif 54*2c2f96dcSApple OSS Distributions #elif CC_IBOOT || CC_RTKIT || CC_RTKITROM 55*2c2f96dcSApple OSS Distributions #include <stdio.h> 56*2c2f96dcSApple OSS Distributions #define cc_printf(x...) printf(x) 57*2c2f96dcSApple OSS Distributions #elif CC_SGX || CC_EFI 58*2c2f96dcSApple OSS Distributions #define cc_printf(x...) 59*2c2f96dcSApple OSS Distributions #elif CC_TXM 60*2c2f96dcSApple OSS Distributions #define cc_printf(x...) 61*2c2f96dcSApple OSS Distributions #elif CC_SPTM 62*2c2f96dcSApple OSS Distributions #define cc_printf(x...) 63*2c2f96dcSApple OSS Distributions #else 64*2c2f96dcSApple OSS Distributions #include <stdio.h> 65*2c2f96dcSApple OSS Distributions #define cc_printf(x...) fprintf(stderr, x) 66*2c2f96dcSApple OSS Distributions #endif 67*2c2f96dcSApple OSS Distributions 68*2c2f96dcSApple OSS Distributions // ======================== 69*2c2f96dcSApple OSS Distributions // Integer types 70*2c2f96dcSApple OSS Distributions // ======================== 71*2c2f96dcSApple OSS Distributions 72*2c2f96dcSApple OSS Distributions #if CC_KERNEL 73*2c2f96dcSApple OSS Distributions /* Those are not defined in libkern */ 74*2c2f96dcSApple OSS Distributions #define PRIx64 "llx" 75*2c2f96dcSApple OSS Distributions #define PRIx32 "x" 76*2c2f96dcSApple OSS Distributions #define PRIx16 "hx" 77*2c2f96dcSApple OSS Distributions #define PRIx8 "hhx" 78*2c2f96dcSApple OSS Distributions #else 79*2c2f96dcSApple OSS Distributions #include <inttypes.h> 80*2c2f96dcSApple OSS Distributions #endif 81*2c2f96dcSApple OSS Distributions 82*2c2f96dcSApple OSS Distributions #if CCN_UNIT_SIZE == 8 83*2c2f96dcSApple OSS Distributions #define CCPRIx_UNIT ".016" PRIx64 84*2c2f96dcSApple OSS Distributions #elif CCN_UNIT_SIZE == 4 85*2c2f96dcSApple OSS Distributions #define CCPRIx_UNIT ".08" PRIx32 86*2c2f96dcSApple OSS Distributions #else 87*2c2f96dcSApple OSS Distributions #error invalid CCN_UNIT_SIZE 88*2c2f96dcSApple OSS Distributions #endif 89*2c2f96dcSApple OSS Distributions 90*2c2f96dcSApple OSS Distributions // ======================== 91*2c2f96dcSApple OSS Distributions // Print utilities for corecrypto 92*2c2f96dcSApple OSS Distributions // ======================== 93*2c2f96dcSApple OSS Distributions 94*2c2f96dcSApple OSS Distributions #include <corecrypto/cc.h> 95*2c2f96dcSApple OSS Distributions 96*2c2f96dcSApple OSS Distributions /* Print a byte array of arbitrary size */ 97*2c2f96dcSApple OSS Distributions void cc_print(const char *label, size_t count, const uint8_t *s); 98*2c2f96dcSApple OSS Distributions 99*2c2f96dcSApple OSS Distributions #endif /* _CORECRYPTO_CCN_DEBUG_H_ */ 100