]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_cdsa_utils/lib/cuEnc64.h
Security-59754.80.3.tar.gz
[apple/security.git] / OSX / libsecurity_cdsa_utils / lib / cuEnc64.h
1 /*
2 * Copyright (c) 1998-2003,2011,2014 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
25 extern "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 */
33 unsigned 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 */
41 unsigned 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 */
52 unsigned 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 */
60 int cuIsValidEnc64(const unsigned char *inbuf,
61 unsigned inbufLen);
62
63 #ifdef __cplusplus
64 }
65 #endif
66
67 #endif /*_CU_ENC64_H_*/