RSA - 12


end;

if (i<=53) then Exit;

Move(nzero,n1,sizeof(nzero));

BN_a_sub_b(a,none,n2);

i := 0;

n1[0] := primes[i];

BN_a_exp_b_mod_c(n1,n2,a,n3);

BN_a_sub_b(n3,none,n4);

BN_a_mod_b(n4,a,n3);

while (i<=50) and (BN_a_cmp_b(n3,nzero)=0) do

begin

Inc(i);

if (i>50) then Break;

n1[0] := primes[i];

BN_a_exp_b_mod_c(n1,n2,a,n3);

BN_a_sub_b(n3,none,n4);

BN_a_mod_b(n4,a,n3);

end;

if (i<=50) then Exit;

BN_a_sub_b(a,none,n2);

i := 0;

oldseed := RandSeed;

for j := 0 to BIGNUM_DWORD do

begin

n4[j] := Random(2);

18.2

n4[j] := Cardinal(RandSeed);

end;

BN_a_mod_b(n4,a,n1);

BN_a_exp_b_mod_c(n1,n2,a,n3);

BN_a_sub_b(n3,none,n4);

BN_a_mod_b(n4,a,n3);

while (i<=50) and (BN_a_cmp_b(n3,nzero)=0) do

begin

Inc(i);

if (i>50) then Break;

for j := 0 to BIGNUM_DWORD do

begin

n4[j] := Random(2);

n4[j] := Cardinal(RandSeed);

end;

BN_a_mod_b(n4,a,n1);

BN_a_exp_b_mod_c(n1,n2,a,n3);

BN_a_sub_b(n3,none,n4);

BN_a_mod_b(n4,a,n3);

end;

RandSeed := oldseed;

if (i<=50) then Exit;

Result := 1;

end;

end.