3way.h

来自「一个DES,RSA,MD5,RC4等加密算法的源码」· C头文件 代码 · 共 53 行

H
53
字号
#ifndef CRYPTOPP_THREEWAY_H
#define CRYPTOPP_THREEWAY_H

/** \file
*/

#include "cryptlib.h"
#include "misc.h"

NAMESPACE_BEGIN(CryptoPP)

/// <a href="http://www.weidai.com/scan-mirror/cs.html#3-Way">3-Way</a>
class ThreeWayEncryption : public FixedBlockSize<12>, public FixedKeyLength<12>
{
public:
	enum {DEFAULT_ROUNDS=11};

	ThreeWayEncryption(const byte *userKey, unsigned int = 0, unsigned int rounds=DEFAULT_ROUNDS);
	~ThreeWayEncryption();

	void ProcessBlock(const byte *inBlock, byte * outBlock) const;
	void ProcessBlock(byte * inoutBlock) const
		{ThreeWayEncryption::ProcessBlock(inoutBlock, inoutBlock);}

private:
	word32 k[3];
	unsigned int rounds;
	SecBlock<word32> rc;
};

/// <a href="http://www.weidai.com/scan-mirror/cs.html#3-Way">3-Way</a>
class ThreeWayDecryption : public FixedBlockSize<12>, public FixedKeyLength<12>
{
public:
	enum {DEFAULT_ROUNDS=11};

	ThreeWayDecryption(const byte *userKey, unsigned int = 0, unsigned int rounds=DEFAULT_ROUNDS);
	~ThreeWayDecryption();

	void ProcessBlock(const byte *inBlock, byte * outBlock) const;
	void ProcessBlock(byte * inoutBlock) const
		{ThreeWayDecryption::ProcessBlock(inoutBlock, inoutBlock);}

private:
	word32 k[3];
	unsigned int rounds;
	SecBlock<word32> rc;
};

NAMESPACE_END

#endif

⌨️ 快捷键说明

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