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 * feeECDSA.h - Elliptic Curve Digital Signature Algorithm (per IEEE 1363)
12 *
13 * Revision History
14 * ----------------
15 * 16 Jul 97 at Apple
16 *	Created.
17 */
18
19#ifndef	_CK_FEEECDSA_H_
20#define _CK_FEEECDSA_H_
21
22#if	!defined(__MACH__)
23#include <ckconfig.h>
24#include <feeTypes.h>
25#include <feePublicKey.h>
26#else
27#include <security_cryptkit/ckconfig.h>
28#include <security_cryptkit/feeTypes.h>
29#include <security_cryptkit/feePublicKey.h>
30#endif
31
32/*
33 * Keep this one defined and visible even if we can't actually do ECDSA - feeSigParse()
34 * uses it to detect "wriong signature type".
35 */
36#define FEE_ECDSA_MAGIC		0xfee00517
37
38#if	CRYPTKIT_ECDSA_ENABLE
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44
45/*
46 * Sign specified block of data (most likely a hash result) using
47 * specified private key. Result, an enc64-encoded signature block,
48 * is returned in *sigData.
49 */
50feeReturn feeECDSASign(feePubKey pubKey,
51	const unsigned char *data,   	// data to be signed
52	unsigned dataLen,				// in bytes
53	feeRandFcn randFcn,				// optional
54	void *randRef,					// optional
55	unsigned char **sigData,		// malloc'd and RETURNED
56	unsigned *sigDataLen);			// RETURNED
57
58/*
59 * Verify signature, obtained via feeECDSASign, for specified
60 * data (most likely a hash result) and feePubKey. Returns FR_Success or
61 * FR_InvalidSignature.
62 */
63feeReturn feeECDSAVerify(const unsigned char *sigData,
64	size_t sigDataLen,
65	const unsigned char *data,
66	unsigned dataLen,
67	feePubKey pubKey);
68
69/*
70 * For given key, calculate maximum signature size.
71 */
72feeReturn feeECDSASigSize(
73	feePubKey pubKey,
74	unsigned *maxSigLen);
75
76#ifdef __cplusplus
77}
78#endif
79
80#endif	/* CRYPTKIT_ECDSA_ENABLE */
81
82#endif	/*_CK_FEEECDSA_H_*/
83