Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!godot.cc.duq.edu!newsgate.duke.edu!news.mathworks.com!uunet!in1.uu.net!ulf.mali.sub.org!um
From: um@c2.org (Ulf Moeller)
Subject: Re: RSA implementation in Scheme?
Message-ID: <835289484.2218@ulf.mali.sub.org>
Sender: um@c2.org (Ulf Moeller)
Supersedes: <835289041.2019@ulf.mali.sub.org>
Content-Type: text/plain; charset=ISO-8859-1
Organization: private site, Hamburg (Germany)
MIME-Version: 1.0
Date: Thu, 20 Jun 1996 16:51:22 GMT
References: <4q8gpo$p37@ulysses.noc.ntua.gr>
Content-Transfer-Encoding: 8bit
Lines: 18

adamo@news.ntua.gr (Yiorgos Adamopoulos) writes:

>Well subject says it all...  Has anybody implemnted RSA in Scheme?

For C implementations of RSA, most of the work is to cope with
bignums. In Scheme, there isn't much to do really. :)

My implementation is at http://www.c2.org/~um/crypt/scheme.html

In a real-world application you will have to care about gathering
randomness for key generation (which is hard to do portably). If
you are using Linux or FreeBSD, I recommend that you use /dev/random.

-- 
(define(RSA m e n)(list->string(u(r(s(string->list m))e n))))(define(u a)(if(>
a 0)(cons(integer->char(modulo a 256))(u(quotient a 256)))'()))(define(s a)(if
(null? a)0(+(char->integer(car a))(* 256(s(cdr a))))))(define(r a x n)(cond((=
0 x)1)((odd? x)(modulo(* a(r a(- x 1)n))n))(#t(modulo(expt(r a(/ x 2)n)2)n))))
