-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8e1696c
Showing
17 changed files
with
1,922 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
25195908475657893494027183240048398571429282126204032027777137836043662020707595556264018525880784406918290641249515082189298559149176184502808489120072844992687392807287776735971418347270261896375014971824691165077613379859095700097330459748808428401797429100642458691817195118746121515172654632282216869987549182422433637259085141865462043576798423387184774447920739934236584823824281198163815010674810451660377306056201619676256133844143603833904414952634432190114657544454178424020924616515723350778707749817125772467962926386356373289912154831438167899885040445364023527381951378636564391212010397122822120720357 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Name: RSA-576 | ||
Prize: $10000 | ||
Digits: 174 | ||
Digit Sum: 785 | ||
188198812920607963838697239461650439807163563379417382700763356422988859715234665485319060606504743045317388011303396716199692321205734031879550656996221305168759307650257059 | ||
Name: RSA-640 | ||
Prize: $20000 | ||
Digits: 193 | ||
Digit Sum: 806 | ||
3107418240490043721350750035888567930037346022842727545720161948823206440518081504556346829671723286782437916272838033415471073108501919548529007337724822783525742386454014691736602477652346609 | ||
Name: RSA-704 | ||
Prize: $30000 | ||
Digits: 212 | ||
Digit Sum: 1009 | ||
74037563479561712828046796097429573142593188889231289084936232638972765034028266276891996419625117843995894330502127585370118968098286733173273108930900552505116877063299072396380786710086096962537934650563796359 | ||
Name: RSA-768 | ||
Prize: $50000 | ||
Digits: 232 | ||
Digit Sum: 1018 | ||
1230186684530117755130494958384962720772853569595334792197322452151726400507263657518745202199786469389956474942774063845925192557326303453731548268507917026122142913461670429214311602221240479274737794080665351419597459856902143413 | ||
Name: RSA-896 | ||
Prize: $75000 | ||
Digits: 270 | ||
Digit Sum: 1222 | ||
412023436986659543855531365332575948179811699844327982845455626433876445565248426198098870423161841879261420247188869492560931776375033421130982397485150944909106910269861031862704114880866970564902903653658867433731720813104105190864254793282601391257624033946373269391 | ||
Name: RSA-1024 | ||
Prize: $100000 | ||
Digits: 309 | ||
Digit Sum: 1369 | ||
135066410865995223349603216278805969938881475605667027524485143851526510604859533833940287150571909441798207282164471551373680419703964191743046496589274256239341020864383202110372958725762358509643110564073501508187510676594629205563685529475213500852879416377328533906109750544334999811150056977236890927563 | ||
Name: RSA-1536 | ||
Prize: $150000 | ||
Digits: 463 | ||
Digit Sum: 2153 | ||
1847699703211741474306835620200164403018549338663410171471785774910651696711161249859337684305435744585616061544571794052229717732524660960646946071249623720442022269756756687378427562389508764678440933285157496578843415088475528298186726451339863364931908084671990431874381283363502795470282653297802934916155811881049844908319545009848393775227257052578591944993870073695755688436933812779613089230392569695253261620823676490316036551371447913932347169566988069 | ||
Name: RSA-2048 | ||
Prize: $200000 | ||
Digits: 617 | ||
Digit Sum: 2738 | ||
25195908475657893494027183240048398571429282126204032027777137836043662020707595556264018525880784406918290641249515082189298559149176184502808489120072844992687392807287776735971418347270261896375014971824691165077613379859095700097330459748808428401797429100642458691817195118746121515172654632282216869987549182422433637259085141865462043576798423387184774447920739934236584823824281198163815010674810451660377306056201619676256133844143603833904414952634432190114657544454178424020924616515723350778707749817125772467962926386356373289912154831438167899885040445364023527381951378636564391212010397122822120720357 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
gcc -g rsacrack.c -lgmp -o rsacrack | ||
|
||
#-lgmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#define TRUE (1) | ||
#define FALSE (0) | ||
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) | ||
#include <stdio.h> | ||
#include <gmp.h> | ||
|
||
|
||
|
||
|
||
int mpz_count_bits(mpz_t num) | ||
{ | ||
mp_limb_t last_limb=num->_mp_d[((num->_mp_size)-1)]; | ||
int num_bits=((num->_mp_size)-1)*(sizeof(mp_limb_t)<<3); | ||
while(last_limb!=0) | ||
{ | ||
last_limb>>=1; | ||
num_bits++; | ||
} | ||
return(num_bits); | ||
} | ||
|
||
void mpz_lshift(mpz_t rop,mpz_t op,unsigned long cnt) | ||
{ | ||
mpn_lshift(rop->_mp_d, op->mp_d,op->_mp_size,cnt); | ||
} | ||
|
||
void mpz_rshift(mpz_t rop,mpz_t op,unsigned long cnt) | ||
{ | ||
mpn_rshift(rop->_mp_d, op->mp_d,op->_mp_size,cnt); | ||
} | ||
|
||
|
||
|
||
int main(int argc,char *argv[]) | ||
{ | ||
mpz_t composite,divisor,shifted_divisor,remainder,result,tmp; | ||
int num_composite_bits,num_divisor_bits,divisor_shift,divisor_shift2,cmp; | ||
|
||
if(argc!=2) | ||
goto error; | ||
mpz_init_set_str(composite,argv[1],10); | ||
if(mpz_cmp_si(composite,0)<=0) | ||
goto error; | ||
mpz_init(remainder); | ||
mpz_init(divisor); | ||
mpz_init(shifted_divisor); | ||
mpz_init(tmp); | ||
mpz_init(result); | ||
mpz_set_ui(result,0); | ||
num_composite_bits=mpz_count_bits(composite); | ||
mpz_init_set_ui(divisor,2); | ||
num_divisor_bits=2; | ||
mpz_set(remainder,composite); | ||
divisor_shift=num_composite_bits-num_divisor_bits; | ||
mpz_lshift(shifted_divisor,divisor,divisor_shift); | ||
|
||
/*long division loop */ | ||
for(divisor_shift2=divisor_shift;divisor_shift2>=0;divisor_shift2--) | ||
{ | ||
mpz_sub(tmp,remainder,shifted_divisor); | ||
cmp=mpz_cmp_ui(tmp,0); | ||
if(cmp==0) | ||
{ | ||
printf("perfect divisor found="); | ||
mpz_out_str(stdout,10,divisor); | ||
printf("\n"); | ||
} | ||
if(cmp>0) | ||
{ | ||
mpz_set_bit(result,divisor_shift2); | ||
mpz_set(remainder,tmp); | ||
} | ||
if(divisor_shift-divisor_shift2==num_divisor_bits) | ||
mpz_rshift(divisor,divisor,1); | ||
} | ||
printf("result "); | ||
mpz_out_str(stdout,10,result); | ||
printf("\n"); | ||
return 0; | ||
|
||
error: | ||
fprintf(stderr,"usage rsacrack positive number\n"); | ||
return -1; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
/* factor -- print factors of n. | ||
Copyright (C) 86, 95, 96, 1997, 1998, 1999 Free Software Foundation, Inc. | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2, or (at your option) | ||
any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software Foundation, | ||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | ||
|
||
/* Written by Paul Rubin <[email protected]>. | ||
Adapted for GNU, fixed to factor UINT_MAX by Jim Meyering. */ | ||
|
||
#include <config.h> | ||
#include <stdio.h> | ||
#include <sys/types.h> | ||
|
||
#include <assert.h> | ||
#define NDEBUG 1 | ||
|
||
#include "system.h" | ||
#include "long-options.h" | ||
#include "error.h" | ||
#include "human.h" | ||
#include "readtokens.h" | ||
#include "xstrtol.h" | ||
|
||
/* The official name of this program (e.g., no `g' prefix). */ | ||
#define PROGRAM_NAME "factor" | ||
|
||
#define AUTHORS "Paul Rubin" | ||
|
||
/* Token delimiters when reading from a file. */ | ||
#define DELIM "\n\t " | ||
|
||
/* FIXME: if this program is ever modified to factor integers larger | ||
than 2^128, this constant (and the algorithm :-) will have to change. */ | ||
#define MAX_N_FACTORS 128 | ||
|
||
/* The name this program was run with. */ | ||
char *program_name; | ||
|
||
void | ||
usage (int status) | ||
{ | ||
if (status != 0) | ||
fprintf (stderr, _("Try `%s --help' for more information.\n"), | ||
program_name); | ||
else | ||
{ | ||
printf (_("\ | ||
Usage: %s [NUMBER]...\n\ | ||
or: %s OPTION\n\ | ||
"), | ||
program_name, program_name); | ||
printf (_("\ | ||
Print factors of each NUMBER; read standard input with no arguments.\n\ | ||
\n\ | ||
--help display this help and exit\n\ | ||
--version output version information and exit\n\ | ||
\n\ | ||
Print the prime factors of all specified integer NUMBERs. If no arguments\n\ | ||
are specified on the command line, they are read from standard input.\n\ | ||
")); | ||
puts (_("\nReport bugs to <[email protected]>.")); | ||
} | ||
exit (status); | ||
} | ||
|
||
/* FIXME: comment */ | ||
|
||
static int | ||
factor (uintmax_t n0, int max_n_factors, uintmax_t *factors) | ||
{ | ||
register uintmax_t n = n0, d, q; | ||
int n_factors = 0; | ||
|
||
if (n < 1) | ||
return n_factors; | ||
|
||
while (n % 2 == 0) | ||
{ | ||
assert (n_factors < max_n_factors); | ||
factors[n_factors++] = 2; | ||
n /= 2; | ||
} | ||
|
||
/* The exit condition in the following loop is correct because | ||
any time it is tested one of these 3 conditions holds: | ||
(1) d divides n | ||
(2) n is prime | ||
(3) n is composite but has no factors less than d. | ||
If (1) or (2) obviously the right thing happens. | ||
If (3), then since n is composite it is >= d^2. */ | ||
|
||
d = 3; | ||
do | ||
{ | ||
q = n / d; | ||
while (n == q * d) | ||
{ | ||
assert (n_factors < max_n_factors); | ||
factors[n_factors++] = d; | ||
n = q; | ||
q = n / d; | ||
} | ||
d += 2; | ||
} | ||
while (d <= q); | ||
|
||
if (n != 1 || n0 == 1) | ||
{ | ||
assert (n_factors < max_n_factors); | ||
factors[n_factors++] = n; | ||
} | ||
|
||
return n_factors; | ||
} | ||
|
||
/* FIXME: comment */ | ||
|
||
static int | ||
print_factors (const char *s) | ||
{ | ||
uintmax_t factors[MAX_N_FACTORS]; | ||
uintmax_t n; | ||
int n_factors; | ||
int i; | ||
char buf[LONGEST_HUMAN_READABLE + 1]; | ||
|
||
if (xstrtoumax (s, NULL, 10, &n, "") != LONGINT_OK) | ||
{ | ||
error (0, 0, _("`%s' is not a valid positive integer"), s); | ||
return 1; | ||
} | ||
n_factors = factor (n, MAX_N_FACTORS, factors); | ||
printf ("%s:", human_readable (n, buf, 1, 1)); | ||
for (i = 0; i < n_factors; i++) | ||
printf (" %s", human_readable (factors[i], buf, 1, 1)); | ||
putchar ('\n'); | ||
return 0; | ||
} | ||
|
||
static int | ||
do_stdin (void) | ||
{ | ||
int fail = 0; | ||
token_buffer tokenbuffer; | ||
|
||
init_tokenbuffer (&tokenbuffer); | ||
|
||
for (;;) | ||
{ | ||
long int token_length; | ||
|
||
token_length = readtoken (stdin, DELIM, sizeof (DELIM) - 1, | ||
&tokenbuffer); | ||
if (token_length < 0) | ||
break; | ||
fail |= print_factors (tokenbuffer.buffer); | ||
} | ||
free (tokenbuffer.buffer); | ||
|
||
return fail; | ||
} | ||
|
||
int | ||
main (int argc, char **argv) | ||
{ | ||
int fail; | ||
|
||
program_name = argv[0]; | ||
setlocale (LC_ALL, ""); | ||
bindtextdomain (PACKAGE, LOCALEDIR); | ||
textdomain (PACKAGE); | ||
|
||
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION, | ||
AUTHORS, usage); | ||
/* The above handles --help and --version. | ||
Since there is no other invocation of getopt, handle `--' here. */ | ||
if (argc > 1 && STREQ (argv[1], "--")) | ||
{ | ||
--argc; | ||
++argv; | ||
} | ||
|
||
fail = 0; | ||
if (argc == 1) | ||
fail = do_stdin (); | ||
else | ||
{ | ||
int i; | ||
for (i = 1; i < argc; i++) | ||
fail |= print_factors (argv[i]); | ||
} | ||
if (fail) | ||
usage (1); | ||
|
||
exit (fail); | ||
} |
Oops, something went wrong.