📄 rsa.h
字号:
// RSA.h: interface for the CRSA class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_RSA_H__8A78E737_548F_40E7_8064_24A6FDEA188F__INCLUDED_)
#define AFX_RSA_H__8A78E737_548F_40E7_8064_24A6FDEA188F__INCLUDED_
//////////////////////////////////////////////////////////////////////
// m--message; c--cryptgraph; p,q--large prime; n=p*q; f=(p-1)*(q-1)
// given e=65537 select d ensure that e*d%f=1 ==>e*d=x*f+1
//
// send: encrypt M using e, and get c=pow(m,e)%n;
// recieve: decrypt C using d,
// text=pow(c,d)%n=pow(m,e*d)%n=pow(m,x*f+1)%n=pow(m,1)%n=m
//////////////////////////////////////////////////////////////////////
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Huge.h"
//////////////////////////////////////////////////////////////////////
// typedef / constant
//////////////////////////////////////////////////////////////////////
const unsigned RSA_BLOCK_BYTE_SIZE = 15;
const unsigned RSA_BLOCK_BIT_SIZE = RSA_BLOCK_BYTE_SIZE<<3;
typedef BYTE RSA_BLOCK[RSA_BLOCK_BYTE_SIZE+1];
//////////////////////////////////////////////////////////////////////
// Class CRSA
//////////////////////////////////////////////////////////////////////
class CRSA
{
public:
CRSA();
virtual ~CRSA();
void Encrypt( RSA_BLOCK b );
void Decrypt( RSA_BLOCK b );
private:
CHuge m_cP, m_cQ;
CHuge m_cE, m_cD;
CHuge m_cN, m_cFN;
private:
void TransRSABlockToHuge( CHuge& n, RSA_BLOCK b );
void TransHugeToRSABlock( CHuge n, RSA_BLOCK b );
};
#endif // !defined(AFX_RSA_H__8A78E737_548F_40E7_8064_24A6FDEA188F__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -