📄 ipp_cipher_arc4.cpp
字号:
/*
//
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright (c) 2005 Intel Corporation. All Rights Reserved.
//
*/
#if defined(_IPP_v51_)
#include "ipp_cipher_arc4.h"
#include <string.h>
//////////////////////////////////////////////////
//
// cipher: ARCFour
//
RC4::RC4(const Ipp8u* pKey, int keyLen)
{
algoBlockSize = ARCFOUR_BLKLEN;
int ctxSize;
ippsARCFourGetSize(&ctxSize);
pCtx = (IppsARCFourState*)( new Ipp8u [ctxSize] );
ResetKey(pKey, keyLen);
}
void RC4::ResetKey(const Ipp8u* pKey, int keyLen)
{
if(keyLen > MAX_ARCFOUR_KEY_LEN)
keyLen = MAX_ARCFOUR_KEY_LEN;
ippsARCFourInit(pKey, keyLen, pCtx);
}
RC4::~RC4()
{
delete [] (Ipp8u*)pCtx;
}
int RC4::doCipher(Ipp8u* pDst, const Ipp8u* pSrc, int srcLen)
{
if(ECB!=mode)
return 0; // unsupported mode
status = ENCRYPT==operation?
ippsARCFourEncrypt(pSrc, pDst, srcLen, pCtx):
ippsARCFourDecrypt(pSrc, pDst, srcLen, pCtx);
return ippStsNoErr==status;
}
#endif // IPP_v51_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -