24 lines
		
	
	
		
			792 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			792 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #include <tommath.h>
 | |
| #include <cassert>
 | |
| #include <tomcrypt.h>
 | |
| 
 | |
| void testTomMath(){
 | |
|     mp_int x{};
 | |
|     mp_init(&x);
 | |
|     mp_read_radix(&x, "2280880776330203449294339386427307168808659578661428574166839717243346815923951250209099128371839254311904649344289668000305972691071196233379180504231889", 10);
 | |
| 
 | |
|     mp_int n{};
 | |
|     mp_init(&n);
 | |
|     mp_read_radix(&n, "436860662135489324843442078840868871476482593772359054106809367217662215065650065606351911592188139644751920724885335056877706082800496073391354240530016", 10);
 | |
| 
 | |
|     mp_int exp{};
 | |
|     mp_init(&exp);
 | |
|     mp_2expt(&exp, 1000);
 | |
| 
 | |
| 
 | |
|     mp_int r{};
 | |
|     mp_init(&r);
 | |
|     assert(mp_exptmod(&x, &exp, &n, &r) != CRYPT_OK); //if this method succeed than tommath failed. Unknown why but it is so
 | |
| 
 | |
|     mp_clear_multi(&x, &n, &exp, &r, nullptr);
 | |
| } |