]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_cryptkit/lib/feeECDSA.h
Security-59754.80.3.tar.gz
[apple/security.git] / OSX / libsecurity_cryptkit / lib / feeECDSA.h
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 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42
43 /*
44 * Sign specified block of data (most likely a hash result) using
45 * specified private key. Result, an enc64-encoded signature block,
46 * is returned in *sigData.
47 */
48 feeReturn feeECDSASign(feePubKey pubKey,
49 feeSigFormat format, // Format of the signature DER/RAW
50 const unsigned char *data, // data to be signed
51 unsigned dataLen, // in bytes
52 feeRandFcn randFcn, // optional
53 void *randRef, // optional
54 unsigned char **sigData, // malloc'd and RETURNED
55 unsigned *sigDataLen); // RETURNED
56
57 /*
58 * Verify signature, obtained via feeECDSASign, for specified
59 * data (most likely a hash result) and feePubKey. Returns FR_Success or
60 * FR_InvalidSignature.
61 */
62 feeReturn feeECDSAVerify(const unsigned char *sigData,
63 size_t sigDataLen,
64 const unsigned char *data,
65 unsigned dataLen,
66 feePubKey pubKey,
67 feeSigFormat format); // Format of the signature DER/RAW
68
69 /*
70 * For given key, calculate maximum signature size.
71 */
72 feeReturn feeECDSASigSize(
73 feePubKey pubKey,
74 unsigned *maxSigLen);
75
76 #ifdef __cplusplus
77 }
78 #endif
79
80 #endif /*_CK_FEEECDSA_H_*/