1/*
2 * ascContext.h - glue between BlockCrytpor and ComCryption (a.k.a. Apple
3 *				  Secure Compression).
4 * Written by Doug Mitchell 4/4/2001
5 */
6
7#ifdef	ASC_CSP_ENABLE
8
9#ifndef _ASC_CONTEXT_H_
10#define _ASC_CONTEXT_H_
11
12#include "AppleCSPContext.h"
13#include <security_comcryption/comcryption.h>
14
15/* symmetric encrypt/decrypt context */
16class ASCContext : public AppleCSPContext {
17public:
18	ASCContext(AppleCSPSession &session) :
19		AppleCSPContext(session),
20		mCcObj(NULL)	{ }
21	~ASCContext();
22
23	// called by CSPFullPluginSession
24	void init(
25		const Context 	&context,
26		bool encoding = true);
27	void update(
28		void 			*inp,
29		size_t 			&inSize, 			// in/out
30		void 			*outp,
31		size_t 			&outSize);			// in/out
32	void final(
33		CssmData 		&out);
34
35 	size_t inputSize(
36		size_t 			outSize);			// input for given output size
37	size_t outputSize(
38		bool 			final = false,
39		size_t 			inSize = 0); 		// output for given input size
40	void minimumProgress(
41		size_t 			&in,
42		size_t 			&out); 				// minimum progress chunks
43
44private:
45	comcryptObj			mCcObj;
46
47	/*
48	 * For first implementation, we have to cope with the fact that the final
49	 * decrypt call down to the comcryption engine requires *some* ciphertext.
50	 * On decrypt, we'll just save one byte on each update in preparation for
51	 * the final call. Hopefull we'll have time to fix deComcryptData() so this
52	 * is unneccesary.
53	 */
54	unsigned char		mDecryptBuf;
55	bool				mDecryptBufValid;
56
57};	/* RC4Context */
58
59#endif 	/*_ASC_CONTEXT_H_ */
60#endif	/* ASC_CSP_ENABLE */
61