1/* Copyright (c) 1998,2011,2014 Apple Inc.  All Rights Reserved.
2 *
3 * NOTICE: USE OF THE MATERIALS ACCOMPANYING THIS NOTICE IS SUBJECT
4 * TO THE TERMS OF THE SIGNED "FAST ELLIPTIC ENCRYPTION (FEE) REFERENCE
5 * SOURCE CODE EVALUATION AGREEMENT" BETWEEN APPLE, INC. AND THE
6 * ORIGINAL LICENSEE THAT OBTAINED THESE MATERIALS FROM APPLE,
7 * INC.  ANY USE OF THESE MATERIALS NOT PERMITTED BY SUCH AGREEMENT WILL
8 * EXPOSE YOU TO LIABILITY.
9 ***************************************************************************
10 *
11 * enc64.h - encode/decode in 64-char IA5 format, per RFC 1421
12 *
13 * Revision History
14 * ----------------
15 *  9 Oct 96 at NeXT
16 *	Created.
17 */
18
19#ifndef	_CK_ENC64_H_
20#define _CK_ENC64_H_
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26/*
27 * Given input buffer inbuf, length inlen, decode from 64-char IA5 format to
28 * binary. Result is fmalloced and returned; its length is returned in *outlen.
29 * NULL return indicates corrupted input.
30 */
31unsigned char *enc64(const unsigned char *inbuf,
32	unsigned inlen,
33	unsigned *outlen);		// RETURNED
34
35/*
36 * Enc64, with embedded newlines every lineLen in result. A newline is
37 * the Microsoft-style "\r\n".
38 */
39unsigned char *enc64WithLines(const unsigned char *inbuf,
40	unsigned inlen,
41	unsigned linelen,
42	unsigned *outlen);		// RETURNED
43
44/*
45 * Given input buffer inbuf, length inlen, decode from 64-char IA5 format to
46 * binary. Result is fmalloced and returned; its length is returned in *outlen.
47 * NULL return indicates corrupted input. All whitespace in inbuf is
48 * ignored.
49 */
50unsigned char *dec64(const unsigned char *inbuf,
51	unsigned inlen,
52	unsigned *outlen);
53
54/*
55 * Determine if specified input data is valid enc64 format. Returns 1
56 * if valid, 0 if not.
57 */
58int isValidEnc64(const unsigned char *inbuf,
59	unsigned inbufLen);
60
61#ifdef __cplusplus
62}
63#endif
64
65#endif	/*_CK_ENC64_H_*/
66