1/* 2 * Copyright (c) 2012 Apple Inc. All Rights Reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24#include "ccGlobals.h" 25#include "ccMemory.h" 26#include "ccdebug.h" 27#include "CommonCryptor.h" 28#include "CommonCryptorSPI.h" 29#include "CommonCryptorPriv.h" 30#include <corecrypto/ccrc4.h> 31 32typedef struct current_rc4_key_st 33{ 34 uint32_t x,y; 35 uint32_t data[256]; 36} RC4_KEY; 37 38#ifndef NDEBUG 39#define ASSERT(s) 40#else 41#define ASSERT(s) assert(s) 42#endif 43 44void CC_RC4_set_key(void *ctx, int len, const unsigned char *data) 45{ 46 CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); 47 ASSERT(sizeof(RC4_KEY) == ccrc4_eay.size); 48 ccrc4_eay.init(ctx, len, data); 49} 50 51void CC_RC4(void *ctx, unsigned long len, const unsigned char *indata, 52 unsigned char *outdata) 53{ 54 CC_DEBUG_LOG(ASL_LEVEL_ERR, "Entering\n"); 55 ccrc4_eay.crypt(ctx, len, indata, outdata); 56} 57