]>
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>
32 #if CRYPTKIT_ASYMMETRIC_ENABLE
39 * Opaque object handle.
41 typedef void *feeFEEDExp
;
44 * Alloc and init a feeFEEDExp object associated with specified feePubKey.
46 feeFEEDExp
feeFEEDExpNewWithPubKey(
48 feeRandFcn randFcn
, // optional
51 void feeFEEDExpFree(feeFEEDExp feed
);
54 * Plaintext block size.
56 unsigned feeFEEDExpPlainBlockSize(feeFEEDExp feed
);
59 * Ciphertext block size used for decryption.
61 unsigned feeFEEDExpCipherBlockSize(feeFEEDExp feed
);
64 * Required size of buffer for ciphertext, upon encrypting one
67 unsigned feeFEEDExpCipherBufSize(feeFEEDExp feed
);
70 * Return the size of ciphertext to hold specified size of encrypted plaintext.
72 unsigned feeFEEDExpCipherTextSize(feeFEEDExp feed
, unsigned plainTextSize
);
75 * Return the size of plaintext to hold specified size of decrypted ciphertext.
77 unsigned feeFEEDExpPlainTextSize(feeFEEDExp feed
, unsigned cipherTextSize
);
80 * Encrypt a block or less of data. Caller malloc's cipherText. Generates
81 * feeFEEDExpCipherBlockSize() bytes of cipherText if finalBlock is false;
82 * if finalBlock is true it could produce twice as much ciphertext.
83 * If plainTextLen is less than feeFEEDExpPlainBlockSize(), finalBlock must be true.
85 feeReturn
feeFEEDExpEncryptBlock(feeFEEDExp feed
,
86 const unsigned char *plainText
,
87 unsigned plainTextLen
,
88 unsigned char *cipherText
,
89 unsigned *cipherTextLen
, // RETURNED
93 * Decrypt (exactly) a block of data. Caller malloc's plainText. Always
94 * generates feeFEEDExpBlockSize bytes of plainText, unless 'finalBlock' is
95 * non-zero (in which case feeFEEDExpBlockSize or less bytes of plainText are
98 feeReturn
feeFEEDExpDecryptBlock(feeFEEDExp feed
,
99 const unsigned char *cipherText
,
100 unsigned cipherTextLen
,
101 unsigned char *plainText
,
102 unsigned *plainTextLen
, // RETURNED
106 * Convenience routines to encrypt & decrypt multi-block data.
108 feeReturn
feeFEEDExpEncrypt(feeFEEDExp feed
,
109 const unsigned char *plainText
,
110 unsigned plainTextLen
,
111 unsigned char **cipherText
, // malloc'd and RETURNED
112 unsigned *cipherTextLen
); // RETURNED
114 feeReturn
feeFEEDExpDecrypt(feeFEEDExp feed
,
115 const unsigned char *cipherText
,
116 unsigned cipherTextLen
,
117 unsigned char **plainText
, // malloc'd and RETURNED
118 unsigned *plainTextLen
); // RETURNED
124 #endif /* CRYPTKIT_ASYMMETRIC_ENABLE */
126 #endif /*_CK_FEEFEEDEXP_H_*/