]>
git.saurik.com Git - apple/security.git/blob - Security/libsecurity_cryptkit/lib/feeDES.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 * FeeDES.h - generic, portable DES encryption object
22 #if !defined(__MACH__)
26 #include <security_cryptkit/ckconfig.h>
27 #include <security_cryptkit/feeTypes.h>
30 #if CRYPTKIT_SYMMETRIC_ENABLE
36 #define FEE_DES_MIN_STATE_SIZE 8
39 * Opaque object handle.
44 * Alloc and init a feeDES object with specified initial state.
45 * State must be at least 8 bytes; only 8 bytes are used, ignoring
48 feeDES
feeDESNewWithState(const unsigned char *state
,
51 void feeDESFree(feeDES des
);
54 * Set new initial state.
56 feeReturn
feeDESSetState(feeDES des
,
57 const unsigned char *state
,
61 * Set block or chain (CBC) mode. CBC is default.
63 void feeDESSetBlockMode(feeDES des
);
64 void feeDESSetChainMode(feeDES des
);
67 * Plaintext block size.
69 unsigned feeDESPlainBlockSize(feeDES des
);
72 * Ciphertext block size used for decryption.
74 unsigned feeDESCipherBlockSize(feeDES des
);
77 * Required size of buffer for ciphertext, upon encrypting one
80 unsigned feeDESCipherBufSize(feeDES des
);
84 * Return the size of ciphertext to hold specified size of plaintext.
88 unsigned feeDESCipherTextSize(feeDES des
, unsigned plainTextSize
);
94 unsigned feeDESKeySize(feeDES des
);
97 * Encrypt a block or less of data. Caller malloc's cipherText. Generates
98 * up to (2 * feeDESBlockSize) bytes of cipherText. If plainTextLen is
99 * less than feeDESBlockSize, finalBlock must be true.
101 feeReturn
feeDESEncryptBlock(feeDES des
,
102 const unsigned char *plainText
,
103 unsigned plainTextLen
,
104 unsigned char *cipherText
,
105 unsigned *cipherTextLen
, // RETURNED
109 * Decrypt (exactly) a block of data. Caller malloc's plainText. Always
110 * generates feeDESBlockSize bytes of plainText, unless 'finalBlock' is
111 * non-zero (in which case feeDESBlockSize or less bytes of plainText are
114 feeReturn
feeDESDecryptBlock(feeDES des
,
115 const unsigned char *cipherText
,
116 unsigned cipherTextLen
,
117 unsigned char *plainText
,
118 unsigned *plainTextLen
, // RETURNED
122 * Convenience routines to encrypt & decrypt multi-block data.
124 feeReturn
feeDESEncrypt(feeDES des
,
125 const unsigned char *plainText
,
126 unsigned plainTextLen
,
127 unsigned char **cipherText
, // malloc'd and RETURNED
128 unsigned *cipherTextLen
); // RETURNED
130 feeReturn
feeDESDecrypt(feeDES des
,
131 const unsigned char *cipherText
,
132 unsigned cipherTextLen
,
133 unsigned char **plainText
, // malloc'd and RETURNED
134 unsigned *plainTextLen
); // RETURNED
140 #endif /* CRYPTKIT_SYMMETRIC_ENABLE */
141 #endif /*_CK_FEEDES_H_*/