ADS
Algorithms and Data Structures
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"
54
55#include <cstdint>
56#include <random>
57#include <utility>
58
59/*--------------------------------------------------------------------------*/
60/*--------------------------- NAMESPACE ------------------------------------*/
61/*--------------------------------------------------------------------------*/
62
63namespace ADS
64{
65
67struct RsaKey
68{
69 U64 N ,
70 e;
71 };
72
89template< class R >
90U64 randomPrime( int bits , R & rng );
91
110template< class R >
111std::pair< RsaKey , RsaKey > rsaKeys( R & rng );
112
124inline 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/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The arithmetic of section 17.2 and of exercises 17.1-17.3, on unsigned integers of 64 bits:
U64 rsa(U64 M, const RsaKey &k)
the message under the key, : encrypting with a public key, or decrypting and signing with a private ...
std::pair< RsaKey, RsaKey > rsaKeys(R &rng)
a pair (public, private) of keys, with of about 62 bits
U64 randomPrime(int bits, R &rng)
a random odd prime of exactly bits, by the test of Miller and Rabin on 40 bases
Definition ADT.h:96
std::uint64_t U64
the unsigned integers of 64 bits
Definition NumberTheory.h:261
a key
Definition RSA.h:68
U64 N
the modulus, the product of two primes
Definition RSA.h:69
U64 e
the exponent
Definition RSA.h:70