⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rc4.c

📁 VIA VT6656 USB linux source code.
💻 C
字号:
/* * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * * This software is copyrighted by and is the sole property of * VIA Networking Technologies, Inc. This software may only be used * in accordance with the corresponding license agreement. Any unauthorized * use, duplication, transmission, distribution, or disclosure of this * software is expressly forbidden. * * This software is provided by VIA Networking Technologies, Inc. "as is" * and any express or implied warranties, including, but not limited to, the * implied warranties of merchantability and fitness for a particular purpose * are disclaimed. In no event shall VIA Networking Technologies, Inc. * be liable for any direct, indirect, incidental, special, exemplary, or * consequential damages. * * File: rc4.c * * Purpose: * * Functions:  * * Revision History: * * Author: Kyle Hsu * * Date: Sep 4, 2002 * */ #if !defined(__RC4_H__)#include "rc4.h"#endifVOID rc4_init(PRC4Ext pRC4, PBYTE pbyKey, UINT cbKey_len){    UINT  ust1, ust2;    UINT  keyindex;    UINT  stateindex;    PBYTE pbyst;    UINT  idx;        pbyst = pRC4->abystate;    pRC4->ux = 0;    pRC4->uy = 0;    for (idx = 0; idx < 256; idx++)        pbyst[idx] = (BYTE)idx;    keyindex = 0;    stateindex = 0;    for (idx = 0; idx < 256; idx++) {        ust1 = pbyst[idx];        stateindex = (stateindex + pbyKey[keyindex] + ust1) & 0xff;        ust2 = pbyst[stateindex];        pbyst[stateindex] = (BYTE)ust1;        pbyst[idx] = (BYTE)ust2;        if (++keyindex >= cbKey_len)            keyindex = 0;    }}UINT rc4_byte(PRC4Ext pRC4){    UINT ux;    UINT uy;    UINT ustx, usty;    PBYTE pbyst;        pbyst = pRC4->abystate;    ux = (pRC4->ux + 1) & 0xff;    ustx = pbyst[ux];    uy = (ustx + pRC4->uy) & 0xff;    usty = pbyst[uy];    pRC4->ux = ux;    pRC4->uy = uy;    pbyst[uy] = (BYTE)ustx;    pbyst[ux] = (BYTE)usty;        return pbyst[(ustx + usty) & 0xff];}VOID rc4_encrypt(PRC4Ext pRC4, PBYTE pbyDest,                     PBYTE pbySrc, UINT cbData_len){    UINT ii;    for (ii = 0; ii < cbData_len; ii++)        pbyDest[ii] = (BYTE)(pbySrc[ii] ^ rc4_byte(pRC4));}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -