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