/* Dynamic Password Client - DMS - aug 00 - by Sylvain HUET */ struct EnterBox= [chEnterBox:Chn,winEnterBox:ObjWin,txtEnterBox:ObjText,endEnterBox:fun[S] I] mkEnterBox;; fun _ok(x,b)= let _GETtext b.txtEnterBox -> s in (_DSwindow b.winEnterBox; exec b.endEnterBox with [s]) ;; fun _cancel(x,b)= _DSwindow b.winEnterBox; exec b.endEnterBox with [nil] ;; fun _destroyE(x,b)= exec b.endEnterBox with [nil];; fun lineok(a,b,c)=_ok nil b;; fun _focusevent(a,b)=_SETtextFocus b.txtEnterBox;; fun iniEnterBox(ch,father,x,y,title,end,txt)= let _CRwindow ch father x y 300 80 WN_MENU+WN_MINBOX title -> win in let _CRtext ch win 5 5 290 20 ET_BORDER txt -> banner in let _CReditLine ch win 5 30 290 20 ET_PASSWORD+ET_DOWN+ET_AHSCROLL "" -> text in let _CRbutton ch win 5 55 70 20 0 _loc this "OK" nil -> ok in let _CRbutton ch win 80 55 70 20 0 _loc this "CANCEL" nil -> cancel in let mkEnterBox [ch win text end]-> b in (_CBwinDestroy win @_destroyE b; _CBwinFocus win @_focusevent b; _CBbutton ok @_ok b; _CBbutton cancel @_cancel b; _CBlineOk text @lineok b; _SETtextFocus text; b) ;; defcom Canswer=answer S;; /* cryptage */ fun BigSizebis(n,b,i)= if (BigCmp b n) >0 then i else BigSizebis n BigAdd b b i+1;; fun BigSize(n)= BigSizebis n BigFromAsc "1" 0;; fun CRPcryptone(l,p,g,y,k,i1)= if l==nil then nil else let l->[m nxt] in (BigToStringn (BigExpn g k p) i1):: (BigToStringn (BigMuln (BigExpn y k p) m p) i1)::CRPcryptone nxt p g y k i1;; fun CRPfindK(p)= let BigFromAsc "1" -> un in let BigMod BigRand p -> k in if (BigCmp BigPgcd BigSub p un k un)==0 then k else CRPfindK p;; fun CRPcrypt(s,pub)= let pub->[p g y] in let ((BigSize p)-1)>>3 -> nbyte in let CRPfindK p -> k in strcatn CRPcryptone (BigListFromString s nbyte) p g y k nbyte+1;; fun crypt(s,k)= if s==nil then nil else let hd strextr k->[p [g [y _]]] in CRPcrypt s [BigFromString p BigFromString g BigFromString y];; fun end(ps,pub)= _DMSsend this Canswer [crypt ps pub];; fun IniDMI(pub)= let _loc this "PASS" nil -> txt in iniEnterBox _channel DMSwin nil nil txt mknode @end pub txt; 0;;