ADS
Algorithms and Data Structures
Toggle main menu visibility
Loading...
Searching...
No Matches
RSA.h
Go to the documentation of this file.
1
/*--------------------------------------------------------------------------*/
2
/*------------------------------- File RSA.h -------------------------------*/
3
/*--------------------------------------------------------------------------*/
40
/*--------------------------------------------------------------------------*/
41
/*----------------------------- DEFINITIONS --------------------------------*/
42
/*--------------------------------------------------------------------------*/
43
44
#ifndef __ADS_RSA
45
#define __ADS_RSA
46
/* self-identification: #endif constant */
47
48
/*--------------------------------------------------------------------------*/
49
/*------------------------------ INCLUDES ----------------------------------*/
50
/*--------------------------------------------------------------------------*/
51
52
#include "
ADS/Contract.h
"
53
#include "
ADS/numeric/NumberTheory.h
"
54
55
#include <cstdint>
56
#include <random>
57
#include <utility>
58
59
/*--------------------------------------------------------------------------*/
60
/*--------------------------- NAMESPACE ------------------------------------*/
61
/*--------------------------------------------------------------------------*/
62
63
namespace
ADS
64
{
65
67
struct
RsaKey
68
{
69
U64
N
,
70
e
;
71
};
72
89
template
<
class
R >
90
U64
randomPrime
(
int
bits , R & rng );
91
110
template
<
class
R >
111
std::pair< RsaKey , RsaKey >
rsaKeys
( R & rng );
112
124
inline
U64
rsa
(
U64
M ,
const
RsaKey
& k );
125
126
/*--------------------------------------------------------------------------*/
127
128
}
// end( namespace ADS )
129
130
/*--------------------------------------------------------------------------*/
131
/*-------------------------- IMPLEMENTATION --------------------------------*/
132
/*--------------------------------------------------------------------------*/
133
134
#include "ADS/numeric/impl/RSA.tpp"
135
136
/*--------------------------------------------------------------------------*/
137
138
#endif
/* RSA.h included */
139
140
/*--------------------------------------------------------------------------*/
141
/*----------------------------- End File RSA.h -----------------------------*/
142
/*--------------------------------------------------------------------------*/
Contract.h
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
NumberTheory.h
The arithmetic of section 17.2 and of exercises 17.1-17.3, on unsigned integers of 64 bits:
ADS::rsa
U64 rsa(U64 M, const RsaKey &k)
the message under the key, : encrypting with a public key, or decrypting and signing with a private ...
ADS::rsaKeys
std::pair< RsaKey, RsaKey > rsaKeys(R &rng)
a pair (public, private) of keys, with of about 62 bits
ADS::randomPrime
U64 randomPrime(int bits, R &rng)
a random odd prime of exactly bits, by the test of Miller and Rabin on 40 bases
ADS
Definition
ADT.h:96
ADS::U64
std::uint64_t U64
the unsigned integers of 64 bits
Definition
NumberTheory.h:261
ADS::RsaKey
a key
Definition
RSA.h:68
ADS::RsaKey::N
U64 N
the modulus, the product of two primes
Definition
RSA.h:69
ADS::RsaKey::e
U64 e
the exponent
Definition
RSA.h:70
ADS
numeric
RSA.h
Generated by
1.17.0