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 * feeDigitalSignature.h - generic, portable FEE Digital Signature object 12 * 13 * Revision History 14 * ---------------- 15 * 22 Aug 96 at NeXT 16 * Created. 17 */ 18 19#ifndef _CK_FEEDIGITALSIG_H_ 20#define _CK_FEEDIGITALSIG_H_ 21 22#if !defined(__MACH__) 23#include <feeTypes.h> 24#include <feePublicKey.h> 25#else 26#include <security_cryptkit/feeTypes.h> 27#include <security_cryptkit/feePublicKey.h> 28#endif 29 30#ifdef __cplusplus 31extern "C" { 32#endif 33 34#define FEE_SIG_MAGIC 0xfee00516 35 36/* 37 * Opaque signature handle. 38 */ 39typedef void *feeSig; 40 41/* 42 * Create new feeSig object, including a random large integer 'Pm' for 43 * possible use in salting a feeHash object. 44 */ 45feeSig feeSigNewWithKey( 46 feePubKey pubKey, 47 feeRandFcn randFcn, /* optional */ 48 void *randRef); /* optional */ 49 50void feeSigFree( 51 feeSig sig); 52 53/* 54 * Obtain a malloc'd Pm after or feeSigNewWithKey() feeSigParse() 55 */ 56unsigned char *feeSigPm( 57 feeSig sig, 58 unsigned *PmLen); /* RETURNED */ 59 60/* 61 * Sign specified block of data (most likely a hash result) using 62 * specified feePubKey. 63 */ 64feeReturn feeSigSign( 65 feeSig sig, 66 const unsigned char *data, // data to be signed 67 unsigned dataLen, // in bytes 68 feePubKey pubKey); 69 70/* 71 * Given a feeSig processed by feeSigSign, obtain a malloc'd byte 72 * array representing the signature. 73 */ 74feeReturn feeSigData( 75 feeSig sig, 76 unsigned char **sigData, // malloc'd and RETURNED 77 unsigned *sigDataLen); // RETURNED 78 79/* 80 * Obtain a feeSig object by parsing an existing signature block. 81 * Note that if Pm is used to salt a hash of the signed data, this must 82 * be performed prior to hashing. 83 */ 84feeReturn feeSigParse( 85 const unsigned char *sigData, 86 size_t sigDataLen, 87 feeSig *sig); // RETURNED 88 89/* 90 * Verify signature, obtained via feeSigParse, for specified 91 * data (most likely a hash result) and feePubKey. Returns FR_Success or 92 * FR_InvalidSignature. 93 */ 94feeReturn feeSigVerify( 95 feeSig sig, 96 const unsigned char *data, 97 unsigned dataLen, 98 feePubKey pubKey); 99 100/* 101 * For given key, calculate maximum signature size. 102 */ 103feeReturn feeSigSize( 104 feePubKey pubKey, 105 unsigned *maxSigLen); 106 107#ifdef __cplusplus 108} 109#endif 110 111#endif /*_CK_FEEDIGITALSIG_H_*/ 112