]>
git.saurik.com Git - apple/security.git/blob - AppleCSP/MiscCSPAlgs/bfContext.h
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 * bfContext.h - glue between BlockCrytpor and ssleay Blowfish
22 * Written by Doug Mitchell 4/23/2003
25 #ifndef _BF_CONTEXT_H_
26 #define _BF_CONTEXT_H_
28 #include "AppleCSPContext.h"
29 #include "BlockCryptor.h"
30 #include <CoreServices/../Frameworks/CarbonCore.framework/Headers/MacTypes.h>
31 #include <openssl/blowfish.h>
33 class BlowfishContext
: public BlockCryptor
{
35 BlowfishContext(AppleCSPSession
&session
) :
36 BlockCryptor(session
),
41 // called by CSPFullPluginSession
42 void init(const Context
&context
, bool encoding
= true);
44 // As an optimization, we allow reuse of a modified context.
45 // The main thing we avoid is a redundant key scheduling. We
46 // save the current raw keys bits in mRawKey and compare on
48 bool changed(const Context
&context
) { return true; }
50 // called by BlockCryptor
52 const void *plainText
, // length implied (one block)
55 size_t &cipherTextLen
, // in/out, throws on overflow
58 const void *cipherText
, // length implied (one cipher block)
60 size_t &plainTextLen
, // in/out, throws on overflow
68 bool mInitFlag
; // for easy reuse
71 * Raw key bits saved here and checked on re-init to avoid
74 uint8 mRawKey
[BF_MAX_KEY_SIZE_BYTES
];
78 }; /* BlowfishContext */
80 #endif //_BF_CONTEXT_H_