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

📄 rvdesencryption.h

📁 h.248协议源码
💻 H
字号:
/************************************************************************
 File Name     : rvdesencryption.h
 Description   : This file contains the RvDesEncryption class for 
                 performing DES encryption and decryption on a buffer.
                 The code for this class was based on the code found in
                 "Applied Cryptology" by Bruce Schneier ISBN 0-471-11709-9.
                 Chapter 12 covers the DES algorithm is detail.
*************************************************************************
 Copyright (c)  2001 , RADVision, Inc. All rights reserved.
*************************************************************************
 NOTICE:
 This document contains information that is proprietary to RADVision Inc. 
 No part of this publication may be reproduced in any form whatsoever
 without written prior approval by RADVision Inc. 
 
 RADVision Inc. reserves the right to revise this publication and make
 changes without obligation to notify any person of such revisions or
 changes.
*************************************************************************
 $Revision: $
 $Date:   03/13/2001 $
 $Author: Scott K. Eaton $
************************************************************************/

#if !defined(RVDESENCRYPTION_H)
#define RVDESENCRYPTION_H

#include "rvtypes.h"
#include "rvalloc.h"

#ifdef __cplusplus
extern "C" {
#endif


/* Encryption direction */
#define RV_DESENCRYPTION_DIRECTION_ENCRYPT ((RvUint8)0) /* Encrypt buffer */
#define RV_DESENCRYPTION_DIRECTION_DECRYPT ((RvUint8)1)  /* Decrypt buffer */

/*$
{type scope="protected":
	{name: RvDesEncryption}
	{superpackage: Security}	
	{include: rvdesencryption.h}
    {description:	
		{p: This class is used for encrypting and decrypting buffers
            using the DES algorithm. It supports ECB and CBC modes of
            encryption. Only buffers that are multiples of the block
            size (64-bits) are allowed.}
	}
	{methods scope="private":
		{method: void rvDesEncryptionFunction(const RvUint8 *input, RvUint8 *output, RvUint32 length, RvUint8  mode,
                                              RvUint32 prevBlock[2], const RvUint32 keys[32], RvBool encrypt);}
		{method: void rvDesEncryptionGenerateKeySet(const RvUint8 *key, RvUint32 keys[32], RvBool encrypt);}
		{method: void rvDesEncryptionCookKeys( const RvUint32 keys[32], RvUint32 cookedKeys[32]);}
		{method: void rvDesEncryptionScrunch(const RvUint8 outof[8], RvUint32 into[2]);}
		{method: void rvDesEncryptionUnscrunch(const RvUint32 outof[2], RvUint8 into[8]);}
    }
	{methods:
		{method: RvDesEncryption* rvDesEncryptionConstruct(RvDesEncryption* thisPtr);}
		{method: void rvDesEncryptionDestruct(RvDesEncryption* thisPtr);}
		{method: void rvDesEncryptionInitializeECBMode(RvDesEncryption* thisPtr, RvUint8 direction, const RvUint8 key[7]);}
		{method: void rvDesEncryptionInitializeCBCMode(RvDesEncryption* thisPtr, RvUint8 direction, const RvUint8 key[7], const RvUint8 iv[8]);}
		{method: void rvDesEncryptionProcess(RvDesEncryption* thisPtr, const RvUint8* input, RvUint8* output, RvUint32 length);}
		{method: void rvDesEncryptionReset(RvDesEncryption* thisPtr);}
    }
}
$*/
typedef struct
{
    RvUint32 iv[2];         /* Initialization Vector      */
    RvUint32 prevBlock[2];  /* Previously processed block */
    RvUint8  mode;          /* Encryption mode            */
    RvUint32 keySet[32];    /* Preprocessed keys          */
    RvUint8  key[8];        /* Key                        */
    RvBool   encrypt;       /* rvTrue, if encrypting data, otherwise decrypting data */

} RvDesEncryption;

/* Construct/Destruct Methods */
RvDesEncryption *rvDesEncryptionConstruct(RvDesEncryption *thisPtr);
void   rvDesEncryptionDestruct(RvDesEncryption *thisPtr);

/* Encryption/Decryption Methods */
void rvDesEncryptionInitializeECBMode(RvDesEncryption *thisPtr, 
                                      RvUint8 direction,
                                      const RvUint8 key[7]);
void rvDesEncryptionInitializeCBCMode(RvDesEncryption *thisPtr, 
                                      RvUint8 direction,
                                      const RvUint8 key[7],
                                      const RvUint8 iv[8]);
void rvDesEncryptionProcess(RvDesEncryption *thisPtr, const RvUint8 *input, 
                            RvUint8 *output, RvUint32 length);
void rvDesEncryptionReset(RvDesEncryption *thisPtr);


#ifdef __cplusplus
}
#endif

#endif  /* Include guard */

⌨️ 快捷键说明

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