tpm-key-attestation-0.10.0/0000755000175000017500000000000013751742042014544 5ustar pravipravitpm-key-attestation-0.10.0/SECURITY.md0000644000175000017500000000030313751742042016331 0ustar pravipravi# Security Policy ## Reporting a Vulnerability If you have discovered a security bug, please send an email to security@cedarcode.com instead of posting to the GitHub issue tracker. Thank you! tpm-key-attestation-0.10.0/lib/0000755000175000017500000000000013751742042015312 5ustar pravipravitpm-key-attestation-0.10.0/lib/tpm/0000755000175000017500000000000013751742042016112 5ustar pravipravitpm-key-attestation-0.10.0/lib/tpm/key_attestation/0000755000175000017500000000000013751742042021321 5ustar pravipravitpm-key-attestation-0.10.0/lib/tpm/key_attestation/version.rb0000644000175000017500000000014213751742042023330 0ustar pravipravi# frozen_string_literal: true module TPM class KeyAttestation VERSION = "0.10.0" end end tpm-key-attestation-0.10.0/lib/tpm/s_attest/0000755000175000017500000000000013751742042017740 5ustar pravipravitpm-key-attestation-0.10.0/lib/tpm/s_attest/s_certify_info.rb0000644000175000017500000000057613751742042023277 0ustar pravipravi# frozen_string_literal: true require "bindata" require "tpm/sized_buffer" require "tpm/tpm2b_name" module TPM class SAttest < BinData::Record # Section 10.12.3 in https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-01.38.pdf class SCertifyInfo < BinData::Record tpm2b_name :name sized_buffer :qualified_name end end end tpm-key-attestation-0.10.0/lib/tpm/s_attest.rb0000644000175000017500000000126013751742042020264 0ustar pravipravi# frozen_string_literal: true require "bindata" require "tpm/constants" require "tpm/sized_buffer" require "tpm/s_attest/s_certify_info" module TPM # Section 10.12.8 in https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-01.38.pdf class SAttest < BinData::Record class << self alias_method :deserialize, :read end endian :big uint32 :magic uint16 :attested_type sized_buffer :qualified_signer sized_buffer :extra_data # s_clock_info :clock_info # uint64 :firmware_version skip length: 25 choice :attested, selection: :attested_type do s_certify_info TPM::ST_ATTEST_CERTIFY end end end tpm-key-attestation-0.10.0/lib/tpm/t_public/0000755000175000017500000000000013751742042017713 5ustar pravipravitpm-key-attestation-0.10.0/lib/tpm/t_public/s_rsa_parms.rb0000644000175000017500000000057413751742042022557 0ustar pravipravi# frozen_string_literal: true require "bindata" module TPM class TPublic < BinData::Record # Section 12.2.3.5 in https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-01.38.pdf class SRsaParms < BinData::Record endian :big uint16 :symmetric uint16 :scheme uint16 :key_bits uint32 :exponent end end end tpm-key-attestation-0.10.0/lib/tpm/t_public/s_ecc_parms.rb0000644000175000017500000000056713751742042022526 0ustar pravipravi# frozen_string_literal: true require "bindata" module TPM class TPublic < BinData::Record # Section 12.2.3.6 in https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-01.38.pdf class SEccParms < BinData::Record endian :big uint16 :symmetric uint16 :scheme uint16 :curve_id uint16 :kdf end end end tpm-key-attestation-0.10.0/lib/tpm/certificates/0000755000175000017500000000000013751742042020557 5ustar pravipravitpm-key-attestation-0.10.0/lib/tpm/certificates/QC/0000755000175000017500000000000013751742042021062 5ustar pravipravitpm-key-attestation-0.10.0/lib/tpm/certificates/QC/RootCA/0000755000175000017500000000000013751742042022211 5ustar pravipravi././@LongLink0000644000000000000000000000015400000000000011603 Lustar rootroottpm-key-attestation-0.10.0/lib/tpm/certificates/QC/RootCA/Microsoft TPM Root Certificate Authority 2014.certpm-key-attestation-0.10.0/lib/tpm/certificates/QC/RootCA/Microsoft TPM Root Certificate Authority 20000644000175000017500000000277113751742042031733 0ustar pravipravi00ݠ]0N 'IiP]0  *H  01 0 UUS10U Washington10URedmond10U Microsoft Corporation1604U-Microsoft TPM Root Certificate Authority 20140 141210213119Z 391210213928Z01 0 UUS10U Washington10URedmond10U Microsoft Corporation1604U-Microsoft TPM Root Certificate Authority 20140"0  *H 0 ʷG!H,a?H)ۃaFaS*(`pn8 14w8. )*mTh!Ƶ`^#6+EVޗM"e6|N"<` 1LHw :, ^!_N|ו4sWò#* hyPqOkLj:XdHv/r~M\gNoπӄ򠧙NZic2Ʒi1צ傖pR͕wYtn;pj*Sܺ0߉xUPWEwؕ֙@|$#(C olR."DԹu$Uq.+!WTn sXXP\nxHc>5MuUY[XY0ղ}?ykAl/HL=ҵ٥$.zx#y}fTѤݭ4f67Lf9Vt$>dSƢ`Y#aނ?H)GK-SG<ЭcX=!r%z4/km9H˒liE‘JxslCl* fF}yC{!38Q娓M̫ҥZaߏ̇)wp2=tpm-key-attestation-0.10.0/lib/tpm/certificates/NationZ/0000755000175000017500000000000013751742042022141 5ustar pravipravitpm-key-attestation-0.10.0/lib/tpm/certificates/NationZ/RootCA/0000755000175000017500000000000013751742042023270 5ustar pravipravitpm-key-attestation-0.10.0/lib/tpm/certificates/NationZ/RootCA/EkRootCA.crt0000644000175000017500000000153613751742042025416 0ustar pravipravi-----BEGIN CERTIFICATE----- MIICRDCCAcqgAwIBAgIBATAKBggqhkjOPQQDAzBrMQswCQYDVQQGEwJDTjEhMB8G A1UECgwYTmF0aW9ueiBUZWNobm9sb2dpZXMgSW5jMRswGQYDVQQLDBJOYXRpb256 IFRQTSBEZXZpY2UxHDAaBgNVBAMME05hdGlvbnogVFBNIFJvb3QgQ0EwHhcNMTcw NTEyMDAwMDAwWhcNNDcwNTEzMDAwMDAwWjBrMQswCQYDVQQGEwJDTjEhMB8GA1UE CgwYTmF0aW9ueiBUZWNobm9sb2dpZXMgSW5jMRswGQYDVQQLDBJOYXRpb256IFRQ TSBEZXZpY2UxHDAaBgNVBAMME05hdGlvbnogVFBNIFJvb3QgQ0EwdjAQBgcqhkjO PQIBBgUrgQQAIgNiAATvuDTN8TNvp3A9fSjWpDARLmvz7ItQrDq/mmuzvzInwQfs YKUUJza4MXB3yS0PH1jjv1YMvaIBIalAgc+kahScQUy6W2fy6hd36pazmc/vQfG3 Gdhw56gGwRHx4rn4TuqjQjBAMB0GA1UdDgQWBBQ6vP8I314BDCtkB4vHzpUG9Aj9 5DAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNo ADBlAjApzqSmd4cCMKC7slJ4NE/7zweXZx89JzSEnEWGcq78jbbXCw6yM+R4nCNX phflI9QCMQCeFOAvyR+DQvThfGFINABej+1zeDVIjuZHat3FHVyV0UQVClPgMlZu TntipXwGOVY= -----END CERTIFICATE----- tpm-key-attestation-0.10.0/lib/tpm/certificates/Atmel/0000755000175000017500000000000013751742042021621 5ustar pravipravitpm-key-attestation-0.10.0/lib/tpm/certificates/Atmel/RootCA/0000755000175000017500000000000013751742042022750 5ustar pravipravitpm-key-attestation-0.10.0/lib/tpm/certificates/Atmel/RootCA/Atmel TPM Root Signing Module.der0000644000175000017500000000105713751742042030623 0ustar pravipravi0+0Рp?!nի2+ITx0 *H=0s1 0 UUS10UColorado10UColorado Springs10 U Atmel1&0$UAtmel TPM Root Signing Module0 101231000000Z 401231000000Z0s1 0 UUS10UColorado10UColorado Springs10 U Atmel1&0$UAtmel TPM Root Signing Module0Y0*H=*H=B}sfsGZ|k ՚̈^ 0\ ex gIi&6z|B@{lM[+ B0@0U0U00U1]m ["xW0 *H=I0F!۸ED\ThJG&ʎf!9q,\k_8-+`boVtpm-key-attestation-0.10.0/lib/tpm/certificates/Nuvoton/0000755000175000017500000000000013751742042022227 5ustar pravipravitpm-key-attestation-0.10.0/lib/tpm/certificates/Nuvoton/RootCA/0000755000175000017500000000000013751742042023356 5ustar pravipravitpm-key-attestation-0.10.0/lib/tpm/certificates/Nuvoton/RootCA/Nuvoton TPM Root CA 1014.cer0000644000175000017500000000162613751742042027665 0ustar pravipravi00zmtgz0  *H 0U1S0UNuvoton TPM Root CA 10140%U Nuvoton Technology Corporation0 UTW0 170821110336Z 370817110336Z0U1S0UNuvoton TPM Root CA 10140%U Nuvoton Technology Corporation0 UTW0"0  *H 0 wSvoLӵjp0[#xmI|nn>-%\z[T"Nz?:^ID<q.}~ :o'غZYĜh9 K;Dp5a<&9 DHjfWU]UFҼTdiJ4}m?jrr\n8kGu} R ڑf0d0U0U00U#0Gr`|0UGr`|0  *H BT1l C~:]]9#X"{KJ 塥X_f@wĨfN]Ldt]py 9d65jMQw ۋXc,T3nNHTwG>sVӉ~D|$>Ƕϱtpm-key-attestation-0.10.0/lib/tpm/certificates/Nuvoton/RootCA/Nuvoton TPM Root CA 2010.cer0000644000175000017500000000162613751742042027662 0ustar pravipravi00zX !0  *H 0U1S0UNuvoton TPM Root CA 20100%U Nuvoton Technology Corporation0 UTW0 150423065919Z 350419065919Z0U1S0UNuvoton TPM Root CA 20100%U Nuvoton Technology Corporation0 UTW0"0  *H 0 ƕQ9it{;gL eֿ=r{ ,7t(m^f0d0U0U00U#00C$ tP0U0C$ tP0  *H ғ'>hKyKB}y5cqQq$;g5 B:;X %(Ez3:ЏX18k1Uޛޗk`d( lu0J}sGP zu1?1+b릉|'cH#z+a:}raE\D(ui9X"RE[Uk^ 6"%Rp|FRg:5 [6fE'"[Z CY+\%Wtpm-key-attestation-0.10.0/lib/tpm/certificates/Nuvoton/RootCA/Nuvoton TPM Root CA 1013.cer0000644000175000017500000000162613751742042027664 0ustar pravipravi00zH |M0  *H 0U1S0UNuvoton TPM Root CA 10130%U Nuvoton Technology Corporation0 UTW0 150511084325Z 350507084325Z0U1S0UNuvoton TPM Root CA 10130%U Nuvoton Technology Corporation0 UTW0"0  *H 0 daSgў1zd@ޤHEcI6a TB?PߛΕF'}2ov ͅg {Ia-4WM|d{(*a"ӈ=g?'(87!aVeqDYCQ[ N:V:_cٷ(M'<_s'l?D_+Phngl}5 \AX R%PeM-Չi=f0d0U0U00U#07)* k/C0U7)* k/C0  *H \c=`J!kZZ "H&o]{Lgv93Im 3 Af)דF.!b=!Dd :-򟋭(L]VHri5xy8Ŋj%dW{ .&8e},+` ޴!L0S0g{p=a OE.M8FW*>ݫ9M oU!Z޽:ytpm-key-attestation-0.10.0/lib/tpm/certificates/Nuvoton/RootCA/NTC TPM EK Root CA ARSUF 01.cer0000644000175000017500000000153513751742042027614 0ustar pravipravi0Y0A %An:0  *H 0X1V0"UNTC TPM EK Root CA ARSUF 010%U Nuvoton Technology Corporation0 UTW0 140401183438Z 340328183438Z0X1V0"UNTC TPM EK Root CA ARSUF 010%U Nuvoton Technology Corporation0 UTW0"0  *H 0 ɣlʪʤQ6R`#HS lrU44%>2E[ʔUH *3XΆ=Y+Ο_W{q"L(Ɩxa\?B`f}npi+|Mst"ٓN 43yj,&zfe 0I ߔ(ZPݦv/-/C@ ED~/w6LJqEXᄞnV%ۅqx.&0$0U0U00  *H {zdn32>r)&BO<Q[7=o>isE0joaKj6/͕X-CQᗯMXe?gϿnY'19-[ؿJuV2|t A 3w\ߑf E`JO91rWD!*j_7izi&Rq%ps[}X{ dTorImOi2[a'-$rIL?${FJ"Щ'tpm-key-attestation-0.10.0/lib/tpm/certificates/Nuvoton/RootCA/Nuvoton TPM Root CA 1111.cer0000644000175000017500000000101313751742042027651 0ustar pravipravi00 ܽ%0 *H=0U1S0UNuvoton TPM Root CA 11110%U Nuvoton Technology Corporation0 UTW0 170821033253Z 370817033253Z0U1S0UNuvoton TPM Root CA 11110%U Nuvoton Technology Corporation0 UTW0Y0*H=*H=Br q =QLCTUQs 9ƑuFW~G`avRU6r)ҋ<6N >f0d0U0U00U/{_1 ǻUG0U#0/{_1 ǻUG0 *H=H0E!ʄ_!pQdA6`})ufG(H C慕m~);ꦤ /obbDtpm-key-attestation-0.10.0/lib/tpm/certificates/Nuvoton/RootCA/NTC TPM EK Root CA 02.cer0000644000175000017500000000151613751742042026753 0ustar pravipravi0J02c0  *H 0R1P0UNTC TPM EK Root CA 020%U Nuvoton Technology Corporation0 UTW0 120711163324Z 320711163324Z0R1P0UNTC TPM EK Root CA 020%U Nuvoton Technology Corporation0 UTW0"0  *H 0 jhSՀ6aDʻ3) ϖ8D/Š_+`m[7{C,̘ge _+V4j L8S'fvyTڊj q;q>#Gg9 Ù6j{aMG;5haa6fsqnQvYZt"3EYʫɔ7&0$0U0U00  *H ,+VpR[QaTrATX[ !4Fi#ъOP:Ȳ\'E׸hۈ0>B9/yvy݈ۅ= %&jZ!S%}M޻+*Kٸ:@~g@WV={l: 0{/PJLVI(d}و1+!8U >0XCv|B8A>GE !tJe'8stpm-key-attestation-0.10.0/lib/tpm/certificates/Nuvoton/RootCA/Nuvoton TPM Root CA 1110.cer0000644000175000017500000000101213751742042027647 0ustar pravipravi008dc0 *H=0U1S0UNuvoton TPM Root CA 11100%U Nuvoton Technology Corporation0 UTW0 150511084333Z 350507084333Z0U1S0UNuvoton TPM Root CA 11100%U Nuvoton Technology Corporation0 UTW0Y0*H=*H=B5dn#Wfxw$N u&3ÂOSDboUFp" ߠφcwf0d0U0U00UԶKi`w0U#0ԶKi`w0 *H=H0E!rsy],A*O h*C g"?g'/V7PLީbDtpm-key-attestation-0.10.0/lib/tpm/certificates/Nuvoton/RootCA/Nuvoton TPM Root CA 2011.cer0000644000175000017500000000162613751742042027663 0ustar pravipravi00z('y0  *H 0U1S0UNuvoton TPM Root CA 20110%U Nuvoton Technology Corporation0 UTW0 170911071012Z 370907071012Z0U1S0UNuvoton TPM Root CA 20110%U Nuvoton Technology Corporation0 UTW0"0  *H 0 ˲.aYg=mG^>\Ya.MיΰLȍ9a?WC(( xt2Rᨤr=Qk6 ȴ<Ξʄ+2EDWX"LJ10}I3#-e A.w~ pȴn99~⹧𴻜ds'q\_*35L}$;;ߋ뇞!'Ag:&0$0U0U00  *H AC9<,/^IJW~mwP<"JRMU(c{ /]2'AZ+m@F9?.DwwpWכ$e6 le]Oڽt[czO ~Kf7͔Oε53;^5G=nh,qU3Vlܟ/u!V\|ڡ l97B*l_S>takie nhnŘ &тtpm-key-attestation-0.10.0/lib/tpm/certificates/Nuvoton/RootCA/Nuvoton TPM Root CA 2110.cer0000644000175000017500000000101213751742042027650 0ustar pravipravi00?/<0 *H=0U1S0UNuvoton TPM Root CA 21100%U Nuvoton Technology Corporation0 UTW0 151019043200Z 351015043200Z0U1S0UNuvoton TPM Root CA 21100%U Nuvoton Technology Corporation0 UTW0Y0*H=*H=B6o?b266WE{x2"%7WX=Ǯc,ɭ7$$f0d0U0U00UyRbxPqqj50U#0yRbxPqqj50 *H=H0E!8#Rte]ŢHJTn (>zxph6hHtpm-key-attestation-0.10.0/lib/tpm/certificates/Nuvoton/RootCA/Nuvoton TPM Root CA 2111.cer0000644000175000017500000000101313751742042027652 0ustar pravipravi00 Qk10 *H=0U1S0UNuvoton TPM Root CA 21110%U Nuvoton Technology Corporation0 UTW0 170911070949Z 370907070949Z0U1S0UNuvoton TPM Root CA 21110%U Nuvoton Technology Corporation0 UTW0Y0*H=*H=Bڜܰ>A?Dgc,,;l'Asv n(͍9} od$ƥf0d0U0U00U#*Ӿ7JDrJRW.0U#0#*Ӿ7JDrJRW.0 *H=H0E ^mN, _bQ7g6J̠p.(!,YW+\pխCV]ݯ M2N$tpm-key-attestation-0.10.0/lib/tpm/certificates/Microsoft/0000755000175000017500000000000013751742042022524 5ustar pravipravitpm-key-attestation-0.10.0/lib/tpm/certificates/Microsoft/RootCA/0000755000175000017500000000000013751742042023653 5ustar pravipravi././@LongLink0000644000000000000000000000016300000000000011603 Lustar rootroottpm-key-attestation-0.10.0/lib/tpm/certificates/Microsoft/RootCA/Microsoft TPM Root Certificate Authority 2014.certpm-key-attestation-0.10.0/lib/tpm/certificates/Microsoft/RootCA/Microsoft TPM Root Certificate Auth0000644000175000017500000000277113751742042032164 0ustar pravipravi00ݠ]0N 'IiP]0  *H  01 0 UUS10U Washington10URedmond10U Microsoft Corporation1604U-Microsoft TPM Root Certificate Authority 20140 141210213119Z 391210213928Z01 0 UUS10U Washington10URedmond10U Microsoft Corporation1604U-Microsoft TPM Root Certificate Authority 20140"0  *H 0 ʷG!H,a?H)ۃaFaS*(`pn8 14w8. )*mTh!Ƶ`^#6+EVޗM"e6|N"<` 1LHw :, ^!_N|ו4sWò#* hyPqOkLj:XdHv/r~M\gNoπӄ򠧙NZic2Ʒi1צ傖pR͕wYtn;pj*Sܺ0߉xUPWEwؕ֙@|$#(C olR."DԹu$Uq.+!WTn sXXP\nxHc>5MuUY[XY0ղ}?ykAl/HL=ҵ٥$.zx#y}fTѤݭ4f67Lf9Vt$>dSƢ`Y#aނ?H)GK-SG<ЭcX=!r%z4/km9H˒liE‘JxslCl* fF}yC{!38Q娓M̫ҥZaߏ̇)wp2=tpm-key-attestation-0.10.0/lib/tpm/certificates/Infineon/0000755000175000017500000000000013751742042022324 5ustar pravipravitpm-key-attestation-0.10.0/lib/tpm/certificates/Infineon/RootCA/0000755000175000017500000000000013751742042023453 5ustar pravipravitpm-key-attestation-0.10.0/lib/tpm/certificates/Infineon/RootCA/IFX-RootCA.cer0000644000175000017500000000177313751742042025731 0ustar pravipravi00ߠsq/ˑ =K(0  *H 01 0 UUS10U VeriSign, Inc.1;09U 2VeriSign Trusted Computing Certification Authority110/U(VeriSign Trusted Platform Module Root CA0 051025000000Z 451024235959Z01 0 UUS10U VeriSign, Inc.1;09U 2VeriSign Trusted Computing Certification Authority110/U(VeriSign Trusted Platform Module Root CA0"0  *H 0 Pk@{cUs!9ep~$ᝥL?˕{;dJd y9HqԦ&=0v/#]7\B]YoOP=-.Dii(ؔķ=,%fwB$=ۏ6eUd/WΩ _EZl d6}qOF99MdE+xn~tpm-key-attestation-0.10.0/lib/tpm/certificates/Infineon/RootCA/Infineon OPTIGA(TM) RSA Root CA.crt0000644000175000017500000000265713751742042031050 0ustar pravipravi000  *H  0w1 0 UDE1!0U Infineon Technologies AG10U OPTIGA(TM) Devices1(0&U Infineon OPTIGA(TM) RSA Root CA0 130726000000Z 430725235959Z0w1 0 UDE1!0U Infineon Technologies AG10U OPTIGA(TM) Devices1(0&U Infineon OPTIGA(TM) RSA Root CA0"0  *H 0 S31;B5\{܀4*E(g۔Tkh MP{KzfXLr8WD8b .Ap +GqH!:n"/vGa˟,g%R{bd&W&Pd5 Y?lc3z#ւeI~9ׇKq|I#fX|xbH,GdWx.zPHVDGԅ9@^9+$`765F{#rzVD/Tr7SnSEsF#*׋#m߈hܲ1Q}'׃p\!Rv&}=X0R}!^p sm0Gn'&Oro ѕINܔC3sPwe҂>r2`IHm$2i,pĀKiQ.V *n "/5㬍kIB0@0UܻVueA0U0U00  *H  aLw2`,R[U/fcJ SJ4!3H2wTއ%7X DD?-W[A`*yqzv$ #:>2DKn)-9e}⓫Z Fce6#4HKL#!fjkatkY(qY$ ;` >KwC)_K/!>؞H([+YY(0K:nsK|Ʉ~p u/ 6 dɯHajêC+J;*!XBFNkՕ%<‹ڸ땮`GkLݫيdL!KsɆ HdFgg2u!EwIq*zql N0)Lw(Lcp2Zlu;(CqɤSӑͫŮRTJ \ļ}0 z;`n(ː(1h&TsuyTwZ>eS2l"TjTr6K LZ iu٬yHtpm-key-attestation-0.10.0/lib/tpm/certificates/Infineon/RootCA/IFX_TPM_RootCert_008.crt0000644000175000017500000000241713751742042027547 0ustar pravipravi0 0r0  *H 01 0 U DE10 U Saxony10U Dresden1!0U Infineon Technologies AG10U Infineon SMS10U Infineon TPM CA 0080 031120000000Z 181120235959Z01 0 U DE10 U Saxony10U Dresden1!0U Infineon Technologies AG10U Infineon SMS10U Infineon TPM CA 0080"0  *H 0 XC|$7vEmL@ךǹÛ!*SsPQ ik㘎6Y$uG$c&K0ON>#UG 3"A$J,̾r#yBfKGRI ?/ +i*1)1b%8`_r _@&wj1c+F/DG'n_s&hBlU,NbM>"Z`)aǖg?heZp~ԆAEXKz0v0UѠGJ:L۾0 U0U00U 00*D0s09+-http://www.infineon.com/tpm/CertificatePolicy06+0* (TCPA Trusted Platform Module Endorsement0U#001 0 U DE10 U Saxony10U Dresden1!0U Infineon Technologies AG10U Infineon SMS10U Infineon TPM CA 008r0  *H o,j\F?]I:P&UrhCEwl~ς`2gC(< n6 b&6>jEG];D웮I~] AZtap[wr=8e9[֊/u)]"}uO#|J1`a * p3f߰ K|1r!ןdiFo;ptpm-key-attestation-0.10.0/lib/tpm/certificates/Infineon/RootCA/IFX TPM EK Root CA.cer0000644000175000017500000000212413751742042026644 0ustar pravipravi0P08G$!?} ͇HZ0  *H 01 0 UUS10U VeriSign, Inc.1;09U 2VeriSign Trusted Computing Certification Authority110/U(VeriSign Trusted Platform Module Root CA0 051025000000Z 301024235959Z0m1 0 UDE10UBavaria1!0U Infineon Technologies AG1 0 U AIM10UIFX TPM EK Root CA0"0  *H 0 &jX4Amt+-O/hÿK ԓ= 0Yd:*w<$O+D٭aw XVE*MbrK`ngJ ɋVaE5$9uC-7YVQ"%00U00XU N0L0J `HE/0;09+-http://www.verisign.com/repository/index.html0U0UVDcrE TB0U#0 D&7Eo0  *H X|ٓyoM5GpOϷO|E-7]suw0Fo>v~-WMiJf/B^M?PDłC׿:~õ /)fg-O: [&^)aG00LU E0C0A +2Z0402+&https://www.globalsign.com/repository/0 *H=g0d0Z{<2u!rSз\U6rrt7V0bL-ǕרKV6HVg1c|w GL11tpm-key-attestation-0.10.0/lib/tpm/certificates/STMicro/RootCA/GlobalSign Trusted Computing CA.crt0000644000175000017500000000173313751742042031572 0ustar pravipravi00   0  *H  01;09U 2GlobalSign Trusted Computing Certificate Authority10U  GlobalSign1301U*GlobalSign Trusted Platform Module Root CA0 090318100000Z 490318100000Z01;09U 2GlobalSign Trusted Computing Certificate Authority10U  GlobalSign1301U*GlobalSign Trusted Platform Module Root CA0"0  *H 0 -0$ڶƅqC̈r=ǁU#DZQ_c3drx3ǯ[v= (ghӈ!_b?NséAuR)6Bxؿ8tW/~y1b{宲9]R 1v٨12iS eknd././@LongLink0000644000000000000000000000016200000000000011602 Lustar rootroottpm-key-attestation-0.10.0/lib/tpm/certificates/STMicro/RootCA/GlobalSign Trusted Platform Module ECC Root CA.crttpm-key-attestation-0.10.0/lib/tpm/certificates/STMicro/RootCA/GlobalSign Trusted Platform Module EC0000644000175000017500000000126713751742042032036 0ustar pravipravi00:EܜYFKy0 *H=01;09U 2GlobalSign Trusted Computing Certificate Authority10U  GlobalSign1705U.GlobalSign Trusted Platform Module ECC Root CA0 141126000000Z 380119031407Z01;09U 2GlobalSign Trusted Computing Certificate Authority10U  GlobalSign1705U.GlobalSign Trusted Platform Module ECC Root CA0v0*H=+"b5:lCP?zwU9xk}z-9SVŔ>bk҆-zHf_uKqX2zPYw3!rt;2Wu|2Ǵ~rEc0a0U0U00Ua> [&^)aG00U#0a> [&^)aG00 *H=g0d0wMZ7PgS'E >U. |P߲{04Ǥtt {h"<ʮ L"Bd3a6..Nctpm-key-attestation-0.10.0/lib/tpm/certificates/STMicro/RootCA/ST TPM Root Certificate.crt0000644000175000017500000000202013751742042030010 0ustar pravipravi0 0 "l~0  *H  01;09U 2GlobalSign Trusted Computing Certificate Authority10U  GlobalSign1301U*GlobalSign Trusted Platform Module Root CA0 090728120000Z 391231235959Z0J1 0 UCH10U STMicroelectronics NV10USTM TPM EK Root CA0"0  *H 0 }'C,+zm[vI!<ǠrϤfzyElKmtk5- x jpokx">V²)ʹ5q}hWAtn3@J)MQ ZVEYz ՓjO.RgP \Zo"Qٕ[&=`ҾW00U0# +7+8~rc0U8~rc0U008+,0*0(+0http://ftpm.amd.com/pki/ocsp0,U%0#0!http://ftpm.amd.com/pki/crl0CU <0:08 +xe 0*0(+https://ftpm.amd.com/pki/cps0 *H=H0E!ErX+A1 p 5>ӗ@mm=:4m[t!$zR=!>&tpm-key-attestation-0.10.0/lib/tpm/certificates/AMD/RootCA/AMD-fTPM-RSA-RootCA.crt0000644000175000017500000000221413751742042025775 0ustar pravipravi00p&M9<][IN!0  *H  0v10U  Engineering1 0 UUS10U Sunnyvale1 0 UCA10U Advanced Micro Devices10 UAMDTPM0 141023143432Z 391023143432Z0v10U  Engineering1 0 UUS10U Sunnyvale1 0 UCA10U Advanced Micro Devices10 UAMDTPM0"0  *H 0 BMV}x-P @Dw%s+TP ɬ+|p/Ғy:6ON .i7c)Q$ ({=xR@#WRDIzc߾ggaW[U,,2n9OvLfzOK Y7d<-^ Z8+[So)qg0xM`D̛+带A 0 0U0# +7+WT_yiQB!x_h/0UWT_yiQB!x_h/0U008+,0*0(+0http://ftpm.amd.com/pki/ocsp0,U%0#0!http://ftpm.amd.com/pki/crl0=U 60402U 0*0(+https://ftpm.amd.com/pki/cps0  *H  ܀c'i٬1 7pw zT`vXqn{Ȉ`Q҇zFMk4֤.Hi[0̨0՛O7 !/>Geav;/2LMe!E+8[iu߁/9=MZ9>Osb=A;[2%֒-(iPKШ09^+ngd|hJ[.13@Ybi/jctpm-key-attestation-0.10.0/lib/tpm/certificates/Intel/0000755000175000017500000000000013751742042021632 5ustar pravipravitpm-key-attestation-0.10.0/lib/tpm/certificates/Intel/RootCA/0000755000175000017500000000000013751742042022761 5ustar pravipravitpm-key-attestation-0.10.0/lib/tpm/certificates/Intel/RootCA/EKRootPublicKey.cer0000644000175000017500000000117313751742042026431 0ustar pravipravi0w0O#"F;ݷ~(@O0 *H=01 0 U US1 0 U CA10U Santa Clara10U Intel Corporation1!0U TPM EK root cert signing10U www.intel.com0 140115000000Z 491231235959Z01 0 U US1 0 U CA10U Santa Clara10U Intel Corporation1!0U TPM EK root cert signing10U www.intel.com0Y0*H=*H=B}Q,Jo?v]}l)W!CC߶[Oa hV:TŞf0d0U#0ROե!G {[w0UROե!G {[w0U00U0 *H=G0D %tTY=b pd 2 ,o!E%Fx6TN1Hdtpm-key-attestation-0.10.0/lib/tpm/tpm2b_name.rb0000644000175000017500000000051113751742042020460 0ustar pravipravi# frozen_string_literal: true require "bindata" require "tpm/tpmt_ha" module TPM class Tpm2bName < BinData::Record endian :big uint16 :name_size, value: lambda { name.to_binary_s.size } tpmt_ha :name, read_length: :name_size def valid_for?(other_name) name.to_binary_s == other_name end end end tpm-key-attestation-0.10.0/lib/tpm/key_attestation.rb0000644000175000017500000000506013751742042021647 0ustar pravipravi# frozen_string_literal: true require "openssl" require "tpm/key_attestation/version" require "tpm/aik_certificate" require "tpm/certify_validator" require "tpm/constants" require "tpm/public_area" module TPM class KeyAttestation # https://docs.microsoft.com/en-us/windows-server/security/guarded-fabric-shielded-vm/guarded-fabric-install-trusted-tpm-root-certificates ROOT_CERTIFICATES = begin pattern = File.expand_path(File.join(__dir__, "certificates", "*", "RootCA", "*.*")) Dir.glob(pattern).map do |filename| File.open(filename) { |file| OpenSSL::X509::Certificate.new(file) } end end class Error < StandardError; end attr_reader( :certify_info, :signature, :certified_key, :certificates, :signature_algorithm, :hash_algorithm, :qualifying_data, :root_certificates ) def initialize( certify_info, signature, certified_key, certificates, qualifying_data, signature_algorithm: ALG_RSASSA, hash_algorithm: ALG_SHA256, root_certificates: ROOT_CERTIFICATES ) @certify_info = certify_info @signature = signature @certified_key = certified_key @certificates = certificates @signature_algorithm = signature_algorithm @hash_algorithm = hash_algorithm @qualifying_data = qualifying_data @root_certificates = root_certificates end def key if valid? public_area.key end end def valid? certify_validator.valid?(aik_certificate.public_key) && aik_certificate.conformant? && trustworthy? end private def certify_validator @certify_validator ||= TPM::CertifyValidator.new( certify_info, signature, qualifying_data, public_area, signature_algorithm: signature_algorithm, hash_algorithm: hash_algorithm ) end def trustworthy? x509_certificates = certificates.map { |c| OpenSSL::X509::Certificate.new(c) } trust_store.verify(x509_certificates[0], x509_certificates[1..-1]) end def trust_store @trust_store ||= OpenSSL::X509::Store.new.tap do |trust_store| root_certificates.uniq(&:serial).each { |root_certificate| trust_store.add_cert(root_certificate) } end end def aik_certificate @aik_certificate ||= TPM::AIKCertificate.from_der(certificates.first) end def public_area @public_area ||= TPM::PublicArea.new(certified_key) end end end tpm-key-attestation-0.10.0/lib/tpm/tpmt_ha.rb0000644000175000017500000000064213751742042020075 0ustar pravipravi# frozen_string_literal: true require "bindata" module TPM class TpmtHa < BinData::Record BYTE_LENGTH = 8 DIGEST_LENGTH_SHA1 = 160 DIGEST_LENGTH_SHA256 = 256 endian :big uint16 :hash_alg choice :digest, selection: :hash_alg do string TPM::ALG_SHA1, length: DIGEST_LENGTH_SHA1 / BYTE_LENGTH string TPM::ALG_SHA256, length: DIGEST_LENGTH_SHA256 / BYTE_LENGTH end end end tpm-key-attestation-0.10.0/lib/tpm/t_public.rb0000644000175000017500000000453213751742042020244 0ustar pravipravi# frozen_string_literal: true require "bindata" require "openssl" require "tpm/constants" require "tpm/sized_buffer" require "tpm/t_public/s_ecc_parms" require "tpm/t_public/s_rsa_parms" module TPM # Section 12.2.4 in https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-01.38.pdf class TPublic < BinData::Record BYTE_LENGTH = 8 CURVE_TPM_TO_OPENSSL = { TPM::ECC_NIST_P256 => "prime256v1", TPM::ECC_NIST_P384 => "secp384r1", TPM::ECC_NIST_P521 => "secp521r1", }.freeze BN_BASE = 2 RSA_KEY_DEFAULT_PUBLIC_EXPONENT = 2**16 + 1 ECC_UNCOMPRESSED_POINT_INDICATOR = "\x04" class << self alias_method :deserialize, :read end endian :big uint16 :alg_type uint16 :name_alg # :object_attributes skip length: 4 sized_buffer :auth_policy choice :parameters, selection: :alg_type do s_ecc_parms TPM::ALG_ECC s_rsa_parms TPM::ALG_RSA end choice :unique, selection: :alg_type do sized_buffer TPM::ALG_ECC sized_buffer TPM::ALG_RSA end def rsa? alg_type == TPM::ALG_RSA end def ecc? alg_type == TPM::ALG_ECC end def key if parameters.symmetric == TPM::ALG_NULL if ecc? ecc_key elsif rsa? rsa_key else raise "Type #{alg_type} not supported" end end end def openssl_curve_name if ecc? CURVE_TPM_TO_OPENSSL[parameters.curve_id] || raise("Unknown curve #{parameters.curve_id}") end end private def ecc_key if parameters.scheme == TPM::ALG_ECDSA group = OpenSSL::PKey::EC::Group.new(openssl_curve_name) key = OpenSSL::PKey::EC.new(group) key.public_key = OpenSSL::PKey::EC::Point.new(group, bn(ECC_UNCOMPRESSED_POINT_INDICATOR + unique.buffer.value)) key end end def rsa_key case parameters.scheme when TPM::ALG_RSASSA, TPM::ALG_RSAPSS, TPM::ALG_NULL n = unique.buffer.value if parameters.key_bits / BYTE_LENGTH == n.size key = OpenSSL::PKey::RSA.new(parameters.key_bits.value) key.set_key(bn(n), bn(RSA_KEY_DEFAULT_PUBLIC_EXPONENT), nil) key.public_key end end end def bn(data) if data OpenSSL::BN.new(data, BN_BASE) end end end end tpm-key-attestation-0.10.0/lib/tpm/public_area.rb0000644000175000017500000000136513751742042020712 0ustar pravipravi# frozen_string_literal: true require "openssl" require "tpm/t_public" module TPM TPM_TO_OPENSSL_HASH_ALG = { TPM::ALG_SHA1 => "SHA1", TPM::ALG_SHA256 => "SHA256" }.freeze class PublicArea attr_reader :object def initialize(object) @object = object end def name [name_alg].pack("n") + name_digest end def key t_public.key end def ecc? t_public.ecc? end def openssl_curve_name t_public.openssl_curve_name end private def name_digest OpenSSL::Digest.digest(TPM_TO_OPENSSL_HASH_ALG[name_alg], object) end def name_alg t_public.name_alg end def t_public @t_public ||= TPM::TPublic.deserialize(object) end end end tpm-key-attestation-0.10.0/lib/tpm/constants.rb0000644000175000017500000000242213751742042020453 0ustar pravipravi# frozen_string_literal: true module TPM # Section 6 in https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-01.38.pdf GENERATED_VALUE = 0xFF544347 ST_ATTEST_CERTIFY = 0x8017 # Algorithms ALG_RSA = 0x0001 ALG_SHA1 = 0x0004 ALG_SHA256 = 0x000B ALG_SHA384 = 0x000C ALG_SHA512 = 0x000D ALG_NULL = 0x0010 ALG_RSASSA = 0x0014 ALG_RSAPSS = 0x0016 ALG_ECDSA = 0x0018 ALG_ECC = 0x0023 # ECC curves ECC_NIST_P256 = 0x0003 ECC_NIST_P384 = 0x0004 ECC_NIST_P521 = 0x0005 # https://trustedcomputinggroup.org/resource/vendor-id-registry/ section 2 "TPM Capabilities Vendor ID (CAP_VID)" VENDOR_IDS = { "id:414D4400" => "AMD", "id:41544D4C" => "Atmel", "id:4252434D" => "Broadcom", "id:49424D00" => "IBM", "id:49465800" => "Infineon", "id:494E5443" => "Intel", "id:4C454E00" => "Lenovo", "id:4E534D20" => "National Semiconductor", "id:4E545A00" => "Nationz", "id:4E544300" => "Nuvoton Technology", "id:51434F4D" => "Qualcomm", "id:534D5343" => "SMSC", "id:53544D20" => "ST Microelectronics", "id:534D534E" => "Samsung", "id:534E5300" => "Sinosun", "id:54584E00" => "Texas Instruments", "id:57454300" => "Winbond", "id:524F4343" => "Fuzhou Rockchip", }.freeze end tpm-key-attestation-0.10.0/lib/tpm/sized_buffer.rb0000644000175000017500000000052413751742042021107 0ustar pravipravi# frozen_string_literal: true require "bindata" module TPM # Section 10.4 in https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-01.38.pdf class SizedBuffer < BinData::Record endian :big uint16 :buffer_size, value: lambda { buffer.size } string :buffer, read_length: :buffer_size end end tpm-key-attestation-0.10.0/lib/tpm/aik_certificate.rb0000644000175000017500000000531313751742042021547 0ustar pravipravi# frozen_string_literal: true require "delegate" require "openssl" require "tpm/constants" module TPM # Section 3.2 in https://www.trustedcomputinggroup.org/wp-content/uploads/Credential_Profile_EK_V2.0_R14_published.pdf class AIKCertificate < SimpleDelegator ASN_V3 = 2 EMPTY_NAME = OpenSSL::X509::Name.new([]).freeze SAN_DIRECTORY_NAME = 4 OID_TCG = "2.23.133" OID_TCG_AT_TPM_MANUFACTURER = "#{OID_TCG}.2.1" OID_TCG_AT_TPM_MODEL = "#{OID_TCG}.2.2" OID_TCG_AT_TPM_VERSION = "#{OID_TCG}.2.3" OID_TCG_KP_AIK_CERTIFICATE = "#{OID_TCG}.8.3" def self.from_der(certificate_der) new(OpenSSL::X509::Certificate.new(certificate_der)) end def conformant? in_use? && valid_version? && valid_extended_key_usage? && valid_basic_constraints? && empty_subject? && valid_subject_alternative_name? end private def in_use? now = Time.now not_before < now && now < not_after end def valid_version? version == ASN_V3 end def valid_basic_constraints? basic_constraints = extension("basicConstraints") basic_constraints && basic_constraints.value == "CA:FALSE" && basic_constraints.critical? end def valid_extended_key_usage? extended_key_usage = extension("extendedKeyUsage") extended_key_usage && extended_key_usage.value == OID_TCG_KP_AIK_CERTIFICATE && !extended_key_usage.critical? end def empty_subject? subject.eql?(EMPTY_NAME) end def valid_subject_alternative_name? if san_extension san_extension.critical? && !tpm_manufacturer.empty? && TPM::VENDOR_IDS[tpm_manufacturer] && !tpm_model.empty? && !tpm_version.empty? end end def extension(oid) extensions.detect { |ext| ext.oid == oid } end def tpm_manufacturer if san_name san_name.assoc(OID_TCG_AT_TPM_MANUFACTURER).at(1) end end def tpm_model if san_name san_name.assoc(OID_TCG_AT_TPM_MODEL).at(1) end end def tpm_version if san_name san_name.assoc(OID_TCG_AT_TPM_VERSION).at(1) end end def san_name if san_extension san_asn1 = OpenSSL::ASN1.decode(san_extension).find do |val| val.tag_class == :UNIVERSAL && val.tag == OpenSSL::ASN1::OCTET_STRING end directory_name = OpenSSL::ASN1.decode(san_asn1.value).find do |val| val.tag_class == :CONTEXT_SPECIFIC && val.tag == SAN_DIRECTORY_NAME end OpenSSL::X509::Name.new(directory_name.value.first).to_a end end def san_extension extension("subjectAltName") end end end tpm-key-attestation-0.10.0/lib/tpm/certify_validator.rb0000644000175000017500000000432113751742042022151 0ustar pravipravi# frozen_string_literal: true require "openssl/signature_algorithm" require "tpm/constants" require "tpm/s_attest" module TPM class CertifyValidator attr_reader :info, :signature, :nonce, :public_area, :signature_algorithm, :hash_algorithm TPM_SIGNATURE_ALG_TO_OPENSSL = { ALG_RSASSA => OpenSSL::SignatureAlgorithm::RSAPKCS1, ALG_RSAPSS => OpenSSL::SignatureAlgorithm::RSAPSS, ALG_ECDSA => OpenSSL::SignatureAlgorithm::ECDSA }.freeze TPM_HASH_ALG_TO_OPENSSL = { ALG_SHA1 => "SHA1", ALG_SHA256 => "SHA256", ALG_SHA384 => "SHA384", ALG_SHA512 => "SHA512" }.freeze def initialize(info, signature, nonce, public_area, signature_algorithm: ALG_RSASSA, hash_algorithm: ALG_SHA256) @info = info @signature = signature @nonce = nonce @public_area = public_area @signature_algorithm = signature_algorithm @hash_algorithm = hash_algorithm end def valid?(signing_key) valid_info? && valid_signature?(signing_key) end private def valid_info? attest.attested_type == TPM::ST_ATTEST_CERTIFY && attest.extra_data.buffer == nonce && attest.magic == TPM::GENERATED_VALUE && attest.attested.name.valid_for?(public_area.name) end def valid_signature?(verify_key) openssl_signature_algorithm = openssl_signature_algorithm_class.new(**openssl_signature_algorithm_parameters) openssl_signature_algorithm.verify_key = verify_key openssl_signature_algorithm.verify(signature, info) rescue OpenSSL::SignatureAlgorithm::Error false end def attest @attest ||= TPM::SAttest.deserialize(info) end def openssl_signature_algorithm_parameters parameters = { hash_function: openssl_hash_function } if public_area.ecc? parameters[:curve] = public_area.openssl_curve_name end parameters end def openssl_hash_function TPM_HASH_ALG_TO_OPENSSL[hash_algorithm] || raise("Unsupported hash algorithm #{hash_algorithm}") end def openssl_signature_algorithm_class TPM_SIGNATURE_ALG_TO_OPENSSL[signature_algorithm] || raise("Unsupported signature algorithm #{signature_algorithm}") end end end tpm-key-attestation-0.10.0/.travis.yml0000644000175000017500000000145613751742042016663 0ustar pravipravi--- dist: bionic language: ruby cache: bundler: true directories: - /home/travis/.rvm/ env: - RB=2.7.1 LIBSSL=1.0 - RB=2.7.1 LIBSSL=1.1 - RB=2.6.6 LIBSSL=1.0 - RB=2.6.6 LIBSSL=1.1 - RB=2.5.8 LIBSSL=1.0 - RB=2.5.8 LIBSSL=1.1 - RB=2.4.10 LIBSSL=1.0 - RB=2.4.10 LIBSSL=1.1 - RB=ruby-head LIBSSL=1.0 - RB=ruby-head LIBSSL=1.1 gemfile: - gemfiles/openssl_head.gemfile - gemfiles/openssl_2_2.gemfile - gemfiles/openssl_2_1.gemfile - gemfiles/openssl_2_0.gemfile - gemfiles/openssl_default.gemfile matrix: fast_finish: true allow_failures: - env: RB=ruby-head LIBSSL=1.0 - env: RB=ruby-head LIBSSL=1.1 - gemfile: gemfiles/openssl_head.gemfile before_install: - ./install-openssl.sh - ./install-ruby.sh - gem install bundler -v "~> 2.0" - rm Gemfile.lock tpm-key-attestation-0.10.0/.rubocop.yml0000644000175000017500000000466413751742042017030 0ustar pravipraviAllCops: TargetRubyVersion: 2.4 DisabledByDefault: true Exclude: - "gemfiles/**/*" Bundler: Enabled: true Gemspec: Enabled: true Layout: Enabled: true Layout/LineLength: Max: 120 Lint: Enabled: true Naming: Enabled: true Security: Enabled: true Style/BlockComments: Enabled: true Style/CaseEquality: Enabled: true Style/ClassAndModuleChildren: Enabled: true Style/ClassMethods: Enabled: true Style/ClassVars: Enabled: true Style/CommentAnnotation: Enabled: true Style/ConditionalAssignment: Enabled: true Style/DefWithParentheses: Enabled: true Style/Dir: Enabled: true Style/EachForSimpleLoop: Enabled: true Style/EachWithObject: Enabled: true Style/EmptyBlockParameter: Enabled: true Style/EmptyCaseCondition: Enabled: true Style/EmptyElse: Enabled: true Style/EmptyLambdaParameter: Enabled: true Style/EmptyLiteral: Enabled: true Style/EvenOdd: Enabled: true Style/ExpandPathArguments: Enabled: true Style/For: Enabled: true Style/FrozenStringLiteralComment: Enabled: true Style/GlobalVars: Enabled: true Style/HashSyntax: Enabled: true Style/IdenticalConditionalBranches: Enabled: true Style/IfInsideElse: Enabled: true Style/InverseMethods: Enabled: true Style/MethodCallWithoutArgsParentheses: Enabled: true Style/MethodDefParentheses: Enabled: true Style/MultilineMemoization: Enabled: true Style/MutableConstant: Enabled: true Style/NestedParenthesizedCalls: Enabled: true Style/OptionalArguments: Enabled: true Style/ParenthesesAroundCondition: Enabled: true Style/RedundantBegin: Enabled: true Style/RedundantConditional: Enabled: true Style/RedundantException: Enabled: true Style/RedundantFreeze: Enabled: true Style/RedundantInterpolation: Enabled: true Style/RedundantParentheses: Enabled: true Style/RedundantPercentQ: Enabled: true Style/RedundantReturn: Enabled: true Style/RedundantSelf: Enabled: true Style/Semicolon: Enabled: true Style/SingleLineMethods: Enabled: true Style/SpecialGlobalVars: Enabled: true Style/SymbolLiteral: Enabled: true Style/TrailingBodyOnClass: Enabled: true Style/TrailingBodyOnMethodDefinition: Enabled: true Style/TrailingBodyOnModule: Enabled: true Style/TrailingMethodEndStatement: Enabled: true Style/TrivialAccessors: Enabled: true Style/UnpackFirst: Enabled: true Style/YodaCondition: Enabled: true Style/ZeroLengthPredicate: Enabled: true tpm-key-attestation-0.10.0/Gemfile0000644000175000017500000000040313751742042016034 0ustar pravipravi# frozen_string_literal: true source "https://rubygems.org" # Specify your gem's dependencies in tpm-key_attestation.gemspec gemspec gem "appraisal", "~> 2.2.0" gem "byebug", "~> 11.0" gem "rake", "~> 13.0" gem "rspec", "~> 3.0" gem "rubocop", "~> 0.80.1" tpm-key-attestation-0.10.0/install-ruby.sh0000755000175000017500000000043313751742042017530 0ustar pravipravisource ~/.rvm/scripts/rvm if [[ "${LIBSSL}" == "1.0" ]]; then rvm install $RB --autolibs=read-only -C --with-openssl-dir=usr/include/openssl elif [[ "${LIBSSL}" == "1.1" ]]; then rvm install $RB --binary --fuzzy fi rvm use $RB ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION' tpm-key-attestation-0.10.0/README.md0000644000175000017500000000331713751742042016027 0ustar pravipravi# tpm-key_attestation TPM Key Attestation utitlies [![Gem](https://img.shields.io/gem/v/tpm-key_attestation.svg?style=flat-square&color=informational)](https://rubygems.org/gems/tpm-key_attestation) [![Travis](https://img.shields.io/travis/cedarcode/tpm-key_attestation/master.svg?style=flat-square)](https://travis-ci.org/cedarcode/tpm-key_attestation) [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-informational.svg?style=flat-square)](https://conventionalcommits.org) ## Installation Add this line to your application's Gemfile: ```ruby gem 'tpm-key_attestation' ``` And then execute: $ bundle install Or install it yourself as: $ gem install tpm-key_attestation ## Usage ```ruby key_attestation = TPM::KeyAttestation.new( certify_info, signature, certified_object, signing_key, quilifying_data, signature_algorithm: TPM::ALG_RSAPSS # Supported values: TPM::ALG_RSAPSS, TPM::ALG_RSASSA, TPM::ALG_ECDSA (default TPM::ALG_RSASSA) ) if key_attestation.valid? key_attestation.key end ``` ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/cedarcode/tpm-key_attestation. tpm-key-attestation-0.10.0/install-openssl.sh0000755000175000017500000000023313751742042020230 0ustar pravipraviif [[ "${LIBSSL}" == "1.0" ]]; then sudo apt purge libssl-dev && sudo apt-get -yq --no-install-suggests --no-install-recommends install libssl1.0-dev fi tpm-key-attestation-0.10.0/Appraisals0000644000175000017500000000051213751742042016564 0ustar pravipravi# frozen_string_literal: true appraise "openssl_head" do gem "openssl", git: "https://github.com/ruby/openssl" end appraise "openssl_2_2" do gem "openssl", "~> 2.2.0" end appraise "openssl_2_1" do gem "openssl", "~> 2.1.0" end appraise "openssl_2_0" do gem "openssl", "~> 2.0.0" end appraise "openssl_default" do end tpm-key-attestation-0.10.0/CHANGELOG.md0000644000175000017500000000431113751742042016354 0ustar pravipravi# Changelog ## [v0.10.0] - 2020-07-09 ### Added - Support ECDSA with NIST P384 and P521 curves ## [v0.9.0] - 2020-05-31 ### Fixed - Fixed compatibility with OpenSSL-C (libssl) v1.0.2 ([@santiagorodriguez96]) ## [v0.8.0] - 2020-03-29 ### Changed - Update `openssl-signature_algorithm` gem dependency from `v0.3` to `v0.4`. ## [v0.7.0] - 2020-02-25 ### Added - `TPM::KeyAttestation#valid?` performs certificate path validation. In other words, it verifies trust up to an acceptable trusted root certificate. ### Changed - Rename `TPM::EKCertificate` to `TPM::AIKCertificate` to fix semantics ## [v0.6.0] - 2020-01-30 ### Changed - `TPM::KeyAttestation.new` now accepts `signature_algorithm` and `hash_algorithm` in TPM format in replacement of `JOSE` format `algorithm` string ## [v0.5.0] - 2020-01-23 ### Added - `TPM::KeyAttestation#valid?` also checks there's at least a well-formatted key in the attestation ## [v0.4.0] - 2020-01-20 ### Added - Suport verification of RSA-PSS key attestations ## [v0.3.0] - 2020-01-20 ### Added - `TPM::KeyAttestation#key` returns attested key as an instance of `OpenSSL::PKey::PKey` ## [v0.2.0] - 2020-01-16 ### Added - `TPM::KeyAttestation#valid?` ## [v0.1.0] - 2020-01-15 ### Added - `TPM::EKCertificate` wrapper - `TPM::SAttest` wrapper [v0.10.0]: https://github.com/cedarcode/tpm-key_attestation/compare/v0.9.0...v0.10.0/ [v0.9.0]: https://github.com/cedarcode/tpm-key_attestation/compare/v0.8.0...v0.9.0/ [v0.8.0]: https://github.com/cedarcode/tpm-key_attestation/compare/v0.7.0...v0.8.0/ [v0.7.0]: https://github.com/cedarcode/tpm-key_attestation/compare/v0.6.0...v0.7.0/ [v0.6.0]: https://github.com/cedarcode/tpm-key_attestation/compare/v0.5.0...v0.6.0/ [v0.5.0]: https://github.com/cedarcode/tpm-key_attestation/compare/v0.4.0...v0.5.0/ [v0.4.0]: https://github.com/cedarcode/tpm-key_attestation/compare/v0.3.0...v0.4.0/ [v0.3.0]: https://github.com/cedarcode/tpm-key_attestation/compare/v0.2.0...v0.3.0/ [v0.2.0]: https://github.com/cedarcode/tpm-key_attestation/compare/v0.1.0...v0.2.0/ [v0.1.0]: https://github.com/cedarcode/tpm-key_attestation/compare/57c926ef7e83830cee8d111fdc5ccaf99ab2e861...v0.1.0/ [@santiagorodriguez96]: https://github.com/santiagorodriguez96 tpm-key-attestation-0.10.0/.gitignore0000644000175000017500000000023313751742042016532 0ustar pravipravi/.bundle/ /.yardoc /_yardoc/ /coverage/ /doc/ /pkg/ /spec/reports/ /tmp/ # rspec failure tracking .rspec_status /gemfiles/*.gemfile.lock .byebug_history tpm-key-attestation-0.10.0/Gemfile.lock0000644000175000017500000000251613751742042016772 0ustar pravipraviPATH remote: . specs: tpm-key_attestation (0.10.0) bindata (~> 2.4) openssl-signature_algorithm (~> 1.0) GEM remote: https://rubygems.org/ specs: appraisal (2.2.0) bundler rake thor (>= 0.14.0) ast (2.4.1) bindata (2.4.7) byebug (11.1.3) diff-lcs (1.4.4) jaro_winkler (1.5.4) openssl-signature_algorithm (1.0.0) parallel (1.19.2) parser (2.7.1.4) ast (~> 2.4.1) rainbow (3.0.0) rake (13.0.1) rexml (3.2.4) rspec (3.9.0) rspec-core (~> 3.9.0) rspec-expectations (~> 3.9.0) rspec-mocks (~> 3.9.0) rspec-core (3.9.2) rspec-support (~> 3.9.3) rspec-expectations (3.9.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.9.0) rspec-mocks (3.9.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.9.0) rspec-support (3.9.3) rubocop (0.80.1) jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.7.0.1) rainbow (>= 2.2.2, < 4.0) rexml ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 1.7) ruby-progressbar (1.10.1) thor (1.0.1) unicode-display_width (1.6.1) PLATFORMS ruby DEPENDENCIES appraisal (~> 2.2.0) byebug (~> 11.0) rake (~> 13.0) rspec (~> 3.0) rubocop (~> 0.80.1) tpm-key_attestation! BUNDLED WITH 2.1.4 tpm-key-attestation-0.10.0/gemfiles/0000755000175000017500000000000013751742042016337 5ustar pravipravitpm-key-attestation-0.10.0/gemfiles/openssl_2_2.gemfile0000644000175000017500000000036113751742042022016 0ustar pravipravi# This file was generated by Appraisal source "https://rubygems.org" gem "appraisal", "~> 2.2.0" gem "byebug", "~> 11.0" gem "rake", "~> 13.0" gem "rspec", "~> 3.0" gem "rubocop", "~> 0.80.1" gem "openssl", "~> 2.2.0" gemspec path: "../" tpm-key-attestation-0.10.0/gemfiles/openssl_2_1.gemfile0000644000175000017500000000036113751742042022015 0ustar pravipravi# This file was generated by Appraisal source "https://rubygems.org" gem "appraisal", "~> 2.2.0" gem "byebug", "~> 11.0" gem "rake", "~> 13.0" gem "rspec", "~> 3.0" gem "rubocop", "~> 0.80.1" gem "openssl", "~> 2.1.0" gemspec path: "../" tpm-key-attestation-0.10.0/gemfiles/openssl_head.gemfile0000644000175000017500000000041513751742042022335 0ustar pravipravi# This file was generated by Appraisal source "https://rubygems.org" gem "appraisal", "~> 2.2.0" gem "byebug", "~> 11.0" gem "rake", "~> 13.0" gem "rspec", "~> 3.0" gem "rubocop", "~> 0.80.1" gem "openssl", git: "https://github.com/ruby/openssl" gemspec path: "../" tpm-key-attestation-0.10.0/gemfiles/openssl_default.gemfile0000644000175000017500000000032713751742042023062 0ustar pravipravi# This file was generated by Appraisal source "https://rubygems.org" gem "appraisal", "~> 2.2.0" gem "byebug", "~> 11.0" gem "rake", "~> 13.0" gem "rspec", "~> 3.0" gem "rubocop", "~> 0.80.1" gemspec path: "../" tpm-key-attestation-0.10.0/gemfiles/openssl_2_0.gemfile0000644000175000017500000000036113751742042022014 0ustar pravipravi# This file was generated by Appraisal source "https://rubygems.org" gem "appraisal", "~> 2.2.0" gem "byebug", "~> 11.0" gem "rake", "~> 13.0" gem "rspec", "~> 3.0" gem "rubocop", "~> 0.80.1" gem "openssl", "~> 2.0.0" gemspec path: "../" tpm-key-attestation-0.10.0/bin/0000755000175000017500000000000013751742042015314 5ustar pravipravitpm-key-attestation-0.10.0/bin/setup0000755000175000017500000000020313751742042016375 0ustar pravipravi#!/usr/bin/env bash set -euo pipefail IFS=$'\n\t' set -vx bundle install # Do any other automated setup that you need to do here tpm-key-attestation-0.10.0/bin/console0000755000175000017500000000060013751742042016700 0ustar pravipravi#!/usr/bin/env ruby # frozen_string_literal: true require "bundler/setup" require "tpm/key_attestation" # You can add fixtures and/or initialization code here to make experimenting # with your gem easier. You can also use a different console, if you like. # (If you use this, don't forget to add pry to your Gemfile!) # require "pry" # Pry.start require "irb" IRB.start(__FILE__) tpm-key-attestation-0.10.0/LICENSE0000644000175000017500000002613513751742042015560 0ustar pravipravi Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. tpm-key-attestation-0.10.0/Rakefile0000644000175000017500000000031713751742042016212 0ustar pravipravi# frozen_string_literal: true require "bundler/gem_tasks" require "rspec/core/rake_task" require "rubocop/rake_task" RSpec::Core::RakeTask.new(:spec) RuboCop::RakeTask.new task default: [:rubocop, :spec] tpm-key-attestation-0.10.0/tpm-key_attestation.gemspec0000644000175000017500000000226213751742042022120 0ustar pravipravi# frozen_string_literal: true require_relative 'lib/tpm/key_attestation/version' Gem::Specification.new do |spec| spec.name = "tpm-key_attestation" spec.version = TPM::KeyAttestation::VERSION spec.authors = ["Gonzalo"] spec.license = "Apache-2.0" spec.summary = "TPM Key Attestation verifier" spec.homepage = "https://github.com/cedarcode/tpm-key_attestation" spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0") spec.metadata["homepage_uri"] = spec.homepage spec.metadata["source_code_uri"] = spec.homepage spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md" # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. spec.files = Dir.chdir(File.expand_path(__dir__)) do `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } end spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] spec.add_dependency "bindata", "~> 2.4" spec.add_dependency "openssl-signature_algorithm", "~> 1.0" end tpm-key-attestation-0.10.0/.rspec0000644000175000017500000000005513751742042015661 0ustar pravipravi--color --require spec_helper --order random