eralha
Power Member
We need a encoding key(e) and a decoding key(d).
We start with E, E should be coprime to (p-1*q-1)
The security of RSA does not depend on E, we can check the primes against (p-1*q-1) until we find one. 3, 5, 7 etc (the security of RSA depends on how hard it is factoring the number we choose as modulus).
3 is coprime to 4265, lets choose 3 as our E.
In order to calculate D we must do an inverse mod operation like so
E^-1 mod (p-1*q-1). Inverse mod can be found on any good calculator and is often shown as M^-1 i am using Hexprobe Multibyte Calculator
so 3^-1 mod 4265 is 2843(d)
now take 3 as our encoding key(e) and 2843 as our decoding key(d).
The RSA rules are now
C = P^E mod m
P = C^D mod m
P = Plain Text
C = Cipher Text
1000^E(3) mod m(4399) = C(1724)
1000 encrypts to 1724, lets decode it now.
1724^D(2843) mod m(4399) = P(1000)
Boas pessoal estou a tentar perceber esta logica, o que nao entendi bem foi como gerar a chave de desencriptação, dame sempre valores esquisitos, as contas que estou a fazer são em action script, mas o meu problema está na matemática.
We start with E, E should be coprime to (p-1*q-1)
The security of RSA does not depend on E, we can check the primes against (p-1*q-1) until we find one. 3, 5, 7 etc (the security of RSA depends on how hard it is factoring the number we choose as modulus).
3 is coprime to 4265, lets choose 3 as our E.
In order to calculate D we must do an inverse mod operation like so
E^-1 mod (p-1*q-1). Inverse mod can be found on any good calculator and is often shown as M^-1 i am using Hexprobe Multibyte Calculator
so 3^-1 mod 4265 is 2843(d)
now take 3 as our encoding key(e) and 2843 as our decoding key(d).
The RSA rules are now
C = P^E mod m
P = C^D mod m
P = Plain Text
C = Cipher Text
1000^E(3) mod m(4399) = C(1724)
1000 encrypts to 1724, lets decode it now.
1724^D(2843) mod m(4399) = P(1000)
Boas pessoal estou a tentar perceber esta logica, o que nao entendi bem foi como gerar a chave de desencriptação, dame sempre valores esquisitos, as contas que estou a fazer são em action script, mas o meu problema está na matemática.
Código:
var modulus:Number = 4399;
var eKey:Number = 3;
var dKey:Number = (eKey^-1)%4265;
var c:Number = Math.pow(1000,eKey)%modulus;
var p:Number = Math.pow(c, dKey)%modulus;
trace("EKEY: "+eKey+" Cypher "+c+" DKEY: "+dKey+" Plain: "+p);
OUTPUT: EKEY: 3 Cypher 1724 DKEY: -4 Plain: 1.1320118003091641e-13