]>
git.saurik.com Git - apple/security.git/blob - Security/libsecurity_apple_csp/lib/bfContext.h
2 * Copyright (c) 2000-2001,2011,2013-2014 Apple 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
24 #ifndef _BF_CONTEXT_H_
25 #define _BF_CONTEXT_H_
27 #include "AppleCSPContext.h"
28 #include "BlockCryptor.h"
29 #include <openssl/blowfish.h>
31 class BlowfishContext
: public BlockCryptor
{
33 BlowfishContext(AppleCSPSession
&session
) :
34 BlockCryptor(session
),
39 // called by CSPFullPluginSession
40 void init(const Context
&context
, bool encoding
= true);
42 // As an optimization, we allow reuse of a modified context.
43 // The main thing we avoid is a redundant key scheduling. We
44 // save the current raw keys bits in mRawKey and compare on
46 bool changed(const Context
&context
) { return true; }
48 // called by BlockCryptor
50 const void *plainText
, // length implied (one block)
53 size_t &cipherTextLen
, // in/out, throws on overflow
56 const void *cipherText
, // length implied (one cipher block)
59 size_t &plainTextLen
, // in/out, throws on overflow
67 bool mInitFlag
; // for easy reuse
70 * Raw key bits saved here and checked on re-init to avoid
73 uint8 mRawKey
[BF_MAX_KEY_SIZE_BYTES
];
77 }; /* BlowfishContext */
79 #endif //_BF_CONTEXT_H_