10.07.2015 Views

Implementing the RSA cryptosystem with Maxima CAS - Facultad de ...

Implementing the RSA cryptosystem with Maxima CAS - Facultad de ...

Implementing the RSA cryptosystem with Maxima CAS - Facultad de ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The Electronic Journal of Ma<strong>the</strong>matics and Technology, Volume 6, Number 1, ISSN 1933-2823tea in <strong>the</strong> gar<strong>de</strong>n, if <strong>the</strong> lady and gentleman wish to take <strong>the</strong>ir tea in <strong>the</strong> gar<strong>de</strong>n ...” I <strong>de</strong>ci<strong>de</strong>d that if <strong>the</strong>shaking of her breasts could be stopped, some of <strong>the</strong> fragments of <strong>the</strong> afternoon might be collected,and I concentrated my attention <strong>with</strong> careful subtlety to this end.To redirect <strong>the</strong> output to a file, we give <strong>the</strong> path to that file, as in:(%i14) rsa_<strong>de</strong>crypt("/root/hysteria-encrypted.txt",20,private_key,"/root/hysteria-<strong>de</strong>crypted.txt");(%o14) /root/hysteria − <strong>de</strong>crypted.txt4 Digital signaturesAlthough <strong>the</strong> <strong>RSA</strong> <strong>cryptosystem</strong>, as <strong>de</strong>scribed in <strong>the</strong> preceding sections, has some nice properties (itis reliable and secure), it also has a serious drawback: it does not provi<strong>de</strong> any method to check <strong>the</strong>au<strong>the</strong>nticity of <strong>the</strong> message; in o<strong>the</strong>r words, we do not know if <strong>the</strong> person claiming to be <strong>the</strong> sen<strong>de</strong>r of<strong>the</strong> message is actually that person, as <strong>the</strong> recipient gets <strong>the</strong> message encrypted <strong>with</strong> his own publickey, which is available to everybody.However, using <strong>the</strong> same i<strong>de</strong>as of <strong>the</strong> <strong>RSA</strong> method, a solution to this problem can be given. Itconsists in <strong>the</strong> following: <strong>the</strong> sen<strong>de</strong>r (user A) signs <strong>the</strong> message in such a way that anybody (forinstance, <strong>the</strong> receiver, user B) can <strong>de</strong>duce that only A is able to produce that signature. To implementthis “digital signature”, a possible method 6 follows <strong>the</strong>se steps: user A adds to <strong>the</strong> message she wantsto send (say text) her signature, ano<strong>the</strong>r piece of text such as I am user A, that i<strong>de</strong>ntifies her, encrypted<strong>with</strong> her private key, to get text + f A pri(I am user A). Then, <strong>the</strong> sen<strong>de</strong>r (user A) encrypts <strong>the</strong> result<strong>with</strong> <strong>the</strong> public key of <strong>the</strong> recipient B, f B pub (text + f A pri(I am user A)). When user B <strong>de</strong>crypts <strong>the</strong>message, he will find two pieces, <strong>the</strong> message text and <strong>the</strong> encrypted chunk f A pri(I am user A). To besure that <strong>the</strong> message actually comes from A, all he has to do is to apply her public key to it, as <strong>the</strong>result is <strong>the</strong>nf A pub(f A pri(I am user A)) = I am user A.Note that <strong>the</strong> i<strong>de</strong>a behind <strong>the</strong> digital signature is that only A is able to produce a text such that, whenapplying fpub A , <strong>the</strong> result is legible.The following function, rsa encrypt ds, is a slight modification of rsa encrypt capableof including a signature. It takes a file <strong>with</strong> path a containing some text to encrypt, an integer k (<strong>the</strong>chunk length), a list P = [e, n] (<strong>the</strong> public key of <strong>the</strong> recipient, user B), a list Q = [d, n] (<strong>the</strong> privatekey of <strong>the</strong> sen<strong>de</strong>r, user A), a path q to a file storing a signature, and, optionally, a path p to a file where<strong>the</strong> output is written as its arguments. When p is absent, <strong>the</strong> output is written in <strong>the</strong> <strong>Maxima</strong> console.load("stringproc");Beginning of co<strong>de</strong>6 The procedure we <strong>de</strong>scribe here is not <strong>the</strong> one used in an actual situation, where A first gets a digest of <strong>the</strong> message,<strong>with</strong> a certain hash function such as MD5, and <strong>the</strong>n encrypt this digest <strong>with</strong> her own private key. But <strong>the</strong> example we<strong>de</strong>scribe retains <strong>the</strong> basic i<strong>de</strong>a while being far more easy to implement.47

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!