]>
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>
37 * Opaque object handle.
39 typedef void *feeFEED
;
42 * forEncrypt argument values.
48 * Alloc and init a feeFEED object associated with specified feePubKey
51 feeFEED
feeFEEDNewWithPubKey(feePubKey myPrivKey
,
52 feePubKey theirPubKey
,
53 int forEncrypt
, // FF_DECRYPT, FF_ENCRYPT
54 feeRandFcn randFcn
, // optional
57 void feeFEEDFree(feeFEED feed
);
60 * Plaintext block size.
62 unsigned feeFEEDPlainBlockSize(feeFEED feed
);
65 * Ciphertext block size used for decryption.
67 unsigned feeFEEDCipherBlockSize(feeFEED feed
);
70 * Calculate size of buffer currently needed to encrypt one block of
73 unsigned feeFEEDCipherBufSize(feeFEED feed
,
77 * Return the size of ciphertext currently needed to encrypt specified
78 * size of plaintext. Also can be used to calculate size of ciphertext
79 * which can be decrypted into specified size of plaintext.
81 unsigned feeFEEDCipherTextSize(feeFEED feed
,
82 unsigned plainTextSize
,
86 * Return the size of plaintext currently needed to decrypt specified size
87 * of ciphertext. Also can be used to calculate size of plaintext
88 * which can be encrypted into specified size of ciphertext.
90 unsigned feeFEEDPlainTextSize(feeFEED feed
,
91 unsigned cipherTextSize
,
92 int finalBlock
); // ignored if decrypting
95 * Encrypt a block or less of data. Caller malloc's cipherText.
97 feeReturn
feeFEEDEncryptBlock(feeFEED feed
,
98 const unsigned char *plainText
,
99 unsigned plainTextLen
,
100 unsigned char *cipherText
,
101 unsigned *cipherTextLen
, // RETURNED
105 * Decrypt (exactly) a block of data. Caller malloc's plainText. Always
106 * generates feeFEEDBlockSize bytes of plainText, unless 'finalBlock' is
107 * non-zero (in which case feeFEEDBlockSize or less bytes of plainText are
110 feeReturn
feeFEEDDecryptBlock(feeFEED feed
,
111 const unsigned char *cipherText
,
112 unsigned cipherTextLen
,
113 unsigned char *plainText
,
114 unsigned *plainTextLen
, // RETURNED
118 * Convenience routines to encrypt & decrypt multi-block data.
120 feeReturn
feeFEEDEncrypt(feeFEED feed
,
121 const unsigned char *plainText
,
122 unsigned plainTextLen
,
123 unsigned char **cipherText
, // malloc'd and RETURNED
124 unsigned *cipherTextLen
); // RETURNED
126 feeReturn
feeFEEDDecrypt(feeFEED feed
,
127 const unsigned char *cipherText
,
128 unsigned cipherTextLen
,
129 unsigned char **plainText
, // malloc'd and RETURNED
130 unsigned *plainTextLen
); // RETURNED
136 #endif /*_CK_FEEFEED_H_*/