_eddlZddlZddlmZddlmZddlZddlZddlZGddZ GddZ Gdd e Z Gd d e Z dS) N)Optional) lru_cachec~eZdZdZddZdZeeddZeedd Z eedd Z eedd Z eed d e de fdZeddZdZdS)Schemec0d|_d|_g|_dSN)typenameimplementationsselfs 0/Users/thom/git/pqcrypto/pqclean/test/pqclean.py__init__zScheme.__init__ s  !..c^tj|d|jz|jS)Ncrypto_)ospathjoinr r r bases rrz Scheme.paths#w||D)di"7CCCrcd|jddS)Nz PQCLEAN_{}_-)formatr upperreplacer s rnamespace_prefixzScheme.namespace_prefixs2##DIOO$5$566>>sBGGGrNmaxsizec|tD]}|j|kr|cStd|)NzNo scheme for )r all_schemesr KeyError) scheme_nameschemes rby_namezScheme.by_namesQ((**  F{k)) *5 55666rcg}|td|td|S)Nkemsign)extendrall_schemes_of_type)schemess rr#zScheme.all_schemessNv11%88999v11&99:::rcvg}tD]}||j|Sr)rr#r,r )r r&s rall_implementationszScheme.all_implementations'sD((** ; ;F  " "6#9 : : : :rcHdtDS)Nc:g|]}||Ssupported_on_current_platform.0impls r z8Scheme.all_supported_implementations..2899955779999r)rr0r3rrall_supported_implementationsz$Scheme.all_supported_implementations/s.99!;!;!=!=999 9r r returncg}tjdd|z}tj|rtj|D]}tjtj||rS|dkr#|t |h|dkr#|t| |S)Nrrr*r+)rrrisdirlistdirappendKEM Signature)r r.pds rr-zScheme.all_schemes_of_type5s GLLy4/ 0 0 7==   /Z]] / /7==a!3!344/u}}s1vv....y||4444.rc\tj|d} t|d5}t j|}dddn #1swxYwY|S#t $r.}td||Yd}~dSd}~wwxYw)NzMETA.ymlzutf-8)encodingzCan't open {}: {}) rrropenyaml safe_load Exceptionprintr)r metafilefmetadataes rrOzScheme.metadataEs7<< Z88 h111 -Q>!,, - - - - - - - - - - - - - - -O    %,,Xq99 : : :44444 s;A3A& A3&A**A3-A*.A33 B+=#B&&B+cfd|j|jS)Nz<{}({})>)rr titler r s r__repr__zScheme.__repr__Ps&  !2!2DI>>>rr)__name__ __module__ __qualname__rrr staticmethodrr'r#r0r;strlistr-rOrSr3rrrr s""" DDDDHHHYt77\7 Yq\ Yq\ Yq99\9Yr # $   \ Yt?????rrceZdZdZeddZddefdZdefdZdegfd Z degfd Z degfd Z e edd Z e edd edefdZe d edefdZdZddeedefdZeddefdZdZdZdS)Implementationc"||_||_dSr)r&r )r r&r s rrzImplementation.__init__Vs  rNr ct|jdD]}|d|jkr|cSdS)Nr r )r&rOr )r is rrOzImplementation.metadataZsN%%''(9:  AyDI%%&  rrr=c~tj|j||jS)N)r)rrrr&r rs rrzImplementation.path`s-w||DK,,$,77CCCrctjdkr%d|jj|jSd|jj|jS)Nntz lib{}_{}.libz lib{}_{}.a)rr rr&r s rlibnamezImplementation.libnamecsG 7d??!(()949EE E""4;#3TY???rctjtj|dS)Nz*.cglobrrrr s rcfileszImplementation.cfilesh*ydiikk599:::rctjtj|dS)Nz*.hrer s rhfileszImplementation.hfileskrhrctjtj|tjdkrdndS)Nrbz*.oz*.obj)rfrrrr r s rofileszImplementation.ofilesnsHydiikk"$'T//w@@AA Arct|}|jD]}|j|kr|cSt d|d|)NzNo implementation for z - )rr'r r r$)r%implementation_namer&implementations rr'zImplementation.by_namersg ,,$4 & &N"&999%%%%:U UU@SUUVVVrr&c@g}tj|D]t}tjtj||r#|t ||u|Sr)rr@rr?rrAr\)r&r rEs rr0z"Implementation.all_implementations{sFKKMM** B BAw}}RW\\&++--;;<< B&&~fa'@'@AAArcJdt|DS)Nc:g|]}||Sr3r4r6s rr9z@Implementation.all_supported_implementations..r:r)r\r0)r&s rr;z,Implementation.all_supported_implementationss099!C!CF!K!K999 9rcd|j|jddS)Nz{}{}_rr)rr&rr rrr s rrzImplementation.namespace_prefixsG~~dk::<<"ioo//1118b1A1A Brrc|tj}|dgD]}d|vr ||dvrdSdS)zaCheck if we support the OS If no OS is specified, then we run on the current OS Nsupported_platformsoperating_systemsFT)platformsystemrOget)r r platform_s rsupported_on_oszImplementation.supported_on_ossg :""B,,-BBGG ! !I"i//Y':;;; 55tri'cPd|vrdStjdkrdS|sdSt j|dD]}|ddkr|ddkrYtjdd krPtjd kr$tj d d krtfd |dDrdSdS)NruTppcF architecturearchx86_64r32bitWindowsPLATFORMx86c3,K|]}|dvVdS)flagsNr3)r7flagcpuinfos r z?Implementation.supported_on_current_platform..sI@@ww//@@@@@@rrequired_flags) rOrwmachiner{helpers get_cpu_infolowerr~rxrenvironryall)r rzrs @rr5z,Implementation.supported_on_current_platformsG   7 74     & &5##%% 5&(()>? I(GFO,A,A,C,CCC^,88,..q1W<<  ))Y66 " z : :e C C @@@@#,-=#>@@@@@ 44urcLd|j|jjS)Nz{} implementation of {})rr r&r s r__str__zImplementation.__str__s(// 4;;KLLLrcLd|jj|jS)Nz)rr&r r s rrSzImplementation.__repr__s)001A49MMMrrTr)rUrVrWrrrOrYrrcrgrjrlrXr'rrZr0r;rrboolr{r5rrSr3rrr\r\Ts0Yt DDDDDD@@@@@ ;;;;;;;;;;AAAAAYtWW\WYtFt\9f9999\9BBB  (3- 4    Yut4MMMNNNNNrr\c6eZdZdefdZedefdZdS)rBr c`d|_||_t||_dSNr*r r r\r0r r r s rrz KEM.__init__s,  -AA$GGrr=c6tdSrrr-r3rrall_kemsz KEM.all_kemss))%000rN)rUrVrWrYrrXrZrr3rrrBrBs[HSHHHH 1d111\111rrBc0eZdZdefdZedZdS)rCr c`d|_||_t||_dSNr+rrs rrzSignature.__init__s,  -AA$GGrc6tdSrrr3rrall_sigszSignature.all_sigss))&111rN)rUrVrWrYrrXrr3rrrCrCsOHSHHHH 22\222rrC) rfrtypingr functoolsrrIrwrrr\rBrCr3rrrs  F?F?F?F?F?F?F?F?RgNgNgNgNgNgNgNgNT 1 1 1 1 1& 1 1 1 2 2 2 2 2 2 2 2 2 2r