1/* 2 * Copyright (c) 1998-2003,2010-2011 Apple Inc. All Rights Reserved. 3 * 4 * The contents of this file constitute Original Code as defined in and are 5 * subject to the Apple Public Source License Version 1.2 (the 'License'). 6 * You may not use this file except in compliance with the License. Please 7 * obtain a copy of the License at http://www.apple.com/publicsource and 8 * read it before using this file. 9 * 10 * This Original Code and all software distributed under the License are 11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 12 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 13 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 14 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 15 * Please see the License for the specific language governing rights and 16 * limitations under the License. 17 * 18 * cuEnc64.h - encode/decode in 64-char IA5 format, per RFC 1421 19 */ 20 21#ifndef _CU_ENC64_H_ 22#define _CU_ENC64_H_ 23 24#ifdef __cplusplus 25extern "C" { 26#endif 27 28/* 29 * Given input buffer inbuf, length inlen, decode from 64-char IA5 format to 30 * binary. Result is malloced and returned; its length is returned in *outlen. 31 * NULL return indicates corrupted input. 32 */ 33unsigned char *cuEnc64(const unsigned char *inbuf, 34 unsigned inlen, 35 unsigned *outlen); // RETURNED 36 37/* 38 * Enc64, with embedded newlines every lineLen in result. A newline is 39 * the UNIX \n. Result is mallocd. 40 */ 41unsigned char *cuEnc64WithLines(const unsigned char *inbuf, 42 unsigned inlen, 43 unsigned linelen, 44 unsigned *outlen); // RETURNED 45 46/* 47 * Given input buffer inbuf, length inlen, decode from 64-char IA5 format to 48 * binary. Result is malloced and returned; its length is returned in *outlen. 49 * NULL return indicates corrupted input. All whitespace in inbuf is 50 * ignored. 51 */ 52unsigned char *cuDec64(const unsigned char *inbuf, 53 unsigned inlen, 54 unsigned *outlen); 55 56/* 57 * Determine if specified input data is valid enc64 format. Returns 1 58 * if valid, 0 if not. 59 */ 60int cuIsValidEnc64(const unsigned char *inbuf, 61 unsigned inbufLen); 62 63/* 64 * Given input buffer containing a PEM-encoded certificate, convert to DER 65 * and return in outbuf. Result is malloced and must be freed by caller; 66 * its length is returned in *outlen. Returns 0 on success. 67 */ 68int cuConvertPem(const unsigned char *inbuf, 69 unsigned inlen, 70 unsigned char **outbuf, // RETURNED (caller must free) 71 unsigned *outlen); // RETURNED 72 73#ifdef __cplusplus 74} 75#endif 76 77#endif /*_CU_ENC64_H_*/ 78