]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_cryptkit/lib/feeFEED.h
1 /* Copyright (c) 1998,2011,2014 Apple Inc. All Rights Reserved.
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 ***************************************************************************
11 * FeeFEED.h - generic, portable FEED encryption object
19 #ifndef _CK_FEEFEED_H_
20 #define _CK_FEEFEED_H_
22 #if !defined(__MACH__)
25 #include <feePublicKey.h>
27 #include <security_cryptkit/ckconfig.h>
28 #include <security_cryptkit/feeTypes.h>
29 #include <security_cryptkit/feePublicKey.h>
32 #if CRYPTKIT_ASYMMETRIC_ENABLE
39 * Opaque object handle.
41 typedef void *feeFEED
;
44 * forEncrypt argument values.
50 * Alloc and init a feeFEED object associated with specified feePubKey
53 feeFEED
feeFEEDNewWithPubKey(feePubKey myPrivKey
,
54 feePubKey theirPubKey
,
55 int forEncrypt
, // FF_DECRYPT, FF_ENCRYPT
56 feeRandFcn randFcn
, // optional
59 void feeFEEDFree(feeFEED feed
);
62 * Plaintext block size.
64 unsigned feeFEEDPlainBlockSize(feeFEED feed
);
67 * Ciphertext block size used for decryption.
69 unsigned feeFEEDCipherBlockSize(feeFEED feed
);
72 * Calculate size of buffer currently needed to encrypt one block of
75 unsigned feeFEEDCipherBufSize(feeFEED feed
,
79 * Return the size of ciphertext currently needed to encrypt specified
80 * size of plaintext. Also can be used to calculate size of ciphertext
81 * which can be decrypted into specified size of plaintext.
83 unsigned feeFEEDCipherTextSize(feeFEED feed
,
84 unsigned plainTextSize
,
88 * Return the size of plaintext currently needed to decrypt specified size
89 * of ciphertext. Also can be used to calculate size of plaintext
90 * which can be encrypted into specified size of ciphertext.
92 unsigned feeFEEDPlainTextSize(feeFEED feed
,
93 unsigned cipherTextSize
,
94 int finalBlock
); // ignored if decrypting
97 * Encrypt a block or less of data. Caller malloc's cipherText.
99 feeReturn
feeFEEDEncryptBlock(feeFEED feed
,
100 const unsigned char *plainText
,
101 unsigned plainTextLen
,
102 unsigned char *cipherText
,
103 unsigned *cipherTextLen
, // RETURNED
107 * Decrypt (exactly) a block of data. Caller malloc's plainText. Always
108 * generates feeFEEDBlockSize bytes of plainText, unless 'finalBlock' is
109 * non-zero (in which case feeFEEDBlockSize or less bytes of plainText are
112 feeReturn
feeFEEDDecryptBlock(feeFEED feed
,
113 const unsigned char *cipherText
,
114 unsigned cipherTextLen
,
115 unsigned char *plainText
,
116 unsigned *plainTextLen
, // RETURNED
120 * Convenience routines to encrypt & decrypt multi-block data.
122 feeReturn
feeFEEDEncrypt(feeFEED feed
,
123 const unsigned char *plainText
,
124 unsigned plainTextLen
,
125 unsigned char **cipherText
, // malloc'd and RETURNED
126 unsigned *cipherTextLen
); // RETURNED
128 feeReturn
feeFEEDDecrypt(feeFEED feed
,
129 const unsigned char *cipherText
,
130 unsigned cipherTextLen
,
131 unsigned char **plainText
, // malloc'd and RETURNED
132 unsigned *plainTextLen
); // RETURNED
138 #endif /* CRYPTKIT_ASYMMETRIC_ENABLE */
140 #endif /*_CK_FEEFEED_H_*/