ÿØÿà JFIF    ÿÛ „ !.%+&8&+/1555$;@;4?.451 4,$,44444444444414444444444444444444444444444444444444ÿÀ  á á" ÿÄ     ÿÄ ?    !1AQaq"2‘¡±ÁðBRbrÑá#‚’¢²3S CñÿÄ   ÿÄ !    !1QAa‘2ÿÚ   ? 5˜Z¯V¦cø)›t/? z¨±>Õ5€¶‹Á¤·¼z¼Ü¬+ñ®v¤¨_ˆR­BFn©—˜ý®ç̝P8gýt·ÉSTŦˆìät?þé¼íìN/Þa)ì–í6ô… Ï¿øÃj´¿KÇü]ÿ ªô¹-eKànëÕHTx}ýSÜ›ÿ ”7Ø×&µ<¦  ¥ÑO¶[Ù¯ä¨ÞÃÿ PZ-¬;#õ|•oaÿ ©CìÞz3˜öː/¤­ñTûIØ}š^ mÓ%ªxˆ¥ÉŸu=Z+ISe¿45™¼u;ú&WØ÷€æßQ™®{|íx*TC“#ZŠìZ§²‹ 6pv…³¿¡äª*áZÐ%ÒOáˆo"x«OHk w±æ+¬V(kMúŸ5Vö«$ ÁrÏbàb57/luR ¸ÑÛj Òµì`Мq­û žICÀÊ•©4€Âcà¨Ï€O´<èÐ:›ù(Ë^L8þ‘ÍÌ#¸Ð_Ì©ÙK(Öz 4¬û+¸;ü’V’84‘¬ÃŽ:[â‡ÔÌáõp¢~§ªlæ£ö{®G>J¼"°‡7¯ÆÉèßû ‹É‹§ÁòÃýâßî ^ƾÙõ‹×óH#«LP½ïX=xÑÍ$|W?•~• îëÔ©ª‹ {ÝT…Kÿ ”hûâá)J*ö˜–ÔU;iÇ€/ ÆþjóZ\ýwØ=Ìm ºèËL9 ýèÆð/¨’¥öo=nË.%Îì ŽÕ¯È|{Oj²ƒE6e/ßdÄõ²Ìâ1O®ò×TsəԸhOMýíMˆ¿¼H˜l²,7Â¥#MF/Úf°Ö½± ¸–dr‹NýÊ íjqx{œÉ ä-È ¦ øÄër¨q°ð †nцýÑÄÆ’mä…n<0È™;ÁÝá¯ÁZƒ7FÀmì­ É&9ˆîéi¶ùN§Y• ÃZãAâ?•‡©‰ , ó¾IŸŠc1 4â&y­&pŠ­6;M À 0¹qç»p.á …ŸÅáK@%6·y6ƒ‰3?”úºŽ‰éX5ªPT §µ!=Mž«Ú½‹ÅgÂSâÉaþÓoö–¯ÁÔìR>5éÿ üs¶ÆUcÌ kÇR ]ÿ ù¬¼«VŽ;Â|‡~¢¦”ÏŰæ {L™Õ°Óv¹ò¸írޡעCÃ!íVÕ {¶»sŒNPg/ "uÕbkm²“$ďå¿é¹§°½æz¯6 †s¿!s–wÚÝ“™Œ °.ûj>·+™Òa…©Œ&rÝÎtÛë긪Ît’LAVp%c Úý[ÄzJ¾ÇàXXç@˜ó<êL]·T˜¾¥1Ó©V‡g´æ½¦Ý@¹óø!_@´ÞâSÁ —S3™•& ]@JHÚý©ZŽ €×æÔr»Áf!‡yÞ4Mv*èÓã_{‘åóUuљØ«Oïé*®EvÑ Œ÷‡U \"㪒ÍK+À 4“M¡ï:0¥5í!'<@î´”>Ç»&Z–ïCCV˜Ì5Šo&îhè.žû |ÓK©h$s6KìŒëã)¹hI¦GïOåóI;ììü#É$Š0…Ææ¥TØ.5­¾gn´ “ÂÖ\:hœ89G)J@„}œ:’Ò{/Š"¦_Æ×7Æ3VÇŠÊa]ÚŒÙ€Ä–=®uÁßâACZƒ§§£ Qnâ:«,×{tyø¬iÛcœÜÄ€H½ÄÍCk´÷šß .W'b¤Íåh]÷€=,Žv×cÚEÚHXJX¶îo¨FÒtèöŸ>ªª6[J®Fµ£sGÁeqõfe\íjÒÐïÄÐGˆe1Ø‹.Ø”‘Ëuø Y­ˆÜ ŽG|zùªüMpDnQWÄ”%JŠ™)â*p@Örš«ÕT2Ð%ˆG#ª„ ·¤!°ŸOTÂT¸aÚ%4&h™LµšØüÐ.F¿²ÐÞ_Ç‚¾ÅÃaÜ÷09Æ q€öy˜v‡85õN÷]¬äѼóS{°_MެúÔ#°Ç¸0åÞè2ëôPcvÆw9®ií1Ä8F™˜à‰´+‰Ik1òÝ7“Ñ×ÒsÝ\x‚h`ÞÑ`ó"|µEcý£n˜h`}GÞ !±ù²Ápü²ß6 0ïi󜵩SÈÇ7˜-ÕURO˜¦´f$ªž-Í6(œ}<„ éc øs]ŽŽ„*—¾ ìdŽ„)méª\¿êÎIg¾ØÞ~I#C/¼¼´EÁÈŽi8“©õådô·>euä ƒ'Ê×लR1ÉJE1ÐAát`t;ÇР%Ý<‡¥„ÍÆ`×Oyó)õiI€ñQaŸ4Ûù\áàaÃÔ¹HÃu¹*k€¦<„e S‡&õÏ B!ŽhüÞ`yj}mªf×\¿ Ç~æ­9‡û\՞Ǖg²1Žû5V7 !àöšm° c`ܬøÇìµÒ'P"?…´Ö,"§^•õލsÔ)6˜sæéÍR¼ ò|Sl”‹7 nPW Gòú÷½§O¯‡„l¡kSÞŒr½PÊ@æ¢pŽ-mÿ #Ÿ˜Àº¶Áä¦;ïÔæ$1££`“Õ>„—·ž)ßð³ñ#Ï Ô$¶œ‰ÊE‹À;÷º ¯«P:Ñ”8–IÊtpÞ3ª“>ê“þës4ò2OÏÕ­±zô†Õ§‰.÷ä¸;¿˜“'œ›žª}«Œ{ª±Ì 9ÔóÞÕ‡0 $íWV3Üì¬ —@kÝ4@¿r¼±½¬™›?øØæ´'Áé®CË3-g$˜ö‡×auÚi´Žp/êÛ æF›Ú2v‹ã¿¿,nB1̨ƃqÞa5͝@&Æû“él÷ \C²½UÍc ¯k×¢U ÖéQå™—-r wô ÞÏ<Ò=&=ÿ Ôê Òêˈt,i—;LîÜ á¸*ÚÃ1$êL•LÍ <É)ýÐà’ ;F™{ƒ™˜€&'}‚ãÄK`¡ÞT@I;®žZóè‚s’7®°›+§O­Åq©é»²9<Ô J ¼9O’HL»Ùïì¸rk¼Ž_ý‘TŸu[²ßÚŒ·ü÷B%¯E ŸÔX5êO´ Ç•€’I0 ÉJX` ñ¹õ%;µŸD‘«´€àwÒ™U ûئžÖö\×®×´8 ½‡ºÐÆÓ§?Àkmœ=;d5*@-ì0F Rªýš[Ü6âö̃ڸr*KA9· u*µæ£?U¸Âêí†8@¦X4 e-ò„0s{ HâUpU?¼mñRa°®a%Ð'tÉ×’\¾ÊÉ]t›h>·(Ë@R¼¡Ãt h}’O÷au<+nT…Ö…MӐ??Óe95 q>í/;&JSû °¯ÊéÞ øƒ*Ã2½Ài&:nôUl=¾¿5eˆ3”ñc|Ú2V”>„»&eE;«ÚäC p¢Û úy 9š[ŒÌx¼擼A&DåÒ¯ˆ¤ÀÌ;"˜ ÏQä¸åhÊ}Ûq«Û0WžÒ|»€ø®öCm5•\ÇÀ§Pe3£]0ÃàLDÉ‰1øªxjgwT‚÷¿LΨK‹›ùs—xˆÜ±µ kæ¸f‰‰ÜGk/LÛØ6d9ò¶ùA{ƒA3š/¬D¬khÓk‰`˜"㯒r¿±Óã jx‡°e}<Ñø\3y:'À•/h½Í€Ç4~g ?Û(¼]v‘ªlKÎâ~?O‚W%{Ì:“'©úNq¾›úo(X’¥¯ˆ nFê{Ç€ü?º'ë ø‹ì Þ09ŒÌç9Æ —ËC`j@ÓÄ(+a‹un¸#ÂꟋ{K`‘ÑÍÍ'à´»/Û,KW;Þ4²þð ï Nm|~fGÏ(…³Ã)«1ö­Õ ¥‡¨©ƒÃ™ü-s=à=U66Ï«Ýc蓦W¹íž®›nÔ%êÇìŒ<#Ü×84ån®Ð ÒåOC` ñânÑs‡¢ç 1õ%Îhì½Ã½® e:ݼUZo™`  ÅZŸŒÊ«ê1ÏÄo$q¹Þ€©ˆhÐÉä¯ñ[!…Ú˜àJ:x2$Íß&PåT£6ç— ‡Í*4Ýšçjÿ ‰É nófÐ ó(L5C•åÆ\rMÒ@ò }y-W}™üýVù—ú¢=Ù”c®‘< M ž ´Phr ¦©TD ‘ù.$´÷O‡‘V2Æò.=IUŒ=ž‡â¬i™aþÓåÙ?òUø'ØÖ•.~* šTŒ!•-×áºTâ®ä#õü'´ eýlYÅÓeÕKÂrT"CÚ@u!Óxƒ{š3€}1¿(r}%«nËamjÑ%ÑNEò v ˜à  σöK³,*º.àzù¨™Ó ÚçâU¦*¿ 9{%Ö¹ njûdaXöb) kÛÆ±ûÓ\°M7ˆÂ=û›ç¿Ã‚­V»Cg–8ÙêE- j)k$º`Ã-ùEýeBÆÇ]c¡°ñty&Òd0nõ'¡W+ƒ*|–øµFa\GQªEAÔp5\Ǽ·¼Ç8·õ -â§Ú[ ‡ uZeÖ 3}×d'+¹:ð+K†Û®s!Ï$úe€<Û”x)1»a­¡LC]¸µík…ÚàA»AYº{†ªS[¦5HÒ7ù --,ísòDØ€èk ÞÀîÜ ò@â( ËNˆë›4ô½•/¦o‡€Û7 ê•ÆêòðÜy'Án½µ á˜ݦ ndeo…[ì¶Ê,¥R³Ä=À±—–ß;£™´ñSâ*g§”ïaið‘Jå~™ÓÞ ß³Õ¢»8x埒²52>AÊb&-÷\7´éÄù€T˜,w;3{ï˜k…à¹ÄqÀ«œ{€\ ˆ¾[´¨јr &Úé„Ívˆ±8†¿]|¬ņ4I×pÞS1ÈÖz‰#Ìv‡G!YNògñ:màTz¢Ý1ô©^O=~ë|5Bã™ç•¼µõ•bÆ@úÕS¬ÈŒ#¬zünrŸ û” Z²•èðV"ÁHÚý©wÝ €7¼Ìu1hÑa3Éä û f$o¿É ™Ú›ÝçnpÒ3äÌ3†Í§,Äï]$‰/pê †«À¼¸e9­Æê_C]žƒ·ý·frÁN«, E=›Çq -‰öŒ:aÏ¿±í&£Í:-} 84‘ÿ eƒQÑeëSsuiA ³g㟥ú£?ÿ ʼn*”“÷aühe:ÊWa@ÒÞk±eØ] F Ô—r.åä˜ @ö¥ªZoÐýYL·¥S²G/‡ñ <~*ZÆ´è>JlòàÛÆ½ÿ 窘ìGN¢:I®KšJp/`íIÁÀõ#Ä-€ö­šµŒoF4|ÆQØÆ@Ì|£Ô…¢À{9˜è½Üó›€ôYÒÎYsið;ís¤€à²ˆ‚4qÉVŒI$ ‰"° æµ8cXGjœˏ¡Aâý•ËÜ¢ûï e·çLx']á"oÅÎê3¯Ç—¹”ó0nå‚âg{Œñ> S´˜îè°g238‚ãköÝfÚd´6Ò€;ò÷±¢™¼›º ¢Æ'¥Ðx'e¬ç ]bÈÆV¢ó‹kýBO ðÊâ$Ÿ!×T 3Mýמ žìٍàÌü‘8÷€àæØ8æ©6‰©L´«…oãpð„~Çk‰!ñ;‹”ÛžÍ àž±z Ÿôû øŸÝužÏ;ÿ #|u6™Þ¬ÚˆÐõA4¶â|ôl|Ê2ŽÇ¤ÝÅÇY.<#Aí.k§hóF‚”Y; M½Ö4hŸ4&›­¿tès´%FìL¥£Ãk‰ÇT¤haÁ¤ÚxfÉ`ÑìË›>i 3t‚:,–+^÷´–{Û–Nxi"x‘Ûg î¨>¥Õ܁ùZH,2Û“:8xÊ¢Çí9.É-Ìâã-=çjwµS˜dütžçwýGòú®®ûº_ˆýx$–¡ãøO EÚÛÏ÷R„×w+3£Á£öUMyR²¹âŒ°š›¸Ñãò9§Ó_Dl+Ùßc›úšGÅÌc†Ž!Ko=¶.‘Îÿ c²(2®V mª.ÿ ¹B›¹å ù„öŸSV>™ü¯$y:G¢Z×àøúdî¹û­·ýÇ´:•c LÍõi_‹ö+ÎæGÊè>OŠ•äž´§Þ{X}¨1ÚTc›»Qþ•êô°t¿OP?eæ~É{5]•ÙR£r5†nZ\ã@ &îJõ ¾àC°þV>fé¥/ü5ñÊIº_é5 ;e­h<@ Ä&æÃëE%;X,ÒãÆÞ`Oò¦kŸm#˜!ÀyÄ¢| óLšò¥Ä` ¶R=|ÈCâh5ò3DˆïF†ðÒ#ÅìÛœ?¸yhBãœí ZxßÎÄhºRK„`Þödvײ™ÀÈÑÒgŒuY w³%†ƒÓzõ ÖÏp‚dH®¦A´ù§»ÓÇMæ~)ˆð‡û:ù&Ä •vGD´À n ݇¼Ö8Fö óáà£~Ë¥x`oK|Ä?fxiØü%pìR>éò+Û±éÎ>núlFŤ'tq8LZÏvÃ?„¡ß±È⽆¯³íü@x|PöUäèØã¡ð‚ŒAìÏ"vÍwóŸÍ{ ý0.z È•Ö{,N¡£¡ŸKÕÙž>Ýœþ ÍÀ°<×EA!Å‚D™IúOÍ¡>ôG}Â` ÍßkÜL™Ž Þð™ {IøF²¹òQ3&!ÃÂÞz.d&Ï-sH¸,Ôõ˜ŽP€ 77ˆÝ¼ÊëÜw =cÕ Ú,ØÐ5ÎYÐ)ì´öœgŒ[¤ßv㙑8心>h]§µháYš£²ºÑ.{Ï7Sð•?´~×SÃKýJÛ˜ ™Íäiúu<µX¶1õ^kâçIÑ£sZ4h>j*ÔšD:4­¿_ ÷¸ Õxæÿ ¸?Mù _•­ÊÐ ä ÷ý ÑwL œ­ïnTkÛUÍN©ë:¦fV ¶ÜÔÜMªÅâA½–¿R×TXš-%iTÊT•‡Ù‚JôϐZxWÑè‰f‰òG º ×Õû2aZ7OU3[“×AT–ÞŒ…-‘¤”Ì ì&(ˆ¿­•ƒkï’:ðY¦W‘ Å)“†‘˜³Åtcø˜ñTÂwÚÇ4|üLÇªí–v- qˆèU qPE.†â‘˜µ Æ,ÐÅs]8¾„oúÑ i>ÜxxÈó)ƒ ´æÁâØ$À‰vžŸf$Ž |ãw;ÀÁIJ»b` {¦Ó¤Ú$©YÀ‘n@Óïž«9J¼êG m¤ ܯ¹ÌW4€ÐÒÅÛ‡#褕Ÿn-?í|с¥÷Ú¹¬'´ÞÜ9ÓK `hê£SÄSà?7—Wí_´…óB›»:=Ãïq`<8ñÓŒÑlú2d¬ê³£hÖ[l|$vÝro~'R®‰§°ñmY ͧäP |PUª¹·:3Œ[Û{Xÿ ºâ@‚W–Äé u‚ ¯´*=íή.pûÒdt @G‰¬ s¸ ëÉücr ÞæÑ¨Ê@>¤¢Ö±. Þ'¯°ÌME[YéïĵÂCå½ Ué©Áû'Ê9%eÔðNU”ë‘ÌsD3/®+UI˜9h.WC”빓$#:pz:YÓ ¿xž* ³$Í +$kñAŠ‹†¢ Uê>¸)_š¬÷©ßAÂÔb9ÇU ¯¾á•9¯ÏÏ÷O÷¼¼Fähal1‰3Ì[Ïr•´UCksNÐ] R‘¸¥H+§Šé†c©vÖÞ0iÓ76s†î!§=ß ¼~Ô'°Ãmäoäš³ªøi1úÉ)³yV8 CLÄØÁ‘WYïi€H6ÖÑiámø^ÈY´°Ñ7¥Û*—Ñ©L«Qƒï—Ùrÿ ›£Ð*š¸ˆL©ˆ$ˆ ÷¾D§9È®«qbqC)–ˆïv´çñsÑVT­Ø, <àïºÀO«Jý·õ àfPìð .wFšir´þ’2_Y *Æ€x\« ì€9š@ Ž|F⇥ˆkZ@hÖÄ0t¿-<“‹qµ¾*ZL¤Ú)&BJpÓF5=$„at*Zš$’ÑtdûÝRI1 2މ$€$I$#‰SÞ’Hë¬ï;Á$¡t$’`<(ñÇt)$‡Ð.Êf¢X’Kt=Éé$‚ˆªè¢oÝëòI%Rgcª÷ŠyI%¡‰ÿ !ñ)´õ $¤ Ô’IIGÿÙ  jܚ dZddlmZmZmZmZddlmZmZddlm Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZddlmZdd lmZdd lmZmZmZmZmZdd lmZmZdd lmZm Z m!Z!m"Z"m#Z#m$Z$ejJd kr ddl&m'Z(e)Z*dZ+nddl,m(Z(dZ+ejZdddddZ.dddddddddZ/dddZ0e jbdZ2iZ3ddZ4Gdd e5Z6Gd!d"Z7Gd#d$e5Z8Gd%d&e5Z9Gd'd(e6Z:e:Z;Gd)d*e6Z<Gd+d,e6Z=Gd-d.e5Z>Gd/d0e6Z?Gd1d2e9e?Z@Gd3d4e?ZAGd5d6e?e7ZBGd7d8e5ZCGd9d:eCe9e8e?e7ZDGd;deCe9e8e?ZFGd?d@e9e8e?ZGGdAdBe9e8e?ZHGdCdDe9e8e?ZIGdEdFeIZJGdGdHe?ZKGdIdJe?e7ZLGdKdLe?ZMGdMdNe?ZNGdOdPe?ZOGdQdReBZPGdSdTe@ZQGdUdVeLZRGdWdXe6ZSGdYdZe6ZTGd[d\eSZUGd]d^eTZVGd_d`eSZWGdadbe@ZXGdcdde@ZYGdedfe@ZZGdgdheGZ[Gdidje@Z\Gdkdle@Z]Gdmdne]Z^Gdodpe]Z_Gdqdre@Z`Gdsdte@ZaGdudve@ZbGdwdxe@ZcGdydze@ZdGd{d|e@Zed}Zfd~ZgdZhdZidZjideAdeBdeDdeGdeKdeLdeMdeNdeOdePdeWdeQdeRdeSdeUdeXdeYeZe[e\e^e_e`eaebecedeed ZkddZlddZmy)a ASN.1 type classes for universal types. Exports the following items: - load() - Any() - Asn1Value() - BitString() - BMPString() - Boolean() - CharacterString() - Choice() - EmbeddedPdv() - Enumerated() - GeneralizedTime() - GeneralString() - GraphicString() - IA5String() - InstanceOf() - Integer() - IntegerBitString() - IntegerOctetString() - Null() - NumericString() - ObjectDescriptor() - ObjectIdentifier() - OctetBitString() - OctetString() - PrintableString() - Real() - RelativeOid() - Sequence() - SequenceOf() - Set() - SetOf() - TeletexString() - UniversalString() - UTCTime() - UTF8String() - VideotexString() - VisibleString() - VOID - Void() Other type classes are defined that help compose the types listed above. )unicode_literalsdivisionabsolute_importprint_function)datetime timedelta)FractionN)_teletex_codec)unwrap) OrderedDict) type_namestr_clsbyte_cls int_typeschr_cls)_parse _dump_header) int_to_bytesint_from_bytestimezoneextended_datetimecreate_timezone utc_with_dst))StringIOT)BytesIOF universal applicationcontextprivate)rr rr"r)rrr r!rr r"r primitive constructed)rr z ^\d+(\.\d+)*$c0tj||S)a5 Loads a BER/DER-encoded byte string and construct a universal object based on the tag value: - 1: Boolean - 2: Integer - 3: BitString - 4: OctetString - 5: Null - 6: ObjectIdentifier - 7: ObjectDescriptor - 8: InstanceOf - 9: Real - 10: Enumerated - 11: EmbeddedPdv - 12: UTF8String - 13: RelativeOid - 16: Sequence, - 17: Set - 18: NumericString - 19: PrintableString - 20: TeletexString - 21: VideotexString - 22: IA5String - 23: UTCTime - 24: GeneralizedTime - 25: GraphicString - 26: VisibleString - 27: GeneralString - 28: UniversalString - 29: CharacterString - 30: BMPString :param encoded_data: A byte string of BER or DER-encoded data :param strict: A boolean indicating if trailing data should be forbidden - if so, a ValueError will be raised when trailing data exists :raises: ValueError - when strict is True and trailing data is present ValueError - when the encoded value tag a tag other than listed above ValueError - when the ASN.1 header length is longer than the data TypeError - when encoded_data is not a byte string :return: An instance of the one of the universal classes )strict) Asn1Valueload) encoded_datar&s @/opt/nydus/tmp/pip-target-mjwu0ny1/lib/python/asn1crypto/core.pyr(r(ssf >>,v> 66ceZdZdZdZdZdZdZdZdZ dZ dZ dZ dZ eddZ ddZdZdZd Zd Zd Zd Zd ZdZddZdZdZddZddZy)r'z' The basis of all ASN.1 values NFr+c t|tstdt|zd}|j|}t ||||\}}|S)a Loads a BER/DER-encoded byte string using the current class as the spec :param encoded_data: A byte string of BER or DER-encoded data :param strict: A boolean indicating if trailing data should be forbidden - if so, a ValueError will be raised when trailing data exists :return: An instance of the current class *encoded_data must be a byte string, not %sNspec spec_paramsr&) isinstancer TypeErrorrtag _parse_build)clsr)r&kwargsr0value_s r*r(zAsn1Value.loadsS ,1H9UaKbbc c 77 D 4VTZ[q r+c  |jtvrl|j} | j/t| jdtr| jf| _t | dr|j dt| <|!t|tr|d}||f}|dk(rd}d}|!t|tr|d}||f}|dk(rd}d}|6|d}|dk(r||f}n(|dk(r||f}nttdt||t|d k(rt|d tr|f}|D]\}}d} t|tr |tvr|} n|tvr|} t|}| ttd t| |.t|tsttd t||j ||ff|_|j||ffz|_n|x|\}}|tvrttd t||.t|tsttdt|t||_||_d|_nR|4|tvrttdt|t||_|jd|_|||_| C| t%gdvrttdt| | dk(rd} n| dk(rd } | |_|rd|_| | |_y||j%|yy#ttf$r=} | j*d d}| j*ddt|zzf|z| _| d} ~ wwxYw)a The optional parameter is not used, but rather included so we don't have to delete it from the parameter dictionary when passing as keyword args :param explicit: An int tag number for explicit tagging, or a 2-element tuple of class and tag. :param implicit: An int tag number for implicit tagging, or a 2-element tuple of class and tag. :param no_explicit: If explicit tagging info should be removed from this instance. Used internally to allow contructing the underlying value that has been wrapped in an explicit tag. :param tag_type: None for normal values, or one of "implicit", "explicit" for tagged values. Deprecated in favor of explicit and implicit params. :param class_: The class for the value - defaults to "universal" if tag_type is None, otherwise defaults to "context". Valid values include: - "universal" - "application" - "context" - "private" Deprecated in favor of explicit and implicit params. :param tag: The integer tag to override - usually this is used with tag_type or class_. Deprecated in favor of explicit and implicit params. :param optional: Dummy parameter that allows "optional" key in spec param dicts :param default: The default value to use if the value is currently None :param contents: A byte string of the encoded contents of the value :param method: The method for the value - no default value since this is normally set on a class. Valid values include: - "primitive" or 0 - "constructed" or 1 :raises: ValueError - when implicit, explicit, tag_type, class_ or tag are invalid values Nr_setupTr explicitimplicitzh tag_type must be one of "implicit", "explicit", not %s r"r z explicit class must be one of "universal", "application", "context", "private", not %s zi explicit tag must be an integer, not %s z implicit class must be one of "universal", "application", "context", "private", not %s za implicit tag must be an integer, not %s z class_ must be one of "universal", "application", "context", "private", not %s )r#rr$r z method must be one of "primitive" or "constructed", not %s r#r$ while constructing %s) __class___SETUP_CLASSESr<r2rhasattrr; ValueErrorr reprlenCLASS_NUM_TO_NAME_MAPCLASS_NAME_TO_NUM_MAPr3rclass_r4r=setmethodcontentsargs)selfr<r= no_explicittag_typerGr4optionaldefaultrJrIr6 invalid_classerKs r*__init__zAsn1Value.__init__spT ~~^3nn<<+ 3<<?I0V$'LL#3CL3)KKM&*s##h 2~!* &1Hz)#HC#h 2~!* &1Hz)#HC#>&Fz) &}H+ &}H$VX &#x=A%*Xa[)*L (|H#+KFC$(M!&)4!)>>,2M!)>>,2M!6v!>$0( !/ *)#y9"+F!$!*# -# }},*0#(9 (, &#8I(I 9$,<%& !66$VV &?%c95' &cN ) 4F;  $ %%::( !L *#8"?DK;;&"#DK?"DH!%G!HH$VV &[(F},F$  $ # ( $!%I& 66!":DffQi"?)D/"QQSVZZAFG sK>LLM"%8MM"cNtr|jS|jSz Since str is different in Python 2 and 3, this calls the appropriate method, __unicode__() or __bytes__() :return: A unicode string _PY2 __bytes__ __unicode__rLs r*__str__zAsn1Value.__str__# >># ###% %r+c tr5dt|dt|dt|j dSdt|dt|dt|j dS)7 :return: A unicode string < z b>)rWridrCdumprZs r*__repr__zAsn1Value.__repr__sN $-dORXtDIIK?PQ Q $-T?BtHd499;>OP Pr+c@|jjdS)z A fall-back method for print() in Python 2 :return: A byte string of the output of repr() utf-8)rdencoderZs r*rXzAsn1Value.__bytes__s}}%%g..r+c"|jS)z A fall-back method for print() in Python 3 :return: A unicode string of the output of repr() )rdrZs r*rYzAsn1Value.__unicode__s}}r+c|j}|j|_|j|_|j|_|j|_|S)z Constructs a new copy of the current object, preserving any tagging :return: An Asn1Value object )r?rGr4r=r<rLnew_objs r* _new_instancezAsn1Value._new_instancesC.."hh ====r+cf|j}|j|tj|S)z Implements the copy.copy() interface :return: A new shallow copy of the current Asn1Value object )rl_copycopyrjs r*__copy__zAsn1Value.__copy__s)$$& dDII&r+c|j}||t|<|j|tj|S)z Implements the copy.deepcopy() interface :param memo: A dict for memoization :return: A new deep copy of the current Asn1Value object )rlrbrnrodeepcopyrLmemorks r* __deepcopy__zAsn1Value.__deepcopy__s6$$& RX dDMM*r+c,tj|S)z} Copies the object, preserving any special tagging from it :return: An Asn1Value object rorrrZs r*rozAsn1Value.copy}}T""r+ct|ts||i}|j|jd|jd}|j |t j |S)a} Copies the object, applying a new tagging to it :param tagging: A dict containing the keys "explicit" and "implicit". Legacy API allows a unicode string of "implicit" or "explicit". :param tag: A integer tag number. Only used when tagging is a unicode string. :return: An Asn1Value object r<r=)r<r=)r2dictr?getrnrorr)rLtaggingr4rks r*retagzAsn1Value.retagsS '4(nG..'++j*AGKKXbLc.d dDMM*r+cf|j}|j|tj|S)z{ Copies the object, removing any special tagging from it :return: An Asn1Value object )r?rnrorrrjs r*untagzAsn1Value.untag/s'.." dDMM*r+c |j|jk7r(ttdt|t||j|_||j |_y)a! Copies the contents of another Asn1Value object to itself :param object: Another instance of the same class :param copy_func: An reference of copy.copy() or copy.deepcopy() to use when copying lists, dicts and objects Q Can not copy values from %s object to %s object N)r?r3r rrJ_nativerLother copy_funcs r*rnzAsn1Value._copy;s[ >>U__ ,F% $    / r+cd|z}t|d}t|||r|jj|dzyt|dr|jj|dzyt r>t |jtr$t|dt|jyt|d|jy)J Show the binary data and parsed data in a tree structure  parsedr"chosenz Native: bz Native: N) rA _basic_debugrdebugrrWr2nativerprintrC)rL nest_levelprefix has_parseds r*rzAsn1Value.debugSs  "T8, VT"  KK  j1n - T8 $ KK  j1n - 4;;9VT$++5FGHFDKK@Ar+c|j}|j|jdddk(rd}|j|rt|tr|jrd|_t |j|j |j|j}|j2|jD]#\}}t |d|||jz|z}%||_d|_ |j|z|jzS) Encodes the value using DER :param force: If the encoded contents already exist, clear them and regenerate to ensure they are in DER format instead of BER format :return: A byte string of the DER-encoded value NTrr r+) rJ_headerr2 Constructable _indefiniterIrrGr4r<_trailer)rLforcerJheaderrGr4s r*rczAsn1Value.dumpis== << # RS(9W(DE << 5$ .43C3C !$++t{{DHHdmmTF}}(#'==KFC)&!S&4==:PQTZZF$1"DLDM||h&66r+F) NNFNNNNNNNNr )__name__ __module__ __qualname____doc__rIrGr4_bad_tagr=r<rrJrr classmethodr(rSr[rdrXrYrlrpruror}rrnrrcr+r*r'r's FF CHHHGHHG2imDHL\ & Q/   #, 00B,7r+r'ceZdZdZdZdZdZy)ValueMapzl Basic functionality that allows for mapping values from ints or OIDs to python unicode strings Nc|j}|j |jyi|_|jjD]\}}||j|<y)2 Generates _reverse_map from _map N)r?_map _reverse_mapitems)rLr6keyr8s r*r;zValueMap._setupsV nn 88 s//; ((..*JC&)C  U #+r+)rrrrrrr;rr+r*rrs DL *r+rceZdZdZdZy)Castablez A mixin to handle converting an object between different classes that represent the same encoded value, but with different rules for converting to and from native Python values c |j|jjk7rHttdt |t ||j|jj|}|j |_|j |_|j|_|j|_|j|_ |j|_ t|tr"|j|_ |j|_|S)a+ Converts the current object into an object of a different class. The new class must use the ASN.1 encoding for the value. :param other_class: The class to instantiate the new object from :return: An instance of the type other_class z Can not covert a value from %s object to %s object since they use different tags: %d versus %d )r4r?r3r rrGr=r<rrJrr2rrIr)rL other_classrks r*castz Castable.casts ??dnn00 0F+&$""   -====,,==== dM *![[GN"&"2"2G r+N)rrrrrrr+r*rrs  "r+rc8eZdZdZdZdZdZdZfdZxZ S)rz A mixin to handle string types that may be constructed from chunks contained within an indefinite length BER-encoded container Fc@|js|jSd}t|j}d}||krQt |j||j \}}||j }n||j z }||krQ||jS|S)zc :return: A concatenation of the native values of the contained chunks rN)r0)r _as_chunkrDrJr5r? _merge_chunks)rLpointer contents_lenoutput sub_values r*rzConstructable._merge_chunkss >># #4==)  $!-dmmW4>>!Z Iw~"002)1133  $ >>># # r+c|jS)a A method to return a chunk of data that can be combined for constructed method values :return: A native Python value that can be added together. Examples include byte strings, unicode strings or tuples. rJrZs r*rzConstructable._as_chunks}}r+c|jS)a Returns a native value that can be round-tripped into .set(), to result in a DER encoding. This differs from .native in that .native is designed for the end use, and may account for the fact that the merged value is further parsed as ASN.1, such as in the case of ParsableOctetString() and ParsableOctetBitString(). :return: A python value that is valid to pass to .set() )rrZs r*_setable_nativezConstructable._setable_natives{{r+ctt| |||jr |j |j yy)a% Copies the contents of another Constructable object to itself :param object: Another instance of the same class :param copy_func: An reference of copy.copy() or copy.deepcopy() to use when copying lists, dicts and objects N)superrrnrrHrrLrrr?s r*rnzConstructable._copys; mT( :    HHU**, - r+) rrrrrrrrrn __classcell__r?s@r*rrs(K4  ..r+rcDeZdZdZdZdZdZdZdZe dZ d dZ y ) Voidz A representation of an optional value that is not present. Has .native property and .dump() method to be compatible with other value classes. r+c4|j|jk(S)u :param other: The other Primitive to compare to :return: A boolean rrLrs r*__eq__z Void.__eq__+s$..00r+cy)NFrrZs r* __nonzero__zVoid.__nonzero__6sr+cyNrrrZs r*__len__z Void.__len__9sr+ctdS)Nr)iterrZs r*__iter__z Void.__iter__<s Bxr+cyzl The native Python datatype representation of this value :return: None NrrZs r*rz Void.native?r+cy)rr+rrLrs r*rcz Void.dumpJsr+Nr) rrrrrJrrrrpropertyrrcrr+r*rr#s; H 1 r+rc^eZdZdZdZd dZedZedZd dZ fdZ d dZ xZ S) Anyz A value class that can contain any value, and allows for easy parsing of the underlying encoded value using a spec. This is normally contained in a Structure that has an ObjectIdentifier field and _oid_pair and _oid_specs defined. Nc tj|fi| |Xt|tstt dt |||j df|_|j|_ yy#ttf$r=}|jdd}|jddt |zzf|z|_ |d}~wwxYw)z Sets the value of the object before passing to Asn1Value.__init__() :param value: An Asn1Value object that will be set as the parsed value Nz` value must be an instance of Asn1Value, not %s r rr>) r'rSr2r3r rr?_parsedrcrJrBrK)rLr8r7rRrKs r*rSz Any.__init__gs 4*6*  !%3#F"%( %!&u= %  !I& 66!":DffQi"?)D/"QQSVZZAFG sAA33B?8B::B?cl|j|j|jdjS)z The native Python datatype representation of this value :return: The .native value from the parsed value object r)rparserrZs r*rz Any.natives+ <<  JJL||A%%%r+cX|j|j|jdSzw Returns the parsed object from .parse() :return: The object returned by .parse() rrrrZs r*rz Any.parsed% <<  JJL||Ar+cb|j|jdd||fk7r |xsi}t||j)d|vr|j|dz|d<n|j|d<|j|jz|j z}t |||\}}|||f|_d|_d|_d|_d|_||_d|_|jdS#ttf$r=}|jdd}|jdd t|zzf|z|_ |d}~wwxYw) v Parses the contents generically, or using a spec with optional params :param spec: A class derived from Asn1Value that defines what class_ and tag the value should have, and the semantics of the encoded value. The return value will be of this type. If omitted, the encoded value will be decoded using the standard universal tag based on the encoded tag number. :param spec_params: A dict of params to pass to the spec object :return: An object of the type spec, or if not present, a child of Asn1Value Nr rr<r0r1Fr+r while parsing %s) r_tag_type_to_explicit_implicitr<rrJrr5r4r=rBr3rKr) rLr0r1 passed_paramsrJ parsed_valuer9rRrKs r*rz Any.parsesE$ << 4<<!#4{8K#K  + 1r .}===,!]248MMMR\D]4] j148MM j1<<$--7$--G". -# a !-dK@   $ % " ( # ||A  * vvabz&&)&>4&PPRUYY sB1C""D.18D))D.c\tt| ||||j|_y)a Copies the contents of another Any object to itself :param object: Another instance of the same class :param copy_func: An reference of copy.copy() or copy.deepcopy() to use when copying lists, dicts and objects N)rrrnrrs r*rnz Any._copys& c4ui0 / r+cx|j|j|jdj|S)rrr)rrrcrs r*rczAny.dumps3 <<  JJL||A##%#00r+rNNr) rrrrrrSrrrrrnrcrrs@r*rr\sLG8 & &  0d 01r+rceZdZdZdZdZdZdZdZdZ dZ e ddZ dZ ddZedZej"dZedZd Zed Zed Zd Zd ZfdZddZxZS)ChoicezF A class to handle when a value may be one of several options Nc xt|tstdt|zt ||||\}}|S)a Loads a BER/DER-encoded byte string using the current class as the spec :param encoded_data: A byte string of BER or DER encoded data :param strict: A boolean indicating if trailing data should be forbidden - if so, a ValueError will be raised when trailing data exists :return: A instance of the current class r.r/)r2rr3rr5)r6r)r&r7r8r9s r*r(z Choice.loads? ,1H9UaKbbc c 3FSYZq r+c|j}i|_i|_t|jD][\}}t |dkr|ifz}||j|<t |d|d}||j|<||j|d<]y)zS Generates _id_map from _alternatives to allow validating contents rr"r rN)r?_id_map _name_map enumerate _alternativesrD_build_id_tuple)rLr6indexinfoid_s r*r;z Choice._setup+s nn  $S%6%67KE44y1}re|+/!!%(!$q'473C$CKK %*CMM$q' " 8r+c t|tj|fi| |jdt t d|=t |trUt|dk7r(t t dt|t|t|jd\}}t |tr@t|dk7r(t t dt|t||d}|d}||jvrt t d |t||j||_|j|j\}}}t ||s ||fi|}n t!||}||_yy#tt$f$r=}|j&dd}|j&dd t|zzf|z|_|d}~wwxYw) aq Checks to ensure implicit tagging is not being used since it is incompatible with Choice, then forwards on to Asn1Value.__init__() :param name: The name of the alternative to be set - used with value. Alternatively this may be a dict with a single key being the name and the value being the value, or a two-element tuple of the name and the value. :param value: The alternative value to set - used with name :raises: ValueError - when implicit param is passed (or legacy tag_type param is "implicit") r=Nz The Choice type can not be implicitly tagged even if in an implicit module - due to its nature any tagging must be explicit r z When passing a dict as the "name" argument to %s, it must have a single key/value - however %d were present rr"z When passing a tuple as the "name" argument to %s, it must have two elements, the name and value - however %d were present z The name specified, "%s", is not a valid alternative for %s r>)rr'rSr{rBr r2rzrDrlistrtupler_choicer _fix_taggingrr3rK) rLnamer8r7r9r0paramsrRrKs r*rSzChoice.__init__;s$ 'v.4*6*< zz*%1 "dD)4yA~( &dOI*#'tzz|"4Q"7KD%dE*4yA~( &dOI*!GE7Dt~~-$V!$ & $~~d3 "&"4"4T\\"B4!%. 1&1E(7E$ [ ^I& 66!":DffQi"?)D/"QQSVZZAFG sE$F G8GGc^|j|jjS|jS)zj :return: A byte string of the DER-encoded contents of the chosen alternative )rrJ _contentsrZs r*rJzChoice.contentss( << #<<(( (~~r+c||_y)zo :param value: A byte string of the DER-encoded contents of the chosen alternative NrrLr8s r*rJzChoice.contents r+ct|js!|j|jd|_|jS)zc :return: A unicode string of the field name of the chosen alternative r)_namerrrZs r*rz Choice.names0 zz++DLL9!4&PPRUYY s=A##B/28B**B/c"|jS)zT :return: An Asn1Value object of the chosen alternative )rrZs r*rz Choice.chosenszz|r+c.|jjS)z The native Python datatype representation of this value :return: The .native value from the contained value object )rrrZs r*rz Choice.natives{{!!!r+c ||f}|jS|jd|k7rttdt|t |t |\\}}}}}}}||f}||j vr|j ||_y|je|jYt |jdkDrttdt|||j|jfk(rd|_y|j||}|j Dcgc]}|j|d|d}}ttd|t|dj|cc}w) a Ensures that the class and tag specified exist as an alternative :param class_: The integer class_ from the encoded value header :param tag: The integer tag from the encoded value header :param contents: A byte string of the contents of the value - used when the object is explicitly tagged :raises: ValueError - when value is not a valid alternative Nrz %s was explicitly tagged, but the value provided does not match the class and tag r z| %s was implicitly tagged, but more than one alternative exists rzs Value %s did not match the class and tag of any of the alternatives in %s: %s , ) r<rBr rrrDrrrGr4r_format_class_tagjoin) rLrGr4rJrr9asn1pairasn1ss r*validatezChoice.validatesw$sm == $}}R C' dO ".4Hc(m-L * &faaA3-C $,, <<,DL  ;; "txx';4%%&* dO "t{{DHH--  %%fc2FJllSld''Qa9lS   dO IIe    TsE(c>dt|jd|dS)zo :return: A unicode string of a human-friendly representation of the class and tag [r`])rEupper)rLrGr4s r*r zChoice._format_class_tags 2&9??A3GGr+ctt| |||j|_|j|_||j |_y)a Copies the contents of another Choice object to itself :param object: Another instance of the same class :param copy_func: An reference of copy.copy() or copy.deepcopy() to use when copying lists, dicts and objects N)rrrnrrrrs r*rnz Choice._copys< fd!%3}} [[  / r+c|j|jdddk(rd}|jj||_|j|r^d|_|jK|jD]<\}}t |d||j|jz|jz|_>|j|jzS)rNrrTrr+r )rrrcrr<r)rLrrGr4s r*rcz Choice.dump-s << # RS(9W(DE)))6 << 5DL}}(#'==KFC#/3 t~~@]#^aeamam#mDL$1||dnn,,r+rr)rrrrrrrrrrrrr(r;rSrrJsetterrrrrrr rnrcrrs@r*rrs G EGIMGI*+ Rh  __$""> @H0"-r+rceZdZdZdZdZeddZddZdZ dZ dZ dZ d Z d Zd Zd Zdd ZddZedZdZdZdZdZy)Concata A class that contains two or more encoded child values concatentated together. THIS IS NOT PART OF THE ASN.1 SPECIFICATION! This exists to handle the x509.TrustedCertificate() class for OpenSSL certificates containing extra information. Nc|||S)a Loads a BER/DER-encoded byte string using the current class as the spec :param encoded_data: A byte string of BER or DER encoded data :param strict: A boolean indicating if trailing data should be forbidden - if so, a ValueError will be raised when trailing data exists :return: A Concat object )rJr&r)r6r)r&s r*r(z Concat.loadSs L88r+c<|y t|}g|_d}|jD];}||krt|||\}}n|}|jj |=|r||k7r||z }t d|z|P|jdgt|jz|_t|D]\} } |j| | yy#t t f$r=} | jdd} | jddt|zzf| z| _| d} ~ wwxYw)a :param value: A native Python datatype to initialize the object value with :param contents: A byte string of the encoded contents of the value :param strict: A boolean indicating if trailing data should be forbidden - if so, a ValueError will be raised when trailing data exists in contents :raises: ValueError - when an error occurs with one of the children TypeError - when an error occurs with one of the children Nr)rr04Extra data - %d bytes of trailing data were providedr r>) rD _children _child_specsr5appendrBr3rKrr __setitem__) rLr8rJr&roffsetr0 child_value extra_bytesrRrKrdatas r*rSzConcat.__init__es7"   "8} !# --D ,.:8VZ^._+ V&*f NN))+6 .f 4"."7K$%[^i%ijj  ~~%"&#d.?.?*@!@(/ t  - 0   * vvabz&&)&CiPTo&UUWZ^^ sA8CD8DDcNtr|jS|jSrUrVrZs r*r[zConcat.__str__r\r+c"|jS)z; A byte string of the DER-encoded contents rcrZs r*rXzConcat.__bytes__s yy{r+ct|Sr^)rCrZs r*rYzConcat.__unicode__s Dzr+c ldt|dt|dt|jdS)r^r_r`ra)rrbrCrcrZs r*rdzConcat.__repr__s$ )4$tyy{:KLLr+cf|j}|j|tj|S)z| Implements the copy.copy() interface :return: A new shallow copy of the Concat object )r?rnrorjs r*rpzConcat.__copy__s'.." dDII&r+c|j}||t|<|j|tj|S)z Implements the copy.deepcopy() interface :param memo: A dict for memoization :return: A new deep copy of the Concat object and all child objects )r?rbrnrorrrss r*ruzConcat.__deepcopy__s4.." RX dDMM*r+c,tj|S)zQ Copies the object :return: A Concat object rwrZs r*roz Concat.copyrxr+c |j|jk7r(ttdt|t|||j|_y)a Copies the contents of another Concat object to itself :param object: Another instance of the same class :param copy_func: An reference of copy.copy() or copy.deepcopy() to use when copying lists, dicts and objects rN)r?r3r rrrs r*rnz Concat._copysP >>U__ ,F% $  #5??3r+cd|z}t|t|dt|t|d|jD]}|j |dzy)rr Object #z Children:r"N)rrrbrrrLrrchilds r*rz Concat.debugsN  " 69T?BtHEF )*^^E KK Q '$r+cVd}|jD]}||j|z }|S)rr+r)rrcrLrrJr4s r*rcz Concat.dumps1^^E   / /H$r+c"|jS)z` :return: A byte string of the DER-encoded contents of the children r)rZs r*rJzConcat.contentssyy{r+c,t|jSz. :return: Integer )rDrrZs r*rzConcat.__len__s 4>>""r+c |t|jdz kDs|dkrttd|t ||j |S)z Allows accessing children by index :param key: An integer of the child index :raises: KeyError - when an index is invalid :return: The Asn1Value object of the child specified r rzN No child is definition for position %d of %s )rDr KeyErrorr rrrLrs r* __getitem__zConcat.__getitem__!sX T&&'!+ +sQw6$  ~~c""r+c |t|jdz kDs|dkrttd|t |t |t sttd|t |||j|<y)aG Allows settings children by index :param key: An integer of the child index :param value: An Asn1Value object to set the child to :raises: KeyError - when an index is invalid ValueError - when the value is not an instance of Asn1Value r rzK No child is defined for position %d of %s zz Value for child %s of %s is not an instance of asn1crypto.core.Asn1Value N) rDr r;r rr2r'rBr)rLrr8s r*r"zConcat.__setitem__:s T&&'!+ +sQw6$  %+V$  $sr+c,t|jS)zB :return: An iterator of child values )rrrZs r*rzConcat.__iter__^s DNN##r+r)NNFr)rrrrr rrr(rSr[rXrYrdrprurornrrcrrJrr=r"rrr+r*rrFsLI99"+.Z &M  #4. ("##2"$H$r+rc:eZdZdZdZdZd dZdZd dZdZ dZ y) PrimitivezO Sets the class_ and method attributes for primitive, universal values rNc 4tj|fi| |||_y||j|y||j|yy#tt f$r=}|j dd}|j ddt|zzf|z|_|d}~wwxYw)a^ Sets the value of the object before passing to Asn1Value.__init__() :param value: A native Python datatype to initialize the object value with :param default: The default value if no value is specified :param contents: A byte string of the encoded contents of the value Nr rr>)r'rSrJrHrBr3rKr)rLr8rPrJr7rRrKs r*rSzPrimitive.__init__ps 4*6* # ( "$!%I& 66!":DffQi"?)D/"QQSVZZAFG s! A A A B8BBc t|ts(ttdt |t |||_||_d|_|jdk7rd|_yy)_ Sets the value of the object :param value: A byte string H %s value must be a byte string, not %s Nr+) r2rr3r rrrJrrrs r*rHz Primitive.setsg%*F$%     ==C DM r+c|j|jdddk(rd}|r$|j}d|_|j|tj |S)rNrrT)rrrJrHr'rcrLrrs r*rczPrimitive.dumpsS << # RS(9W(DE [[F DM HHV ~~d##r+c||k( Srrrs r*__ne__zPrimitive.__ne__s5=  r+ct|tsy|j|jk7ry|jj|jjk7ry|j|jk(r|j|jk(ryt |jj t |jgzt tttgz }t |jj t |jgzt tttgz }||zr|j|jk(S|js$|js|js |jr=|jj|jjk(S|j|jk(S)rFT) r2rArJr?r4rH __bases__r'rr=r<rrc)rLr self_bases other_basess r*rzPrimitive.__eq__sR%+ ==ENN * >>  !4!4 4 >>U__ ,%..1P$..223c4>>:J6KKsT]_hjrSsOtt 5??445U__> >yy{ejjl**r+NNNr) rrrrrGrIrSrHrcrIrrr+r*rArAgs,F F> .$.!#+r+rAcFeZdZdZdZdZdZdZfdZe dZ xZ S)AbstractStringz A base class for all strings that have a known encoding. In general, we do not worry ourselves with confirming that the decoded values match a specific set of characters, only that they are decoded into a Python unicode string latin1Nc 2t|ts(ttdt |t |||_|j |j|_d|_ |jrd|_ d|_ |jdk7rd|_ yy)zb Sets the value of the string :param value: A unicode string K %s value must be a unicode string, not %s NFrr+) r2rr3r r_unicoderg _encodingrJrrrIrrs r*rHzAbstractString.sets%)F$%    T^^4    $D DK ==C DM r+c|jy|j.|jj|j|_|jS)r^)rJrTrdecoderUrZs r*rYzAbstractString.__unicode__ sD ==  ==  ..077GDM}}r+cPtt| |||j|_y)a& Copies the contents of another AbstractString object to itself :param object: Another instance of the same class :param copy_func: An reference of copy.copy() or copy.deepcopy() to use when copying lists, dicts and objects N)rrPrnrTrs r*rnzAbstractString._copys! nd)%; r+c<|jy|jSz The native Python datatype representation of this value :return: A unicode string or None N)rJrYrZs r*rzAbstractString.native(s  == !!r+) rrrrrUrTrHrYrnrrrrs@r*rPrPs9IH 4  ' " "r+rPc6eZdZdZdZdZdZdZedZ y)Booleanz7 Represents a boolean in both ASN.1 and Python r cvt||_|sdnd|_d|_|jdk7rd|_yy)z Sets the value of the object :param value: True, False or another value that works with bool() Nr+)boolrrJrrrs r*rHz Boolean.set>s9E{ ','  ==C DM r+c"|jS)4 :return: True or False )__bool__rZs r*rzBoolean.__nonzero__Ms }}r+c |jdk7S)rcr_rrZs r*rdzBoolean.__bool__Ts }}''r+cv|jy|j|j|_|jS)z{ The native Python datatype representation of this value :return: True, False or None N)rJrrdrZs r*rzBoolean.native[s2 ==  << ==?DL||r+N) rrrrr4rHrrdrrrr+r*r]r]7s1 C  (  r+r]c0eZdZdZdZdZdZedZy)Integerz8 Represents an integer in both ASN.1 and Python r"c "t|trg|jtt dt |||j vrtt dt |||j |}n8t|ts(tt dt |t ||jr||jvr|j|n||_ t|d|_ d|_ |jdk7rd|_ yy)z Sets the value of the object :param value: An integer, or a unicode string if _map is set :raises: ValueError - when an invalid value is passed Nz\ %s value is a unicode string, but no _map provided zR %s value, %s, is not present in the _map z %s value must be an integer or unicode string when a name_map is provided, not %s Tsignedr+)r2rrrBr rrrr3rrrJrrrs r*rHz Integer.setss eW %yy  dO "D--- dO "%%e,EE9-F$%  ,099$))9Ktyy'QV $U48  ==C DM r+c0t|jdS)1 :return: An integer Trj)rrJrZs r*__int__zInteger.__int__s dmmD99r+c|jy|jW|j|_|j6|j|jvr|j|j|_|jSzz The native Python datatype representation of this value :return: An integer or None N)rJrrnrrZs r*rzInteger.natives_ ==  << <<>DLyy$)B#yy6 ||r+N) rrrrr4rHrnrrrr+r*rhrhls- C. `:r+rhcBeZdZdZdZdZdZfdZedZ xZ S)_IntegerBitStringzY A mixin for IntegerBitString and BitString to parse the contents as an integer. rc|jrgStrt|jdn|jd}t |jdd}t |jdz dz}|s||dfgSt |jdk(rt dj||dkDrt dj|t|d|zdz z|}||z}||z}|||fgS) a Parse the contents of a primitive BitString encoding as an integer value. Allows reconstructing indefinite length values. :raises: ValueError - when an invalid value is passed :return: A list with one tuple (value, bits, unused_bits) where value is an integer with the value of the BitString, bits is the bit count of value and unused_bits is a tuple of 1s and 0s. rr Nr$Empty bit string has {0} unused bitsBit string has {0} unused bits) rrWordrJrrDrBformat_int_to_bit_tuple)rLunused_bits_lenr8bits unused_bitss r*rz_IntegerBitString._as_chunks   I37#dmmA./T]]1=Mt}}QR01DMM"Q&!+D"%& & t}}  "CJJ?[\ \ Q =DD_UV V'!2F!1K(Lo^  /! k*++r+c|js|jdSd}d}d}|jD]#\}}}|dzr td||z }||z|z}%|||fS)aa Combines the chunks into a single value. :raises: ValueError - when an invalid value is passed :return: A tuple (value, bits, unused_bits) where value is an integer with the value of the BitString, bits is the bit count of value and unused_bits is a tuple of 1s and 0s. rrrv4Only last chunk in a bit string may have unused bits)rrrrB)rLr8 total_bitsr}chunkr|s r*_chunks_to_intz _IntegerBitString._chunks_to_ints>>#A& &  )-(:(:(< $E4A~ !WXX $ Jd]e+E )=j+--r+cPtt| |||j|_y)a) Copies the contents of another _IntegerBitString object to itself :param object: Another instance of the same class :param copy_func: An reference of copy.copy() or copy.deepcopy() to use when copying lists, dicts and objects N)rrrrn _unused_bitsrs r*rnz_IntegerBitString._copy s% ,UI>!..r+c2|j|jSzp The unused bits of the bit string encoding. :return: A tuple of 1s and 0s rrrZs r*r}z_IntegerBitString.unused_bits    r+) rrrrrrrrnrr}rrs@r*rrrrs3 L%,N.> / ! !r+rrc@eZdZdZdZdZdZdZdZdZ e dZ y) BitStringzK Represents a bit string from ASN.1 as a Python tuple of 1s and 0s rNctj||j}|j,t |jj dz|_yy)rNr )rr;r?rmaxkeys_size)rLr6s r*r;zBitString._setup2sD nn 88 DIINN,-1CI r+c t|tr|jtt dt |dg|j z}||_td|j D]*}|jj|}|!||vs&d||<,djtt|}n|jtk(r|j||_n\t|_t|D]?\}}|s |jj||}|jj!|Adjtt|}n(t#t dt |t ||j\t%||j kDr3tt dt ||j t%||j'd}t%|}|d z}d} |dk7r d |z } |d| zz }t)t+j,|d z } | r t/| } nd } |dk(rd } nt/t)|d } t%| | k7rd | t%| z z| z} | | z|_d | z|_d|_|j6rd|_d|_|j:d k7rd |_yy)z Sets the value of the object :param value: An integer or a tuple of integers 0 and 1 :raises: ValueError - when an invalid value is passed NF %s._map has not been defined rr rWz %s value must be a tuple of ones and zeros or a set of unicode strings, not %s zf %s value must be at most %s bits long, specified was %s long 0rtr_r+r")rF)r2rHrrBr rrrranger{rmaprr?rraddr3rDrstripintmathceilrrJrrrrIr) rLr8r|rrbitrsizesize_mod extra_bits size_in_bytesextra_bits_byte value_bytess r*rHz BitString.set=s eS !yy  dO "3#D DLq$**-iimmE*;%<"#DK .GGC./E __ %yy $ "u "+E"2JE3#yy}}UE: ((.#3GGC/0EF$%   99 5zDJJ& dOJJJ "LL%E5z!8 q=XJ S:% %EDIIdQh/0 *:6O%O B;K&s5!}5K { } ,"mc+6F&FG;VK'+5  :-   $D DK ==C DM r+ct|t}|set|jtst t dt |||jvrt t dt |||j |j|j4t|j|dzk\rt|j|Sy|r|jj||}||jvS)aG Retrieves a boolean version of one of the bits based on a name from the _map :param key: The unicode string of one of the bit names :raises: ValueError - when _map is not set or the key name is invalid :return: A boolean if the bit is set rT %s._map does not contain an entry for "%s" r F) r2rrrzrBr rrrrrDrar{)rLris_ints r*r=zBitString.__getitem__sC+dii. dO "$+++ dO " <<  KK 99 4<< C!G+DLL-.. ))--S)Cdll""r+ct|t}|sW|jtt dt |||j vrtt dt |||j |j|jZt|j}t|dz }||kDr|jdg||z z|rdnd||<t||_ns|r|jj||}|r*||jvrE|jj|n)||jvr|jj||j!|jy)a Sets one of the bits based on a name from the _map :param key: The unicode string of one of the bit names :param value: A boolean value :raises: ValueError - when _map is not set or the key name is invalid Nrrr r)r2rrrBr rrrrrrDextendrr{rremoverH)rLrr8r new_nativemax_keys r*r"zBitString.__setitem__sNC+yy  dO "$+++ dO " <<  KK 99 dll+J*o)GW}!!1#w"78#(aaJsO ,DLiimmC-dll*LL$$S)$,,&LL'', r+c|j7|j|jdn|jt|j|j \}}|_t ||}|jrht|_t|D]?\}}|s |jj||}|jj|A|jS||_|jS)z The native Python datatype representation of this value :return: If a _map is set, a set of names, or if no _map is set, a tuple of integers 1 and 0. None if no value. r) rJrrHrrrrzrr{r)rL int_value bit_countr|rrrs r*rzBitString.native s == yy   << 6:6I6I6K 3Iy$"3$Y :Dyy"u "+D/JE3#yy}}UE: ((.#2 || $ ||r+) rrrrr4rr;rHr=r"rrrr+r*rr)s? C E 2a F-#^7rr+rc`eZdZdZdZdZdZdZdZfdZ dZ e d Z e d Z xZS) OctetBitStringzB Represents a bit string in ASN.1 as a Python byte string rNrc t|ts(ttdt |t |||_d|z|_d|_d|_|jrd|_ d|_ |jdk7rd|_ yy) Sets the value of the object :param value: A byte string :raises: ValueError - when an invalid value is passed rEr_rNFrr+) r2rr3r r_bytesrJrrrrIrrs r*rHzOctetBitString.set5 s%*F$%   %    $D DK ==C DM r+ct|jy|j|js,|jd\|_|_|jS|j }d|_|D]#}|jr t d|d|_%djd|D|_|jS)4 :return: A byte string r+rrrr c3&K|] }|d yw)rNr).0rs r* z+OctetBitString.__bytes__..g s&DVEuQxVs)rJrrrrrrBr)rLchunksrs r*rXzOctetBitString.__bytes__T s ==  ;; ##151A!1D. T.{{++-$&!#E((()_``(-aD% $ "hh&DV&DD {{r+crtt| |||j|_|j|_y)a& Copies the contents of another OctetBitString object to itself :param object: Another instance of the same class :param copy_func: An reference of copy.copy() or copy.deepcopy() to use when copying lists, dicts and objects N)rrrnrrrs r*rnzOctetBitString._copyk s/ nd)%;ll !..r+ctrt|jdn|jd}|s|jdddfgSt|jdk(rt dj ||dkDrt dj |d|zdz }trt|jdn|jd}||z}|jddtr t |n t|fz}t||z|}||fgS) z Allows reconstructing indefinite length values :raises: ValueError - when an invalid value is passed :return: List with one tuple, consisting of a byte string and an integer (unused bits) rr Nrrurvrwr) rWrxrJrDrBrychrbytesrz)rLr{mask last_byte zeroed_byter8r}s r*rzOctetBitString._as_chunk{ s48#dmmA./T]]1=M]]12&+, , t}}  "CJJ?[\ \ Q =DD_UV V_$).2C b)* b8I  4%'  a#4s;'7UK>EZ[' D(8/J  $%%r+c<|jy|jS} The native Python datatype representation of this value :return: A byte string or None NrJrXrZs r*rzOctetBitString.native  == ~~r+c2|j|jSrrrZs r*r}zOctetBitString.unused_bits rr+)rrrrr4rrrHrXrnrrrr}rrs@r*rr( sZ CFL >./ &D     ! !r+rc*eZdZdZdZdZedZy)IntegerBitStringz> Represents a bit string in ASN.1 as a Python integer rc rt|ts(ttdt |t ||dkrt tdt ||||_dt|dz|_d|_ d|_ |jrd |_ d|_ |jd k7rd |_ yy) Sets the value of the object :param value: An integer :raises: ValueError - when an invalid value is passed M %s value must be a positive integer, not %s rM %s value must be a positive integer, not %d r_TrjrNFr+)r2rr3r rrBrrrJrrrrIrrs r*rHzIntegerBitString.set s%+F$%   19V$   ,uT"BB    $D DK ==C DM r+c|jy|j|j\|_}|_|jSrp)rJrrr)rL__s r*rzIntegerBitString.native s? ==  << 262E2E2G /DL"d/||r+Nrrrrr4rHrrrr+r*rr s( C& Pr+rcFeZdZdZdZdZdZdZfdZe dZ xZ S) OctetStringz; Represents a byte string in both ASN.1 and Python Nc t|ts(ttdt |t |||_||_d|_|jrd|_d|_ |jdk7rd|_ yyrDrENFrr+ r2rr3r rrrJrrrIrrs r*rHzOctetString.set %*F$%       $D DK ==C DM r+cv|jy|j|j|_|jSrr+rJrrrZs r*rXzOctetString.__bytes__ 5 ==  ;; ,,.DK{{r+cPtt| |||j|_y)a# Copies the contents of another OctetString object to itself :param object: Another instance of the same class :param copy_func: An reference of copy.copy() or copy.deepcopy() to use when copying lists, dicts and objects N)rrrnrrs r*rnzOctetString._copy+ s! k4&ui8ll r+c<|jy|jSrrrZs r*rzOctetString.native: rr+) rrrrr4rrHrXrnrrrrs@r*rr s9 CF 4  #    r+rc4eZdZdZdZdZdZedZdZ y)IntegerOctetStringz? Represents a byte string in ASN.1 as a Python integer rNc tt|ts(ttdt |t ||dkrt tdt ||||_t|d|j|_ d|_ |jrd|_ d|_ |jdk7rd|_ yy)rrrrF)rkwidthNr+)r2rr3r rrBrr_encoded_widthrJrrrIrrs r*rHzIntegerOctetString.setV s%+F$%   19V$   $U5@S@ST    $D DK ==C DM r+c|jy|jt|j|_|jSrp)rJrrrrZs r*rzIntegerOctetString.native| s: ==  << )$*<*<*>?DL||r+c||_|j5t|j|k7r|j|jyyy)z Set the explicit enoding width for the integer :param width: An integer byte width to encode the integer to N)rrJrDrHr)rLrs r*set_encoded_widthz$IntegerOctetString.set_encoded_width s?$ == $T]]);u)D HHT[[ !*E $r+) rrrrr4rrHrrrrr+r*rrI s4 C N$ L   "r+rcteZdZdZdZdZd dZdZd dZdZ dZ fdZ e d Z e d Zd d ZxZS)ParsableOctetStringrNc d}|$|"t|tr|j}d}tj|fd|i||r||j df|_yy)a Allows providing a parsed object that will be serialized to get the byte string value :param value: A native Python datatype to initialize the object value with :param parsed: If value is None and this is an Asn1Value object, this will be set as the parsed value, and the value will be obtained by calling .dump() on this object. FNTr8)r2r'rcrArSr?r)rLr8rr7 set_parseds r*rSzParsableOctetString.__init__ s` =V/Jvy4QKKMEJ47u77 "F$4$4d;DL r+c t|ts(ttdt |t |||_||_d|_|jrd|_d|_ |jdk7rd|_ yyrrrs r*rHzParsableOctetString.set rr+c|j|jdd||fk7r)t|j||\}}|||f|_|jdS)rr rrr)rr5rX)rLr0r1rr9s r*rzParsableOctetString.parse s[$ << 4<<!#4{8K#K*4>>+;$T_`OL!($ ># #r+cX|j|j|jdSrrrZs r*rzParsableOctetString.parsed# rr+c|jrd}|rM|j|jj|}n |j}d|_|j |tj|S)rTNr)rrrrcrrJrHr'rGs r*rczParsableOctetString.dump1 sa   E ||')))6 DM HHV ~~d##r+rr)rrrr4rrrSrHrrXrrnrrrrcrrs@r*rr s_ CGF<0 4.  0 $$   $r+rceZdZdZdZdZy)ParsableOctetBitStringrc t|ts(ttdt |t |||_d|z|_d|_|jrd|_d|_ |jdk7rd|_ yy)rrEr_NFrr+rrs r*rHzParsableOctetBitString.setP s%*F$%   %    $D DK ==C DM r+ctrt|jdn|jd}|r td|jddS)z Allows reconstructing indefinite length values :raises: ValueError - when an invalid value is passed :return: A byte string rz1ParsableOctetBitString should have no unused bitsr N)rWrxrJrB)rLr{s r*rz ParsableOctetBitString._as_chunkn sD48#dmmA./T]]1=M PQ Q}}QR  r+N)rrrr4rHrrr+r*rrL s C <!r+rc.eZdZdZdZdZdZedZy)Nullz< Represents a null value in ASN.1 as None in Python r+cd|_y)zV Sets the value of the object :param value: None r+Nrrs r*rHzNull.set s  r+cyrrrZs r*rz Null.native rr+N) rrrrr4rJrHrrrr+r*rr s, CHr+rcdeZdZdZdZdZedZedZdZ dZ e dZ e d Z y) ObjectIdentifier` Represents an object identifier in ASN.1 as a Python unicode dotted integer string Nc|jttdt|t |t st tdt||jj||S)a^ Converts a dotted unicode string OID into a mapped unicode string :param value: A dotted unicode string OID :raises: ValueError - when no _map dict has been defined on the class TypeError - when value is not a unicode string :return: A mapped unicode string > %s._map has not been defined H value must be a unicode string, not %s )rrBr rr2rr3r{r6r8s r*rzObjectIdentifier.map sv 88 V#  %)F%  xx||E5))r+c|tvr|jdt|<|jtt dt |t |tstt dt |||jvr|j|Stj|stt dt |||S)a Converts a mapped unicode string value into a dotted unicode string OID :param value: A mapped unicode string OR dotted unicode string OID :raises: ValueError - when no _map dict has been defined on the class or the value can't be unmapped TypeError - when value is not a unicode string :return: A dotted unicode string OID TrrzL %s._map does not contain an entry for "%s" ) r@r;rrBr rr2rr3r_OID_REmatchrs r*unmapzObjectIdentifier.unmap s n $ ELLN"&N3  88 V#  %)F%   C$$ $##E* *}}U#V#   r+c t|ts(ttdt |t |||_|j ||jvr|j|}d|_d}t|jdD]\}}t|}|dk(r|}|dk(rS|dkDrttdt||dkr#|d k\rttd t||d z|z}td |z}|d z }|dkDrtd d |zz|z}|d z }|dkDr|xj|z c_d|_|j dk7rd|_yy)a  Sets the value of the object :param value: A unicode string. May be a dotted integer string, or if _map is provided, one of the mapped values. :raises: ValueError - when an invalid value is passed rSNr+.rr r"z\ First arc must be one of 0, 1 or 2, not %s (z Second arc must be less than 40 if first arc is 0 or 1, not %s rv)r2rr3r rrrrrJrsplitrrBrCrrr)rLr8firstrpart encoded_parts r*rHzObjectIdentifier.set s%)F$%   99 )))))%0 $U[[%56KE4t9Dz!19$VU & QY42:$VT & d*"4$;/L19D(&ttd{';<|K qy( MM\ )M=7@ ==C DM r+c|jSr+)dottedrZs r*rYzObjectIdentifier.__unicode__? s {{r+c|j-g}d}|jD]}tr t|}|dz}||dzz }|dzdk(s+t |dk(r|dk\r8|j t d|j t |dz n|dk\r8|j t d|j t |dz nO|j t d|j t |n|j t |d}dj||_|jS) z :return: A unicode string of the object identifier in dotted notation, thus ignoring any mapped value rrrPr"rr r)_dottedrJrWrxrDr!rr)rLrr bytes r*r zObjectIdentifier.dottedG s  << FD t9Dczs "$;!#6{a'2:"MM'!*5"MM'$)*<=!RZ"MM'!*5"MM'$)*<="MM'!*5"MM'$-8 gdm4D'&*88F+DL||r+c|jy|j|j|_|j6|j|jvr|j|j|_|jS)aC The native Python datatype representation of this value :return: A unicode string or None. If _map is not defined, the unicode string is a string of dotted integers. If _map is defined and the dotted string is present in the _map, the mapped value is returned. N)rJrr rrZs r*rzObjectIdentifier.nativek s] ==  << ;;DL 99 T\\TYY%>99T\\2DL||r+)rrrrr4rrrrrHrYrr rrr+r*rr sq CG**B//b? B!!Fr+rceZdZdZdZy)ObjectDescriptorzO Represents an object descriptor from ASN.1 - no Python implementation rvNrrrrr4rr+r*rr  Cr+rceZdZdZdZy) InstanceOfzF Represents an instance from ASN.1 - no Python implementation rtNrrr+r*rr rr+rceZdZdZdZy)RealzH Represents a real number from ASN.1 - no Python implementation Nrrr+r*rr rr+rc*eZdZdZdZdZedZy) Enumeratedz\ Represents a enumerated list of integers from ASN.1 as a Python unicode string c t|ts8t|ts(tt dt |t |t|tr=||j vrtt dt |||j |}n-||jvrtt dt ||tj||y)z Sets the value of the object :param value: An integer or a unicode string from _map :raises: ValueError - when an invalid value is passed zY %s value must be an integer or a unicode string, not %s zL %s value "%s" is not a valid value zB %s value %s is not a valid value N) r2rrr3r rrrBrrhrHrs r*rHzEnumerated.set s%+Jug4NF$%   eW %D--- dO "%%e,E $)) #V$    D% r+c|jy|j"|j|j|_|jSr[)rJrrrnrZs r*rzEnumerated.native s; ==  << 99T\\^4DL||r+Nrrr+r*rr s( C)!V  r+rceZdZdZdZdZy) UTF8StringzI Represents a UTF-8 string from ASN.1 as a Python unicode string rfNrrrrr4rUrr+r*r!r!  CIr+r!ceZdZdZdZy) RelativeOidr Nrrr+r*r&r& s Cr+r&ceZdZdZdZdZdZdZdZdZ gZ dZ dZ dZ dZdZdZdZddZedZej*d Zd Zd Zd Zd ZdZdZdZddZdZdZdZ ddZ!dZ"edZ#fdZ$ddZ%ddZ&xZ'S)Sequencezf Represents a sequence of fields from ASN.1 as a Python object with a dict-like interface rr NFc tj|fi|d}|1|/d}|j|jd}n|j |}|0 |j r6|j Dcgc]}|d }}t |j}n|j}t |}|D]}|rR|j|} | t|jkr+|j| tur||vr|j|W||vs\|j||||j|t|r@ttdt|dj!t#t%|yycc}w#tt&f$r=} | j(dd} | j(ddt|zzf| z| _| d} ~ wwxYw) a" Allows setting field values before passing everything else along to Asn1Value.__init__() :param value: A native Python datatype to initialize the object value with :param default: The default value if no value is specified FNTrz One or more unknown fields was passed to the constructor of %s: %s r r r>)r'rSchildrenrJ_parse_children_fieldsrHr _field_maprDVOIDrr"rBr rrsortedrr3rK) rLr8rPr7check_existingrr unused_keysrrrRrKs r*rSzSequence.__init__' s 4*6* =W0!N}}$==(%*N((*E  & <<04 = DG D="%ejjl"3K ::< * vvabz&&)&CiPTo&UUWZ^^ s2F* F6BF A3FFG8G  Gc|j |jS|jr|j|jSz` :return: A byte string of the DER-encoded contents of the sequence r,r _is_mutated _set_contentsrZs r*rJzSequence.contentsh : == >> !        ~~r+c||_yze :param value: A byte string of the DER-encoded contents of the sequence Nrrs r*rJzSequence.contentsw rr+c|j}|jF|jD]7}t|tst|ts$|xs|j }9|Sz~ :return: A boolean - if the sequence or any children (recursively) have been mutated _mutatedr,r2r) SequenceOfr7rLmutatedr4s r*r7zSequence._is_mutated R-- == $eX.*UJ2O%<):):) 9EDMM%( r+cd|j|jt|jSr9r,r-rDrZs r*rzSequence.__len__ ) ==  "4==!!r+c |j|jt|ts<||jvrt t d|t||j|}|t|jk\rt t d|t| |j|S#ttf$r=}|jdd}|jddt|zzf|z|_ |d}~wwxYw)a9 Allows accessing fields by name or index :param key: A unicode string of the field name, or an integer of the field index :raises: KeyError - when a field name or index is invalid :return: The Asn1Value object of the field specified NL No field named "%s" defined for %s zL No field numbered %s is present in this %s r rr) r,r-r2rr/r;r rrDrIrBr3rK)rLrrRrKs r*r=zSequence.__getitem__ s ==  "#y)$//)vdO  //#&C #dmm$ $6$   ##C( (I& 66!":DffQi":Yt_"LLNQUUAFG s!B22C>8C99C>c ||j|jt|ts<||jvrt t d|t||j|}|j|\}}}}}|j|||||}d} t|tr|jdu} n|jdu} | rtt d|t|||j|<|j6|j|j|j|j |d<d|_y)a Allows settings fields by name or index :param key: A unicode string of the field name, or an integer of the field index :param value: A native Python datatype to set the field value to. This method will construct the appropriate Asn1Value object from _fields. :raises: ValueError - when a field name or index is invalid NrNFzG Value for field "%s" of %s is not set rT)r,r-r2rr/r;r r_determine_spec _make_valuerrrJrBrrr.r?) rLrr8 field_name field_spec value_spec field_paramsr9 new_value invalid_values r*r"zSequence.__setitem__ s= ==  "#y)$//)vdO  //#&C>B>R>RSV>W; J L!$$ZZW\]  i %%,,4M%..$6M V$  ' c << #15s1C1J1JDLLc*1- . r+c |j|jt|ts<||jvrt t d|t||j|}|j|\}}}|rd|vr#d|vrtt d|t|d|vr6t|j|<|j)d|j|<d|_ y|j|dd|_ y)a/ Allows deleting optional or default fields by name or index :param key: A unicode string of the field name, or an integer of the field index :raises: ValueError - when a field name or index is invalid, or the field is not optional or defaulted NrNrPrOz Can not delete the value for the field "%s" of %s since it is not optional or defaulted T)r,r-r2rr/r;r rr.rBr0rr"r?)rLrrr9rs r* __delitem__zSequence.__delitem__ s ==  "#y)$//)vdO  //#&C,,s+a)61j6NV$    !%DMM# ||'%) T"    S$ ' r+c#<K|jD] }|d yw)zE :return: An iterator of field key names rN)r.)rLrs r*rzSequence.__iter__6s LLDq'M!scL|j|jt}t|jD]\}}|j|}|d}n[|j t k(r6|r"|j|j|}n$|d|dz|dz}n|j|}|dr)d|dvr"|d d i|d}|j|k(r|j||j|_ d|_ |jdk7rd|_ yy) a Updates the .contents attribute of the value with the encoded value of all of the child objects :param force: Ensure all contents are in DER format instead of possibly using cached BER-encoded data Nr+rrrrr"rPr r)r,r-rrr.r?rrIrcwritegetvaluerrr)rLrrJrrr4 child_dump default_values r*r8zSequence._set_contents?s" ==  "9$T\\2KE4MM%(E} E)!%!1!1%!8!=!=E!=!JJ!&qE!H!4uQx!?J"ZZeZ4 Aw9Q/ 'Q 2$q' 2  %%':5 NN: &!3""**, ==C DM r+c*|j}i|_g|_g|_t |j D]e\}}t |dkr|ifz}||j |<||j|d<|jjt|d|dg|j=|j|jd|j|jdf|_ t |j D]\}}|jduxr|d|jv}|jduxr|jd|k(}|s|r|jjdi|jj|d|d|d|ddfyzS Generates _field_map, _field_ids and _oid_nums for use in parsing rrr"r N) r?r/ _field_ids_precomputed_specsrr.rDr!r _oid_pair _oid_nums_spec_callbacksrLr6rfield has_callback is_mapped_oids r*r;zSequence._setupdst nn!#%ckk2LE55zA~ %* E"',CNN58 $ NN ! !/%(E!H"E F 3 == $ ^^CMM!,<=s~~cmm\]N^?_`CM%ckk2LE5..d:^uQx3K^K^?^LMM5S#--:Je:SM}&&--d3&&--uQxq58USTXW[.\] 3r+c|j|\}}}|}d}|j`||jvrR|j|}||}|r|jtk(rt |dk(r |\}}|v|}d}nq||}|}d}nh|}ne|j Y|j d|k(rG|j |j dj}||jvr|j|}|}|||||fS)a Determine how a value for a field should be constructed :param index: The field number :return: A tuple containing the following elements: - unicode string of the field name - Asn1Value class of the field spec - Asn1Value class of the value spec - None or dict of params to pass to the field spec - None or Asn1Value class indicating the value spec was derived from an OID or a spec callback Nr"r r) r.rfr?rrDrerIr _oid_specs) rLrrrSrUrT spec_overridecallbackoids r*rPzSequence._determine_specs *.e)<&j,     +8L8L0L++D1H$TNM!**e3M8Ja8O-:*J !)%/ (, '!.J!+J$(M!.J ^^ 'DNN1,=,F""4>>!#45<>+;L|L#,i.A.A4"H#  L9 r+c |j}|j|jrtgt |jz|_t |jD]l\}\}}}d|vs|j|r|j|\}}}} }n|j|\}}}} }|j|||| d|j |<ny g|_t |j} d} d} t |j} d}| | k}|r^|t|j| | \}} | | k}| | kr |j| xs|j| \}}}} }| rd| vsd| vr|j| |d|dfk7r|tk7rd}t|tr' |di| }|j|d|d|dd }|sNd| vr |j j#tn!|j j#|di| | d z } d } ||rt|tr|}d}|r ||| |fz}n||| fz}n| dkDr| d z| krg}| d z }|dk\rK|j|}t |d krn-d|dvsd|dvr|j#|d|d z}|dk\rKt |d kDrd nd }dj%|}t!t'd| d zt(j+|dt,j+|d |d|||}|r0t/|}t1|t2t4fr|j7d |j j#|| d z } d}|r^t |j }|| kr~|j|\}}} d| vr"|j j#|di| n9d| vr |j j#tnt!t'd||d z }|| kr}yy#t $rYMwxYw#t t8f$rD}d|_|j:d d}|j:ddt=|zzf|z|_|d}~wwxYw)Q Parses the contents and generates Asn1Value objects based on the definitions from _fields. :param recurse: If child objects that are Sequence or SequenceOf objects should be recursively parsed :raises: ValueError - when an error occurs parsing child objects NrPrrrOr"FrTr rsrWr z Data for field %s (%s class, %s method, tag %s) does not match the field definition%s of %s recursezV Field "%s" is missing from structure rr)r?rr.r0rDr,rrcrPrQrrbrrqrrrBr!rr rEr{METHOD_NUM_TO_NAME_MAPrGr2r)r@r-r3rKr)rLr}r6rr9rrRrSrTrUcontents_length child_pointerrh field_lenpartsagainrm choice_matchtesterr4 missed_fields prev_fieldprev_field_infopluralmissed_field_namesrrRrKs r*r-zSequence._parse_childrensnn >> !||!%T\\): : -6t||-D)E>Aq& F*11%8RURhRhinRoOJ J aRVRfRfglRmOJ J a/3/?/? JXbdprv/w e, .E l DM!$..1OMEDLL)IE!O3E=+1$../[h+i(E=%79$..u5T9M9Me9TKAz:|]$|)CyT`G`??51eAha5IIj\_N_,1L)*f=!)-7-G,-GF$*OOE!HeAha$Q37L$0#-#=$(MM$8$8$>$(MM$8$89Sl9S$T % (, (!)m :WZ@[%/ (, $ %\:(N N %\(B B]uqyI'=$&M!&J$/*.,,z*B/!3!%);;yO\]L^?^)001CD"a %/%( $6$:SF)-=)A&$V -11%(;.2258<a* &  "E"ENE!%(J)?@--d-; $$U+ ]` &E)#15e1D.j, ,MM(()Cl)CD</MM((.$V &  )#y)3!)$(!)VI&  DM66!":DffQi":Yt_"LLNQUUAFG  sL CP&PCP!CP*BP P PPPQ&"?Q!!Q&c t|tsttdt ||j (t tdt|t ||j|}|j|}|dS)a Determines the spec to use for the field specified. Depending on how the spec is determined (_oid_pair or _spec_callbacks), it may be necessary to set preceding field values before calling this. Usually specs, if dynamic, are controlled by a preceding ObjectIdentifier field. :param field_name: A unicode string of the field name to get the spec for :return: A child class of asn1crypto.core.Asn1Value that the field must be encoded using zM field_name must be a unicode string, not %s z Unable to retrieve spec for field %s in the class %s because _fields has not been set r") r2rr3r rr.rBrCr/rP)rLrRrrs r*r0z Sequence.specs *g.F*%   << VZ $   +##E*Awr+c|jy|j|j|jd t |_t |jD][\}}|j tk(rt|}||j|< |j|d}|j|j|<] |jS|jS#t$rt|}YJwxYw#ttf$rD}d|_|jdd}|jddt!|zzf|z|_|d}~wwxYw)z The native Python datatype representation of this value :return: An OrderedDict or None. If an OrderedDict, all child values are recursively converted to native representation also. NTr|rr r)rJrr,r-r rr?rrGr. IndexErrorrrrBr3rKr)rLrr4rrRrKs r*rzSequence.natives1 ==  << }}$$$T$2 *} $-dmm$4&PPRUYY  s<AC.C C.C+(C.*C++C..E=?D<<Ec(tt| |||jqg|_|jD]Z}|jt k(r|jj |2|jj |j\yy)a  Copies the contents of another Sequence object to itself :param object: Another instance of the same class :param copy_func: An reference of copy.copy() or copy.deepcopy() to use when copying lists, dicts and objects N)rr)rnr,r?rr!rorLrrr4r?s r*rnzSequence._copysp h#E95 == $DM??e+MM((/MM((6 ( %r+c|j|jd|z}t|||D]N}|j|j|}|t us*t |d|d|j|dzPy)rNrz Field ""r)r,r-rrIr/r0rr)rLrrrRr4s r*rzSequence.debugsv ==  " "VT"J$$T__Z%@AED FJ?@ JN+ r+c|j|jdddk(rd}|r#|jgk(r|jturd}|r|j ||jr`|j Tt |jD]<\}\}}}|j |tur d|vsd|vr)ttd |tj|S) rNrrTFrrPrOzN Field "%s" is missing from structure ) rr.r?r)r8r,rr0rBr r'rc)rLrrrRr9rs r*rcz Sequence.dumps << # RS(9W(DE T\\R'DNNh,FE    U  + <  " 3J~~d##r+rrr)(rrrrr4rGrIr,rr?r.rfr/rbrdrlrercrSrrJrr7rIrr=r"rYrr8r;rPrQr-r0rrnrrcrrs@r*r)r) s  C F FHIHGOJJ IJI?B  __  ",\5n+Z# J^6-K^^@FP%NB7*, $$r+r)ceZdZdZdZdZdZdZdZdZ dZ ddZ e dZ e jd Z d Zd Zd Zd ZdZdZdZdZdZdZddZddZdZe dZfdZddZddZxZ S)r@z Represents a sequence (ordered) of a single type of values from ASN.1 as a Python object with a list-like interface r*rr NFc |r||_tj|fi| |||_y|||}|Ct |D]\}}|j |||j|j yyy#ttf$r=}|jdd} |jddt|zzf| z|_ |d}~wwxYw)a Allows setting child objects and the _child_spec via the spec parameter before passing everything else along to Asn1Value.__init__() :param value: A native Python datatype to initialize the object value with :param default: The default value if no value is specified :param contents: A byte string of the encoded contents of the value :param spec: A class derived from Asn1Value to use to parse children Nr rr>) _child_specr'rSrJrr"r8rBr3rKr) rLr8rPrJr0r7rr4rRrKs r*rSzSequenceOf.__init__Cs$ #D 4*6* # ( =W%8#E$(1%(8 u((6)9}},**,- %I& 66!":DffQi"?)D/"QQSVZZAFG s A7A A77C8B>>Cc|j |jS|jr|j|jSr5r6rZs r*rJzSequenceOf.contentsnr9r+c||_yr;rrs r*rJzSequenceOf.contents}rr+c|j}|jF|jD]7}t|tst|ts$|xs|j }9|Sr=r>rAs r*r7zSequenceOf._is_mutatedrCr+cx|j|}|jtk(rt|}||j|<|SrErFrHs r*rIzSequenceOf._lazy_childs:  e$ ??e #ENE#(DMM%  r+ctt||jr|}nt|jtr1t|tr|}nt t dt|t|jtrt|ts3t t dt||jjt||jsJ|j}|j|j|j|j||_|}|}n|j|Si}|jjr|jj|d<|jj r/|jj|jjf|d<t#||S)a  Constructs a _child_spec value from a native Python data type, or an appropriate Asn1Value object :param value: A native Python value, or some child of Asn1Value :return: An object of type _child_spec z Can not set a native python value to %s where the _child_spec is Any - value must be an instance of Asn1Value z Can not set a native python value to %s where the _child_spec is the choice type %s - value must be an instance of Asn1Value )r8r<r=)r2rrqrr'rBr rrrrrGr4rJrr<r=r)rLr8rVrwrs r*rQzSequenceOf._make_valuesy eT-- .I ((# .%+!  dO "((& 1eY/  dO$$--"eT%5%56**,  uyy%..I"'I##%#0 0    $ $!%!1!1!:!:F:     $ $"&"2"2"9"94;K;K;O;O!PF: Iv..r+cd|j|jt|jS)rmrKrZs r*rzSequenceOf.__len__rLr+c\|j|j|j|S)zm Allows accessing children via index :param key: Integer index of child )r,r-rIr<s r*r=zSequenceOf.__getitem__s+ ==  "$$r+c|j|j|j|}|t|jk(rB|jj d|j |j j d||j|<|j &|j|j |j |<d|_y)z Allows overriding a child via index :param key: Integer index of child :param value: Native python datatype that will be passed to _child_spec to create new child object NT)r,r-rQrDr!rrr?)rLrr8rVs r*r"zSequenceOf.__setitem__s ==  "$$U+  #dmm$ $ MM  &||' ##D)& c << # $ c 2 9 9DLL  r+c|j|j|jj||j|jj|d|_y)zk Allows removing a child via index :param key: Integer index of child NT)r,r-poprr?r<s r*rYzSequenceOf.__delitem__sO ==  " # << # LL  S ! r+c#K|j|jtdt|jD]}|j |yw)zA :return: An iter() of child objects Nr)r,r-rrDrI)rLrs r*rzSequenceOf.__iter__!sI ==  "1c$--01E""5) )2sAAc ||turyt||js?$ $? ||t|| @ * vvabz&&)&>4&PPRUYY s(A5A0A50A55C8B<<Cc(tt| |||jqg|_|jD]Z}|jt k(r|jj |2|jj |j\yy)a" Copies the contents of another SequenceOf object to itself :param object: Another instance of the same class :param copy_func: An reference of copy.copy() or copy.deepcopy() to use when copying lists, dicts and objects N)rr@rnr,r?rr!rors r*rnzSequenceOf._copysp j$%eY7 == $DM??e+MM((/MM((6 ( %r+c|j|jd|z}t|||D]}|j|dzy)rNrr )r,r-rrr3s r*rzSequenceOf.debugsH ==  " "VT"E KK Q 'r+c|j|jdddk(rd}|r|j|tj|S)rNrrTr)rr8r'rcrs r*rczSequenceOf.dumpsH << # RS(9W(DE    U  +~~d##r+)NNNNrr)!rrrrr4rGrIr,rr?rrSrrJrr7rIrQrr=r"rYrrr!r8r-r0rrnrrcrrs@r*r@r@+s C F FHIHK)V  __  5/n " %>$ *:( ("H  .7* ($r+r@c6eZdZdZdZdZdZdZdZd dZ d dZ y) Setzm Represents a set of fields (unordered) from ASN.1 as a Python object with a dict-like interface r rNc|j}i|_i|_g|_t |j D]Y\}}t |dkr|ifz}||j |<||j|d<||jt|d|d<[|j=|j|jd|j|jdf|_ t |j D]\}}|jduxr|d|jv}|jduxr|jd|k(}|s|r|jjdi|jj|d|d|d|ddfyra) r?r/rbrcrr.rDrrdrerfr!rgs r*r;z Set._setupsp nn!#%ckk2LE55zA~ %* E"',CNN58 $BGCNN?58U1X> ? 3 == $ ^^CMM!,<=s~~cmm\]N^?_`CM%ckk2LE5..d:^uQx3K^K^?^LMM5S#--:Je:SM}&&--d3&&--uQxq58USTXW[.\] 3r+c |j}|j|jrtgt |jz|_t |jD]l\}\}}}d|vs|j|r|j|\}}}} }n|j|\}}}} }|j|||| d|j |<ny i} t |j} d} d} | | krt|j| | \}} |d|df}|jj|}|Gttd| t j|dt"j|d|d|j|xs|j|\}}}} }||rt%|t&r|}d}|r ||| |fz}n||| fz}|r0t)|}t+|t,t.fr|j1d || |<| dz } | | krt |j}t3d|D]}|| vr|j|xs|j|\}}}} }||rt%|t&r|}d}d }| sd}n(d | vrd| vrd}nd | vr t| |<nd| vr |di| | |<|szttd |t5|g|_t3d|D] }|j j7| |"y#tt8f$r=}|j:dd}|j:dd t5|zzf|z|_|d}~wwxYw)ryNrPrrzr"z Data for field %s (%s class, %s method, tag %s) does not match any of the field definitions r Tr|FrOzU Missing required field "%s" from %s rr)r?rr.r0rDr,rrcrPrQrJrrbr{rBr rEr~rqrrGr2r)r@r-rrr!r3rK)rLr}r6rr9rrRrSrTrU child_maprr seen_fieldrrrhrmr4 total_fieldsrmissingrRrKs r*r-zSet._parse_childrensnn >> !||!%T\\): : -6t||-D)E>Aq& F*11%8RURhRhinRoOJ J aRVRfRfglRmOJ J a/3/?/? JXbdprv/w e, .E S I!$--0OMJ/1'-dmm_Vc'd$}Qxq*++C0=$V#-11%(;.2258<a &  **51PT5I5I%5PG:z<%-JzSV>E"ENE!%(J)?@--d-;#( % a I /1Lt||,Lq,/I%**51PT5I5I%5PJj*lM%-JzSVDMq,/ $$Yu%560I& 66!":DffQi":Yt_"LLNQUUAFG s' D=K> BK>'AK>>M  8MM c|j|jg}t|jD]e\}}|j|}|j|\}}}d|vr|di|j|k(rI|j |j |fg|jddj|D cgc]} | d c} |_ d|_ |jdk7rd|_ yycc} w) ac Encodes all child objects into the contents for this object. This method is overridden because a Set needs to be encoded by removing defaulted fields and then sorting the fields by tag. :param force: Ensure all contents are in DER format instead of possibly using cached BER-encoded data NrrPc |dSrr)cts r*z#Set._set_contents..s1r+)rr+r r) r,r-rrcr.r!r4sortrrrr) rLrchild_tag_encodingsrr4child_encodingrr0rUrs r*r8zSet._set_contentss ==  " %dmm4LE5"ZZeZ4N(,||E': $D$ L(',',,..@  & & >'B C5   %5 63F"G3FR2a53F"GH ==C DM #Hs> C5r) rrrrrIrGr4rbr;r-r8rr+r*rrs1 F F CJ^6m^ r+rceZdZdZdZddZy)SetOfz~ Represents a set (unordered) of a single type of values from ASN.1 as a Python object with a list-like interface rc |j|jg}|D]#}|j|j|%dj t ||_d|_|jdk7rd|_yy)aD Encodes all child objects into the contents for this object. This method is overridden because a SetOf needs to be encoded by sorting the child encodings. :param force: Ensure all contents are in DER format instead of possibly using cached BER-encoded data Nrr+) r,r-r!rcrr1rrr)rLrchild_encodingsr4s r*r8zSetOf._set_contentssx ==  "E  " "5::E:#: ;&"9: ==C DM r+Nr)rrrrr4r8rr+r*rrs C r+rceZdZdZdZy) EmbeddedPdvz A sequence structure Nrrr+r*rr Cr+rceZdZdZdZdZy) NumericStringzK Represents a numeric string from ASN.1 as a Python unicode string rQNr#rr+r*rr CIr+rceZdZdZdZdZy)PrintableStringzM Represents a printable string from ASN.1 as a Python unicode string rQNr#rr+r*rrrr+rceZdZdZdZdZy) TeletexStringzK Represents a teletex string from ASN.1 as a Python unicode string teletexNr#rr+r*rrs CIr+rceZdZdZdZy)VideotexStringzI Represents a videotex string from ASN.1 as a Python byte string Nrrr+r*rrrr+rceZdZdZdZdZy) IA5StringzH Represents an IA5 string from ASN.1 as a Python unicode string asciiNr#rr+r*rrr$r+rc0eZdZdZedZedZy) AbstractTimezK Represents a time from ASN.1 as a Python datetime.datetime object c t|}|jj|}|stt d|t ||j }d}|drtj}nF|drA|ddk(rdnd}t|tt|dt|d xsd  z}|d rZtt|d d t|d zdz}|d|dz}n |d|dz}t|jd}nd }t|dt|dt|dt|dt|dxsd t|dxsd ||dS)z The parsed datetime string. :raises: ValueError - when an invalid value is passed :return: A dict with the parsed values z: Error parsing %s to a %s Nzuludsign+r rdhourdminuter)hoursminutesfractionri@Bminuteisecond<yearmonthdayhour)rrrrrrtzinfor)r_TIMESTRING_RErrBr r groupdictrutcrrrr rDlimit_denominator)rLstringmgroupstzsignfract fract_usecs r* _parsed_timezAbstractTime._parsed_times    % %f -V$    &>B G_w3.1BD  &/*F9-23)"B * F:&'c&,--E h' !) U44Q78JJv')ve}%v'&*/a0&*/a0"  r+c|jy|jG|j}|jdd}|j |}|r|t |z }||_|jS)aF The native Python datatype representation of this value :return: A datetime.datetime object, asn1crypto.util.extended_datetime object or None. The datetime object is usually timezone aware. If it's naive, then it's in the sender's local time; see X.680 sect. 42.3 Nrr) microseconds)rJrrr _get_datetimer)rLrrr8s r*rzAbstractTime.nativeFsi ==  << &&Fzz*a0H&&v.E99 DL||r+N)rrrrrrrrr+r*rrs0= = ~r+rcZeZdZdZdZej dejZdZ dZ y)UTCTimez^ Represents a UTC time from ASN.1 as a timezone aware Python datetime.datetime object a  ^ # YYMMDD (?P\d{2}) (?P\d{2}) (?P\d{2}) # hhmm or hhmmss (?P\d{2}) (?P\d{2}) (?P\d{2})? # Matches nothing, needed because GeneralizedTime uses this. (?P) # Z or [-+]hhmm (?: (?PZ) | (?: (?P[-+]) (?P\d{2}) (?P\d{2}) ) ) $ c^t|tr|js td|j t }d|j cxkrdkstdtd|jd}tr|jd}tj||d|_ y)z Sets the value of the object :param value: A unicode string or a datetime.datetime object :raises: ValueError - when an invalid value is passed Must be timezone awareiizMYear of the UTCTime is not in range [1950, 2049], use GeneralizedTime insteadz %y%m%d%H%M%SZrN) r2rrrB astimezonerrstrftimerWrXrPrHrrs r*rHz UTCTime.sets eX &<< !9::$$\2E5::-- !pqq. !pqqNN?3E W-4' r+c^|ddkr|dxxdz cc<n |dxxdz cc<tdi|S)z Create a datetime object from the parsed time. :return: An aware datetime.datetime object r2iilr)rrLrs r*rzUTCTime._get_datetimes: &>B  6Nd "N 6Nd "N!&!!r+N rrrrr4recompileXrrHrrr+r*rrcs8 C RZZ!4 5N8<"r+rcZeZdZdZdZej dejZdZ dZ y)GeneralizedTimez Represents a generalized time from ASN.1 as a Python datetime.datetime object or asn1crypto.util.extended_datetime object in UTC aO ^ # YYYYMMDD (?P\d{4}) (?P\d{2}) (?P\d{2}) # hh or hhmm or hhmmss (?P\d{2}) (?: (?P\d{2}) (?P\d{2})? )? # Optional fraction; [.,]dddd (one or more decimals) # If Seconds are given, it's fractions of Seconds. # Else if Minutes are given, it's fractions of Minutes. # Else it's fractions of Hours. (?: [,.] (?P\d+) )? # Optional timezone. If left out, the time is in local time. # Z or [-+]hh or [-+]hhmm (?: (?PZ) | (?: (?P[-+]) (?P\d{2}) (?P\d{2})? ) )? $ ct|ttfr|js t d|j t }|jr7dt|jjdjdz}nd}|jd|zdz}tr|jd}tj||d |_y ) a Sets the value of the object :param value: A unicode string, a datetime.datetime object or an asn1crypto.util.extended_datetime object :raises: ValueError - when an invalid value is passed rrrrrWz %Y%m%d%H%M%SZrN)r2rrrrBrr microsecondstrzfillrrrWrXrPrHr)rLr8rs r*rHzGeneralizedTime.sets eh(9: ;<< !9::$$\2E  U%6%6!7!=!=a!@!G!G!LLNN>2X=CE W-4' r+c>|ddk(r tdi|Stdi|S)z Create a datetime object from the parsed time. :return: A datetime.datetime object or asn1crypto.util.extended_datetime object. It may or may not be aware. rrr)rrrs r*rzGeneralizedTime._get_datetimes, &>Q $.v. .%f% %r+Nrrr+r*rrs< C RZZ#!F G#NJB &r+rceZdZdZdZdZy) GraphicStringzK Represents a graphic string from ASN.1 as a Python unicode string rQNr#rr+r*rr CIr+rceZdZdZdZdZy) VisibleStringzK Represents a visible string from ASN.1 as a Python unicode string rQNr#rr+r*rr"rr+rceZdZdZdZdZy) GeneralStringzK Represents a general string from ASN.1 as a Python unicode string rQNr#rr+r*rr+rr+rceZdZdZdZdZy)UniversalStringzM Represents a universal string from ASN.1 as a Python unicode string z utf-32-beNr#rr+r*rr5 CIr+rceZdZdZdZdZy)CharacterStringzM Represents a character string from ASN.1 as a Python unicode string rQNr#rr+r*rr>rr+rceZdZdZdZdZy) BMPStringzG Represents a BMP string from ASN.1 as a Python unicode string z utf-16-beNr#rr+r*r!r!Hrr+r!c Pt|t|dt||jr@t|dt j |jxsdj d|jduxr|jduxr|jdu}|r>tj|j}tj|j}|j^|jD],\}}t|dtj|d|d.|rst|d d d |jnR|jr$|rDt|dd d|jd n"|r t|dd d|j|jr@t|d t j |jxsdj dt|d t j |j xsdj dy)a7 Prints out basic information about an Asn1Value object. Extracted for reuse among different classes that customize the debug information. :param prefix: A unicode string of spaces to prefix output line with :param self: The object to print the debugging information about r2z Header: 0xr+rfNz z tag z (explicitly tagged)z r`z (implicitly tagged)z Trailer: 0xz Data: 0x)rrrbrbinasciihexlifyrXrIrGr4r~r{rEr<r=rrJ)rrL has_header method_name class_namerGr4s r*rrQs vy4 AB || FH,<,Rs-S-Z-Z[b-cde fh&6&6t}}7K&L&S&ST[&\ ]^r+cd|vrT|ddk(r|jdd|df|d<n"|ddk(r|jdd|df|d<|d=|d=d|vr|d=yyy)z Converts old-style "tag_type" and "tag" params to "explicit" and "implicit" :param params: A dict of parameters to convert from tag_type/tag to explicit/implicit rNr<classr"r4r=N)r{)rs r*rrsV *  +"(**Wa"8&-!HF:  J : -"(**Wa"8&-!HF:  :  5M f w r+cft|d}d|vr|jdur^d}n[t|dtr |d\}}n|d}d}|jdurd}n'|jt |k7s|j |k7rd}|jd|jk7rd}|r|j|S|S)z Checks if a value is properly tagged based on the spec, and re/untags as necessary :param value: An Asn1Value object :param params: A dict of spec params :return: An Asn1Value that is properly tagged Fr=Tr r<) rr=r2rrGrFr4r{r<r})r8rr}rGr4s r*rrs#6* E >> &E fZ(% 0 ,KFC$CF >>U "E \\26: :eii3>NE zz*/ {{6"" Lr+cr|y|j}|j}t|d|vr$t|dtr |d\}}n/d}|d}n'd|vr#t|dtr |d\}}nd}|d}|t|t s t |}|jd|}|jd|}||fS)aP Builds a 2-element tuple used to identify fields by grabbing the class_ and tag from an Asn1Value class and the params dict being passed to it :param params: A dict of params to pass to spec :param spec: An Asn1Value class :return: A 2-element integer tuple in the form (class_, tag) rr<r"r=rGr4)rGr4rr2rrrFr{)rr0required_class required_tags r*rrs  |[[N88L"6*V fZ(% 0+1*+= (NLN!*-L v  fZ(% 0+1*+= (NLN!*-L!*^Y*O.~>ZZ.9N::e\2L L ))r+c |s|sytttt|dj|}t ||k7r$t djt |||S)z Format value as a tuple of 1s and 0s. :param value: A non-negative integer to format :param bits: Number of bits in the output :return: A tuple of 1s and 0s with bits members. rz0{0}bzResult too large: {0} > {1})rrrryrDrB)r8r|results r*rzrzs[  3sF5'..*>?@ AF 6{d6==c&k4PQQ Mr+rrrrvrtrrrr"r'r*rrr) rrrrrrrrrrr"c  | t||tSd} |a|xrd|v} | sx|js|rid|vrd|r |di|} n|} | j} t| } |}|}|}|}|}|xsd}| D]\}}||k7rGt t dt | tj|tj|||dk7rGt t dt | tjdtj||||k7r t t d t | ||t|t|\}}|\}}}}}}t| tr||z }||z}t|dd id } || _|| _| | _d } n|r |dd |i|} n || } |t"urnt| tr<| j%||| || j&z| _d}| j)n|| j.k7rQt t dt | tj| j.tj|||| j0k7r|dk(xr| j0dk(xr|dk(}|rt| t2sQt t dt | tj| j0tj|||| _d | _|| j6k7rt| j8t:r|| j8v}n|| j8k(}|skt t dt | | j6||rd|vrt=dd |i|}|j} |}|}|xsd}t| D]0\}}t|t|\}}|\}}}}}}||z }||z}2t|dd id } || jz| _| xj |xsdz c_| | _d } n|t>vr=t t dtj|tj||t>|}|||} |dk(xr| j0dk(xr|dk(}|rt| t2rd | _|| _| s|| _|xsd| _d| _ |r | j)|| S| S#tt*f$r=}|j,dd}|j,ddt | zzf|z|_|d}~wwxYw#tt*f$r=}|j,dd}|j,ddt | zzf|z|_|d}~wwxYw)a Builds an Asn1Value object generically, or using a spec with optional params :param class_: An integer representing the ASN.1 class :param method: An integer representing the ASN.1 method :param tag: An integer representing the ASN.1 tag :param header: A byte string of the ASN.1 header (class, method, tag, length) :param contents: A byte string of the ASN.1 value :param trailer: A byte string of any ASN.1 trailer (only used by indefinite length encodings) :param spec: A class derived from Asn1Value that defines what class_ and tag the value should have, and the semantics of the encoded value. The return value will be of this type. If omitted, the encoded value will be decoded using the standard universal tag based on the encoded tag number. :param spec_params: A dict of params to pass to the spec object :param nested_spec: For certain Asn1Value classes (such as OctetString and BitString), the contents can be further parsed and interpreted as another Asn1Value. This parameter controls the spec for that sub-parsing. :return: An object of the type spec, or if not specified, a child of Asn1Value NFrMr<r+z Error parsing %s - explicitly-tagged class should have been %s, but %s was found r z Error parsing %s - explicitly-tagged method should have been %s, but %s was found z Error parsing %s - explicitly-tagged tag should have been %s, but %s was found TrrJrrrz Error parsing %s - class should have been %s, but %s was found szy Error parsing %s - method should have been %s, but %s was found zv Error parsing %s - tag should have been %s, but %s was found zO Unknown element - %s class, %s method, tag %s )rJrGr)!rr0r<reversedrBr rrEr{r~rrDr2rrGrrrrrJrr3rKrGrIrrr4rrr'_UNIVERSAL_SPECSr)rGrIr4rrJtrailerr0r1 nested_spec header_setrMr8original_explicit explicit_info parsed_class parsed_method parsed_tagto_parseexplicit_headerexplicit_trailerexpected_class expected_tagrr9 parsed_headerparsed_trailerrRrK ber_indef is_bad_tagoriginal_values r*rGrG sR&{3 ~ J "Bm{&B  +*P[B[+{+ % $%67M!L"MJH$O&~# 0=, >1$V"%(-11.A-11, M&!A%$V"%(.2215.22=-P&-$V"%($"&!3x=9acg` mZR`!%0#}4O'58H'H$I1>LDt-9NOE+EM-EN.ENJ>h>+>h/s{E6*vsH5%+enn%c,45F,G (NLXs8}5GD!?C rWs,\SR( %DD(jjt- E D D   "**% &37l_7_7D**6)v)XN.FN.b393l vS1)S1lQ-YQ-h ^$V^$B |+ |+~N"]IN"b2i2jNiNbi!i!X|!=(Ix|~O!]HiO!d>(-9>BK -9K \N")N"bo$-9o$d1!01!h9>^y(^B y    9 AAH " z $yz $zD$D$Nw (w t J B ( NnN [ _>_DS"lS"l\&l\&~NNNnn,_^ &%P**Z0wwy{  t   zt      !"#$ 9@fR#Lr+