From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.unit0.net!peer03.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 29 Apr 2017 08:55:26 -0500 From: Dennis Lee Bieber Newsgroups: comp.lang.ada Subject: Re: Tasking and Concurrent Programming Using Multiple Ada Programs. Date: Sat, 29 Apr 2017 09:55:28 -0400 Organization: IISS Elusive Unicorn Message-ID: <4c29gc93vlvglrsoi41dlr0ch9b5bmh2cc@4ax.com> References: <7edc0e62-80fe-4a91-9015-69c781207fc8@googlegroups.com> User-Agent: ForteAgent/8.00.32.1272 X-No-Archive: YES MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 108.68.176.251 X-Trace: sv3-8ATX2Ce4K43iB0HZOTXrKLq3MD4JCrGASyUJ8OOYbvxtKW6Vo76D2z1u5S2/93sJX9jThFNmjfyJGMZ!CI7wWu9trF6R6e21aeOhQw62xg6NWQcDg8FFgUTIIwcLVPIOT5dNlOULv7NRPVdTWwOvVDAKo+9C!Tfade6P/pC3cuW3ayxZIbV+otmNi X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 15033 X-Received-Bytes: 15188 X-Received-Body-CRC: 693491360 Xref: news.eternal-september.org comp.lang.ada:46643 Date: 2017-04-29T09:55:28-04:00 List-Id: On Sat, 29 Apr 2017 01:13:45 -0700 (PDT), Austin Obyrne declaimed the following: >The hoped for plan is to write a program that will cater for 36 (or less if needs be ) ciphers all reading in and immediately encrypting, in rotation from the same file of plaintext and writing out the resulting ciphertext to the same ciphertext file (the encrypted plaintext file). They would of course be written in Ada. > Insufficient problem description... Do you mean that each of the 36 is processing the identical input, and the output is to be interleaved in the destination file? If so, what chunk size, and is the order of interleaving important (if it is, you probably won't gain too much from concurrency since your output needs to be sequential -- so you end up waiting for #1 to return data before you can even go on to waiting for #2's data, even if #2 finishes before #1. It also means your output file will be 36 times larger... And then you have the decryption -- what are you going to do, feed each chunk, in order, to separate decryption functions when all of them are going to produce the identical plain-text... Lots of redundant processing on your end, while supplying an attacker with 36 variant copies of the same text -- if they can determine the chunk size (and depending upon algorithms, the encrypted text may show some boundaries). OR is each of the 36 supposed to be working on a different chunk of the source -- so the output file is the same size as the input? You've still got the problem of having to produce the output in sequential order, so there is lots of waiting for output to be available. >What I would like to know is if some of your members are familiar with tasking and concurrent programming sufficient to be able to say - Yes, it is feasible at least and give any other advice you may have to offer. > Sure it's possible... But is it effective and useful? Probably not. {NOTE: I used the above text as the "plain.txt"} Python program (you didn't think I was going to write your Ada template, did you?): -=-=-=-=-=- import threading import Queue CHUNKSIZE = 32 class Algorithm1(object): def __init__(self, increment): self.inc = increment def process(self, pbyte): return chr((ord(pbyte) + self.inc) % 256) class Algorithm2(object): def __init__(self, increment): self.inc = increment def process(self, pbyte): if self.inc == 0: self.inc = 1 cbyte = chr((ord(pbyte) + self.inc) % 256) self.inc = (self.inc * 2) % 256 return cbyte class EOD(object): pass ALGORITHMS = [ Algorithm1(2), Algorithm2(2), Algorithm1(3), Algorithm2(3) ] def process(alg, inQ, outQ): while True: data = inQ.get() if data == EOD: break else: odata = "".join([alg.process(d) for d in data]) outQ.put(odata) taskControl = [] for alg in ALGORITHMS: inQue = Queue.Queue() outQue = Queue.Queue() task = threading.Thread(target=process, args=(alg, inQue, outQue)) task.start() taskControl.append( (task, inQue, outQue) ) fin = open("plain.txt", "rb") fout = open("cypher.txt", "wb") while True: data = fin.read(CHUNKSIZE) ## print repr(data) if not data: break # send CHUNKSIZE of data to each task to process for (t, iQ, oQ) in taskControl: iQ.put(data) # wait for each task in sequence to return the processed chunk for (t, iQ, oQ) in taskControl: odata = oQ.get() ## print repr(t), repr(odata) fout.write(odata) # send END OF DATA flag to each task for (t, iQ, oQ) in taskControl: iQ.put(EOD) # join (termination) of tasks for (t, iQ, oQ) in taskControl: t.join() fout.close() fin.close() -=-=-=-=-=-=- And the output of running it (note -- the newsreader will likely have a fit, though I'm copying from a text editor that shows non-printables as inverse video expressions... -=-=-=-=-=-=- Qp"Ucv."4;"Crt"4239"23<35<67"/29Qr(c´¬!4=(Q² 325?0Pqº25>cwuvkp024(8p„Ô*.$I…“´éo"Sj‰’®å!>e}ƒ”©î/33#+SGW,/#Dxvwlq#Re|uqh#?dxvwlq112$0`d”©-"E}ƒ”©î!Qf‚Ž¥ =cy{„‰®®qd{tpgBjqvockn0eqo@"fgenckogf"vjqf‚Ž¥Àiqxuq‰¬®dqqF0„¥ãmcmuu„`ôire|uqhCkrwpdl o1frpA#ghfodlphg#wkpd}z~…€èpvqiyŒnãpoB(t…£ìbkqmt@´èg"hqnnqykpi<  @Vjg"jqrgf"hqt"rg$nŒ¬ïxkroJ-J @Xpu@¨ïqgh(v² qh#iroorzlqj=  AWkh#krshg#iru#sf"jw|Œ¯÷jpkB*MŠ?Vlm0ˆ¯ðff$n’`ðncp"ku"vq"ytkvg"c"rtqitco"vjcv"ynev0‰³ uq$‚‰´å!c$x‚§òbo$|x´ xodq#lv#wr#zulwh#d#surjudp#wkdw#zmcr(y“`ôp"{zy”¥ b"tz‡²án"xpq”`÷knn"ecvgt"hqt"58"*qt"nguu"kh"pggkpt0ƒ¡ôft$n’`³7",w‚@¬åtu$qv@®åfloo#fdwhu#iru#69#+ru#ohvv#li#qhhjnp(s´ås"jw‚@s¶!*sz0Œ¥ót"mn0Ž¥åfu"dg"+"ekrjgtu"cnn"tgcfkpi"k p"cfw(r…`©!emxx…²ó!cpt0’¥áekro0‰® bgv#eh#,#flskhuv#doo#uhdglqj#lq#deu$ju@i dktpu’³ bnp(‚…¡äjpk(yŽ`ápf"koogfkcvgn{"gpet{rvkpi."kp"tqph(y­åeke|uŒ¹ fpgz‰´éoi0(yŽ`òpqg#lpphgldwho|#hqfu|swlqj/#lq#urof$q}¥äjcxm|™`åoev€”©îh.$q~@²ïvcvkqp"htqo"vjg"ucog"hkng"qh"rncve|y® gtsu0”¨å!ueuu@¦émg$wv@°ìbwdwlrq#iurp#wkh#vdph#iloh#ri#soducxqŽ`æsq q(„ˆ¥ tcqm0†©ìf"sn0¬ákpvgzv"cpf"ytkvkpi"qwv"vjg"tguwnkr|u˜´ bph(‡’©ôjpk(•´ uji(‚…³õmlqwh{w#dqg#zulwlqj#rxw#wkh#uhvxojpxmˆ”`áof$‚‰´éoi$w…”`ôig$zu“µìvkpi"ekrjgtvgzv"vq"vjg"ucog"ekrjvmvw@£éqjiz„…¸ô!vs(„ˆ¥ tcqm0ƒ©ðiwlqj#flskhuwh{w#wr#wkh#vdph#flskukro0ƒ©ðigv|u˜´ uq$|x…`óboi(s‰°ègtvgzv"hkng"*vjg"gpet{rvgf"rnckpgv|u˜´ gkpm0H´èf"ivs’¹ ðugh(€Œ¡éohuwh{w#iloh#+wkh#hqfu|swhg#sodlqftxmˆ”`æjni(8”¨å!grk‚™°ôff$x|©îvgzv"hkng+0""Vjg{"yqwnf"qh"eqwtuvi€„@¦émg-60@”èf{$•¬ä!qj(sµòtwh{w#iloh,1##Wkh|#zrxog#ri#frxuvug||0†©ìf+2(0t¨åz"{w…Œ¤ ph$k•²óg"dg"ytkvvgp"kp"Cfc0 @  Kpuwg$ju@·òjvxm~@©î!Chi>-J¾ i®óvh#eh#zulwwhq#lq#Dgd1 A  Lqvxf"fm0—²éuviv0‰® Bfe6*~ YŽ³õhhkekgpv"rtqdngo"fguetkrvkqp000hjqs‰¥îu"tz‚¬ån"hmƒƒ²éqvmw~Nn®iilflhqw#sureohp#ghvfulswlrq111ghmky…®ô!rvwrŒ¥í!fi{s’©ðuksv>Nn  Fq"{qw"ogcp"vjcv"gcej"qh"vjg d¯ zqy(}…¡î!vli„@¥ádj$wv@´èf  Gr#|rx#phdq#wkdw#hdfk#ri#wkh T`ùpw$uu® uje|0…¡ãi"sn0”¨å"58"ku"rtqeguukpi"vjg"kfgpvkecn""7>0‰³ qtsku“³éoi$|x…`éegr|yƒ¡ì!#69#lv#surfhvvlqj#wkh#lghqwlfdo#!5:(y“`ðsqgmƒ“©îh"xpu@©äfpxqs¬ kprwv."cpf"vjg"qwvrwv"ku"vq"dg"kkrx…”l bph(„ˆ¥ pwxx…”`ét"xw0‚¥ jlqsxw/#dqg#wkh#rxwsxw#lv#wr#eh#ljpt}„L`áof$|x…`ïvvt}„@©ó!vs(r…`épvgtngcxgf"kp"vj g"fguvkpcvkqp"hkpxm‚Œ¥áwgh(yŽ`ôig$lu“´éocxqŽ`æjqwhuohdyhg#lq#wkh#ghvwlqdwlrq#iloviz|…¡öff$q~@´èf"hmƒ”©îbvmw~@¦éngA"Kh"uq."yjcv"ejwpm"uk|g."cpf"niG0i¦ tq0(‡ˆ¡ô!el}~‹`ój|i40®ä!ohB#Li#vr/#zkdw#fkxqn#vl}h/#dqg#mgC(Y†`óp.$x´ djyv{@³é{g0(qŽ¤ ku"vjg"qtfgt"qh"kpvgtngcxkpi"korkw(„ˆ¥ pthm‚@¯æ!kr|u’¬åbxmvw@©íqlv#wkh#rughu#ri#lqwhuohdylqj# lpsju$|x…`ïsfiz0¦ jpxm‚Œ¥áwkro0‰­ðqtvcpv"*kh"kv"ku."{qw"rtqdcdn{"yqv|qŽ´ )kj(y”`ét.$•`ðsqfirŒ¹ xruwdqw#+li#lw#lv/#|rx#suredeo|#zptxi~”`¨jh$q„@©ó-"}w…@°òpdej|™`÷qp)v"ickp"vqq"owej"htqo"eqpewttgqr/„@§ájp$|`ível(v’¯í!esvs•²òfrq*w#jdlq#wrr#pxfk#iurp#frqfxuuhpp+|0‡¡éo"xw@­õdj$n‚­ dqrk…’²åpe{"ukpeg"{qwt"qwvrwv"pggfu"vq"dpg0“©îdg $•² pwxx…”`îfgh{0”¯ cqf|#vlqfh#|rxu#rxwsxw#qhhgv#wr#eoe}(ƒ‰®ãf"}w…’`ïvvt}„@®åffw(„`âg"ugswgpvkcn"//"uq"{qw"gpf"wr"ycg${u‘µåovmi|@m­!us(‰µ fph(…`÷bh#vhtxhqwldo#00#vr#|rx#hqg#xs#zdf"wm•¥îuket0Mm tq$•`åof$}€@·ákvkpi"hqt"%3"vq"tgvwtp"fcvc"dghqkxq~‡`æpt$+A@´ï!ti|…’® ecxi0‚¥æplwlqj#iru#&4#wr#uhwxuq#gdwd#ehirjvmvw@¦ïs"'90”¯ sgx}‚Ž `äbve(r…¦ïtg"{qw"ecp"gxgp"iq"qp"vq"yckvkpiti(‰µ dcr(u–¥î!is(Ž`ôp"{iy”©îhuh#|rx#fdq#hyhq#jr#rq#wr#zdlwlqjsg$•`ãbp$m†…® hq$w~@´ï!yeq„‰®ç"hqt"%4)u"fcvc."gxgp"kh"%4"hkpku"jw‚@c²(u$lq”¡¬!gzm~@©æ!%6(v‰®ét#iru#&5*v#gdwd/#hyhq#li#&5#ilqlv!hsz0Cr§t"hi„l fxiv0‰¦ $4$nyŽ©ójgu"dghqtg"%30  Kv"cnuq"ogcpuji{0‚¥æpti(3Qn Y”`ámus(}…¡îtkhv #ehiruh#&41  Lw#dovr#phdqvigw(r…¦ïsg$+ANMŠ Q„@¡ìtq$uu®ó"{qwt"qwvrwv"hkng"yknn"dg"58"vko"}w…’`ïvvt}„@¦émg$yŒ¬ cg$;F@´én#|rxu#rxwsxw#iloh#zloo#eh#69#wlp!{s}‚@¯õury|0†©ìf"{q|Œ`âf"7>0”©ígu"nctigt000"Cpf"vjgp"{qw"jcxg"vgw(|²çft26>@îe"xpuŽ`ùpw$pq–¥ uhv#odujhu111#Dqg#wkhq#|rx#kdyh#wfu$tq’§ås0260a®ä!vlm~@¹ïv"li†…`ôjg"fget{rvkqp"//"yjcv"ctg"{qw"iqji(t…£òzrxqŽ`­."{pq”`ásg$•`çp kh#ghfu|swlrq#00#zkdw#duh#|rx#jrig$luƒ²ùqvmw~@m­!yli„@¡òf"}w…@§ïkpi"vq"fq."hggf"gcej"ejwpm."kp"qkro0”¯ eq0(v…¥ä!gekx@£èvpo40‰® plqj#wr#gr/#ihhg#hdfk#fkxqn/#lq#rjpk(„`äp.$nu…¤ fcgp0ƒ¨õom0(yŽ`ïtfgt."vq"ugrctcvg"fget{vkqp"hwpethm‚L`ôp"wm€²áug$luƒ²ùuksv0†µîdughu/#wr#vhsdudwh#ghfu|wlrq#ixqfsfiz<@´ï!uixq’¡ôf"hms’¹ôjqr(v•®ãvkqpu"yjgp"cn n"qh"vjgo"ctg"iqkpivmw~“`÷igr(qŒ¬ ph$|x…­ bti(w©îhwlrqv#zkhq#doo#ri#wkhp#duh#jrlqjuksvƒ@·èfp$i|Œ`ïg"xpu`ásg$o‰®ç"vq"rtqfweg"vjg"kfgpvkecn"rnckp/"xw0²ïewgm0”¨å!khm~”©ãbn$x|©î.#wr#surgxfh#wkh#lghqwlfdo#sodlq0!vs(€’¯ävei(„ˆ¥ jfiv„‰£ám"ttq‰®­vgzv000"Nqvu"qh"tgfwpfcpv"rtqeguvi€„Nn®!Ns|ƒ@¯æ!til…Ž¤áov$x‚£åtwh{w111#Orwv#ri#uhgxqgdqw #surfhvug||>Nn Mqx{0¦ sgh}~„¡îu"tzƒ¥óukpi"qp"{qwt"gpf."yjkng"uwrrn{kpumvw@¯î!{s}‚@¥îe.$x‰¬å!uyx€Œ¹éovlqj#rq#|rxu#hqg/#zkloh#vxsso|lqtkro0® zqyz0…®ä-"{pyŒ¥ twtx|™©îi"cp"cvvcemgt"ykvj"58"xctkcpv"eqi$i~@¡ôucgsu’`÷jvl(CV`öbtmi~”`ãpj#dq#dwwdfnhu#zlwk#69#yduldqw#frh"ev0´ôbeom‚@·éuj$;F@¶áskev„@£ïrkgu"qh"vjg"ucog"vgzv"//"kh"vjg{rmmƒ@¯ æ!vlm0“¡íf"xmˆ”`­."mn0”¨åzslhv#ri#wkh#vdph#wh{w#00#li#wkh|qki{0¦ uji(ƒ­å!vi€„@m­!kj(„ˆ¥ù"ecp"fgvgtokpg"vjg"ejwpem"uk|g"*"gi~@¤åugvuyŽ¥ uji(sˆµîdm${yš¥ )#fdq#ghwhuplqh#wkh#fkxqfn#vl}h#+!eev0„¥ôftqq~…`ôig$kx•®ãl"wqŠ…`¨cpf"fgrgpfkpi"wrqp"cniqtkvjou."vcrl0„¥ðfphq~‡`õqqr(qŒ§ïskxp}“l udqg#ghshqglqj#xsrq#dojrulwkpv/#wbph(t…°åofmvw@µðpp$ i|‡¯òjvluƒL`ôjg"gpet{rvgf"vgzv"oc{"ujqy"uqog"ji(uŽ£òzrxmt@´åyv$uq™`óiq{(ƒ­å!kh#hqfu|swhg#wh{w#pd|#vkrz#vrph#ig$m~ƒ²ùqvil0”¥øu"qi‰@³èpy${¥ dqwpfctkgu+0  QT"ku"gcej"qh"vds}~„¡òjgw1>-J SZ0‰³ fcgp0¦ uerxqgdulhv,1  RU#lv#hdfk#ri#wcqyvt²éfu-6*MŠ QV(y“`åbel(†`ôjg"58"uwrrqugf"vq"dg"yqtmkpi"qp"ji(CV`óvrtwƒ…¤ uq$ju@·ïsmmvw@¯î!kh#69#vxssrvhg#wr#eh#zrunlqj#rq#ig$;F@³õqrs{u„`ôp"fm0—¯òlkro0® c"fkhhgtgpv"ejwpm"qh"vjg"uqwteg"c$ly†¦åsgr|0ƒ¨õom$wv@´èf"ww…’£å!d#gliihuhqw#fkxqn#ri#wkh#vrxufh#b"hqv†¥òfpx(sˆµîl"sn0”¨å!us}‚ƒ¥ //"uq"vjg"qwvrwv"hkng"ku"vjg"uco/1(ƒ`ôig$w…”°õu"jq|…`ét"xpu@³ án00#vr#wkh#rxwsxw#iloh#lv#wkh#vdp./${@´èf"s}„µô!hmtu@©ó!vlm0“¡íg"uk|g"cu"vjg"kprwvA"[qw)xg"uvkng${yš¥ bu$|x…`éory|O@™ïv)zm0“´émh#vl}h#dv#wkh#lqsxwB#\rx*yh#vwlof"wqŠ…`át"xpu@©îqwxG0y¯õ(xi(ƒ”©ìn"iqv"vjg"rtqdngo"qh"jcxkpi"vq"rn$o”`ôig$x‚¢ìfo$wv@¨áwkro0”¯ qo#jrw#wkh#sureohp#ri#kdylqj#wr#sm"kw„@´èf"tz‚¬ån"sn0ˆ¡öjpk(„`ðtqfweg"vjg" qwvrwv"kp"ugswgpvkcn"tsl…ƒ¥ uji(•´ðvv$q~@³årwiv„‰¡ì!urgxfh#wkh#rxwsxw#lq#vhtxhqwldo#sqh}s…`ôig$w…”°õu"mv0“¥ñvgr|y¬ qtfgt."uq"vjgtg"ku"nqvu"qh"yckvkqvlu’l tq$|x…²å!kw(|´ó!qj(‡©ôjrughu/#vr#wkhuh#lv#orwv#ri#zdlwlpthm‚L`óp"xpu’¥ ju$t”³ ph$q‰´épi"hqt"qwvrwv"vq"dg"cxckncdng0 pk(v² pwxx…”`ôp"fm0¶ájnej|…n qj#iru#rxwsxw#wr#eh#dyd lodeoh1 oi$n’`ïvvt}„@´ï!di(q–¡émcftuNMŠ @Yjcv"K"yqwnf"nkmg"vq"mpqy"ku"Fgˆ¡ô!K$•¬ä!nmsu@´ï!mrw‡@©ó! AZkdw#L#zrxog#olnh#wr#nqrz#lv# B_x´ J"{w…Œ¤ mkom0”¯ lps0‰³ kh"uqog"qh"{qwt"ogodgtu"ctg"hcokkj(ƒ­å!qj(‰µò!oiur…²ó!cvm0†¡íjli#vrph#ri#|rxu#phpehuv#duh#idpljh${¥ ph$•² ngqju’³ bti(v­énkct"ykvj"vcumkpi"cpf"eqpewttgpvnmi‚@·éuj$|q“«éoi$i~„`ãppg}‚’¥îuoldu#zlwk#wdvnlqj#dqg#frqfxuuhqwmkez0—©ôi"xiƒ‹©îh"evt@£ïoeyz‚…®ô"rtqitcookpi"uw hhkekgpv"vq"dg"cd"tz‡²ánomvw@³õghmky…®ô!vs(r…`ác#surjudpplqj#vxiilflhqw#wr#eh#de!rvww’¡ínkro0“µægkgquŽ´ uq$ju@¡âng"vq"uc{"/"[gu."kv"ku"hgcukdng"ni(„`ób{$50y¥ó-"m|0‰³ gge{y‚¬å!oh#wr#vd|#0#\hv/#lw#lv#ihdvleoh#mg$|@³áz"1(i…³¬!kx(y“`æfcwqrŒ¥ cv"ngcuv"cpf"ikxg"cp{"qvjgt"cfxkcx(|…¡óu"evt@§éwg$i~™`ïujiz0¤öjdw#ohdvw#dqg#jlyh#dq|#rwkhu# dgylbv$tu³ô!crl0‡©öf"ev‰@¯ôigv(q„¶éeg"{qw"oc{"jcxg"vq"qhhgt0 @  ei(‰µ nc}(x¶å!vs(†¦ås0N-J fh#|rx#pd|#kdyh#wr#riihu1 A  dg$•`íb{$pq–¥ uq$wv†¥ò/F*MŠ Uwtg"kv)u"rquukdng000"Dwv"ku"kv W}‚…`éu)w(€³ójdpm>Nn Cwx(y“`éu Vxuh#lw*v#srvvleoh111#Exw#lv#lw Uyzu@©ô(u$x“³écni6>N`Âvv$qƒ@©ô"ghhgevkxg"cpf"wughwnA"Rtqdcdn{""inv…£ôjxi(qŽ¤ vuin…Œ Qtsjq‚¬ù!#hiihfwlyh#dqg#xvhixoB#Suredeo|#!gjnuƒ´éwg$i~„`õtgj}|_`ÐsqfirŒ¹ pqv0ps|>qrw1oqx6 -=-=-=-=-=- -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/