Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cKeyRSA1.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cKeyRSA1_H
7 #define _INC_cKeyRSA1_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "../GrayLibBase.h"
13 #include "../Math/cBigUnsigned.h"
18 
19 namespace GrayLib
20 {
22 
23  class cASNWriterRev;
24  class cASNReader;
25 
27  {
62 
63  public:
65  // typedef cUInt64 VAL_t; // substitute this for testing.
66 
69 
70  public:
71  cKeyRSA1(void);
72  cKeyRSA1(const VAL_t& _exp, const VAL_t& _mod);
73  virtual ~cKeyRSA1(void);
74 
75  bool IsValidKey() const;
76  void SetZeroKey();
77 
78  void SetCopyKey(const cKeyRSA1& src)
79  {
80  this->m_N = src.m_N;
81  this->m_E = src.m_E;
82  }
83 
84  void GenerateKeys(OUT VAL_t& d, const VAL_t& p, const VAL_t& q);
85  void GenerateKeys(BIT_ENUM_t nBits, OUT VAL_t& d, OUT VAL_t* pP = nullptr, OUT VAL_t* pQ=nullptr); // OUT p, q ??
86 
87  VAL_t EncryptDecrypt(const VAL_t& source) const;
88 
89  HRESULT WritePublicKey(cASNWriterRev& w) const;
90  HRESULT ReadPublicKey(cASNReader& r);
91 
92  // TODO
93  HRESULT LoadKeyFile(cStreamInput& rInp, const char* pszName = nullptr);
94  HRESULT LoadKeyFile(const FILECHAR_t* pszFileName, const char* pszName = nullptr);
95 
97  };
98 }
99 #endif // _INC_cKeyRSA1_H
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
Definition: cASNReader.h:22
Definition: cASNWriterRev.h:22
Definition: cBigUnsigned.h:22
Definition: cKeyRSA1.h:27
VAL_t m_E
exponent of the key (public or private half of the key depending on use.)
Definition: cKeyRSA1.h:68
void SetCopyKey(const cKeyRSA1 &src)
Definition: cKeyRSA1.h:78
VAL_t m_N
modulus of the key (usually public) = multiplication of the 2 primes (pq).
Definition: cKeyRSA1.h:67
cBigUnsigned VAL_t
Definition: cKeyRSA1.h:64
UNITTEST_FRIEND(cKeyRSA1)
Definition: cStream.h:306
Definition: cMesh.h:22
UNITTEST2_PREDEF(cQuadtree)
unsigned int BIT_ENUM_t
Enumerate number of bits or address a single bit in some array of bits.
Definition: cBits.h:20
char FILECHAR_t
a UTF8 char in a file name. like TCHAR
Definition: FileName.h:22
Definition: cDebugAssert.h:29