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