]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_cryptkit/lib/feeFEEDExp.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 * feeFEEDExp.h - generic FEED encryption object using 2:1 expansion
19 #ifndef _CK_FEEFEEDEXP_H_
20 #define _CK_FEEFEEDEXP_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 *feeFEEDExp
;
42 * Alloc and init a feeFEEDExp object associated with specified feePubKey.
44 feeFEEDExp
feeFEEDExpNewWithPubKey(
46 feeRandFcn randFcn
, // optional
49 void feeFEEDExpFree(feeFEEDExp feed
);
52 * Plaintext block size.
54 unsigned feeFEEDExpPlainBlockSize(feeFEEDExp feed
);
57 * Ciphertext block size used for decryption.
59 unsigned feeFEEDExpCipherBlockSize(feeFEEDExp feed
);
62 * Required size of buffer for ciphertext, upon encrypting one
65 unsigned feeFEEDExpCipherBufSize(feeFEEDExp feed
);
68 * Return the size of ciphertext to hold specified size of encrypted plaintext.
70 unsigned feeFEEDExpCipherTextSize(feeFEEDExp feed
, unsigned plainTextSize
);
73 * Return the size of plaintext to hold specified size of decrypted ciphertext.
75 unsigned feeFEEDExpPlainTextSize(feeFEEDExp feed
, unsigned cipherTextSize
);
78 * Encrypt a block or less of data. Caller malloc's cipherText. Generates
79 * feeFEEDExpCipherBlockSize() bytes of cipherText if finalBlock is false;
80 * if finalBlock is true it could produce twice as much ciphertext.
81 * If plainTextLen is less than feeFEEDExpPlainBlockSize(), finalBlock must be true.
83 feeReturn
feeFEEDExpEncryptBlock(feeFEEDExp feed
,
84 const unsigned char *plainText
,
85 unsigned plainTextLen
,
86 unsigned char *cipherText
,
87 unsigned *cipherTextLen
, // RETURNED
91 * Decrypt (exactly) a block of data. Caller malloc's plainText. Always
92 * generates feeFEEDExpBlockSize bytes of plainText, unless 'finalBlock' is
93 * non-zero (in which case feeFEEDExpBlockSize or less bytes of plainText are
96 feeReturn
feeFEEDExpDecryptBlock(feeFEEDExp feed
,
97 const unsigned char *cipherText
,
98 unsigned cipherTextLen
,
99 unsigned char *plainText
,
100 unsigned *plainTextLen
, // RETURNED
104 * Convenience routines to encrypt & decrypt multi-block data.
106 feeReturn
feeFEEDExpEncrypt(feeFEEDExp feed
,
107 const unsigned char *plainText
,
108 unsigned plainTextLen
,
109 unsigned char **cipherText
, // malloc'd and RETURNED
110 unsigned *cipherTextLen
); // RETURNED
112 feeReturn
feeFEEDExpDecrypt(feeFEEDExp feed
,
113 const unsigned char *cipherText
,
114 unsigned cipherTextLen
,
115 unsigned char **plainText
, // malloc'd and RETURNED
116 unsigned *plainTextLen
); // RETURNED
122 #endif /*_CK_FEEFEEDEXP_H_*/