file_parser-test.cc 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426
  1. /*############################################################################
  2. # Copyright 2016 Intel Corporation
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ############################################################################*/
  16. /// 1.1 issuer material file parsing unit tests.
  17. /*!
  18. * \file
  19. */
  20. #include <cstdint>
  21. #include <vector>
  22. #include "gtest/gtest.h"
  23. extern "C" {
  24. #include "epid/common/1.1/file_parser.h"
  25. }
  26. namespace {
  27. /// Test fixture class for Epid11FileParser
  28. class Epid11FileParser : public ::testing::Test {
  29. public:
  30. /// Cert used to sign legitimate test data
  31. static const EpidCaCertificate kCert;
  32. /// A file with Epid11GroupPublicKey signed with kCert
  33. static const std::vector<uint8_t> kGroupPublicKeyFile;
  34. /// A file with two Epid11GroupPublicKey signed with kCert
  35. static const std::vector<uint8_t> kGroupMultiPublicKeyFile;
  36. /// Expected Epid11GroupPublicKey
  37. static const std::vector<uint8_t> kGroupPublicKey;
  38. /// A file with empty privrl signed with kCert
  39. static const std::vector<uint8_t> kEmptyPrivRlFile;
  40. /// Expected empty privrl
  41. static const std::vector<uint8_t> kEmptyPrivRl;
  42. /// A file with short privrl signed with kCert
  43. static const std::vector<uint8_t> kShortPrivRlFile;
  44. /// Expected short privrl
  45. static const std::vector<uint8_t> kShortPrivRl;
  46. /// A file with empty SigRl signed with kCert
  47. static const std::vector<uint8_t> kEmptySigRlFile;
  48. /// Expected empty SigRl
  49. static const std::vector<uint8_t> kEmptySigRl;
  50. /// A file with short SigRl signed with kCert
  51. static const std::vector<uint8_t> kShortSigRlFile;
  52. /// Expected short SigRl
  53. static const std::vector<uint8_t> kShortSigRl;
  54. /// A file with empty GroupRl signed with kCert
  55. static const std::vector<uint8_t> kEmptyGroupRlFile;
  56. /// Expected empty GroupRl
  57. static const std::vector<uint8_t> kEmptyGroupRl;
  58. /// A file with short GroupRl signed with kCert
  59. static const std::vector<uint8_t> kShortGroupRlFile;
  60. /// Expected short GroupRl
  61. static const std::vector<uint8_t> kShortGroupRl;
  62. };
  63. const EpidCaCertificate Epid11FileParser::kCert = {
  64. // EpidFileHeader::epid_version
  65. 0x02, 0x00,
  66. // EpidFileHeader::file_type
  67. 0x00, 0x11,
  68. // pubkey
  69. 0x24, 0x42, 0xa5, 0xcc, 0x0e, 0xcd, 0x01, 0x5f, 0xa3, 0xca, 0x31, 0xdc,
  70. 0x8e, 0x2b, 0xbc, 0x70, 0xbf, 0x42, 0xd6, 0x0c, 0xbc, 0xa2, 0x00, 0x85,
  71. 0xe0, 0x82, 0x2c, 0xb0, 0x42, 0x35, 0xe9, 0x70, 0x6f, 0xc9, 0x8b, 0xd7,
  72. 0xe5, 0x02, 0x11, 0xa4, 0xa2, 0x71, 0x02, 0xfa, 0x35, 0x49, 0xdf, 0x79,
  73. 0xeb, 0xcb, 0x4b, 0xf2, 0x46, 0xb8, 0x09, 0x45, 0xcd, 0xdf, 0xe7, 0xd5,
  74. 0x09, 0xbb, 0xfd, 0x7d,
  75. // prime
  76. 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
  77. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
  78. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  79. // a
  80. 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
  81. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
  82. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc,
  83. // b
  84. 0x5a, 0xc6, 0x35, 0xd8, 0xaa, 0x3a, 0x93, 0xe7, 0xb3, 0xeb, 0xbd, 0x55,
  85. 0x76, 0x98, 0x86, 0xbc, 0x65, 0x1d, 0x06, 0xb0, 0xcc, 0x53, 0xb0, 0xf6,
  86. 0x3b, 0xce, 0x3c, 0x3e, 0x27, 0xd2, 0x60, 0x4b,
  87. // x
  88. 0x6b, 0x17, 0xd1, 0xf2, 0xe1, 0x2c, 0x42, 0x47, 0xf8, 0xbc, 0xe6, 0xe5,
  89. 0x63, 0xa4, 0x40, 0xf2, 0x77, 0x03, 0x7d, 0x81, 0x2d, 0xeb, 0x33, 0xa0,
  90. 0xf4, 0xa1, 0x39, 0x45, 0xd8, 0x98, 0xc2, 0x96,
  91. // y
  92. 0x4f, 0xe3, 0x42, 0xe2, 0xfe, 0x1a, 0x7f, 0x9b, 0x8e, 0xe7, 0xeb, 0x4a,
  93. 0x7c, 0x0f, 0x9e, 0x16, 0x2b, 0xce, 0x33, 0x57, 0x6b, 0x31, 0x5e, 0xce,
  94. 0xcb, 0xb6, 0x40, 0x68, 0x37, 0xbf, 0x51, 0xf5,
  95. // r
  96. 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
  97. 0xff, 0xff, 0xff, 0xff, 0xbc, 0xe6, 0xfa, 0xad, 0xa7, 0x17, 0x9e, 0x84,
  98. 0xf3, 0xb9, 0xca, 0xc2, 0xfc, 0x63, 0x25, 0x51,
  99. // signature::x
  100. 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, 0xed, 0x2a,
  101. 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, 0x70, 0x2a, 0x6c, 0x06,
  102. 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7,
  103. // signature::y
  104. 0x94, 0x03, 0x1d, 0x90, 0x6b, 0x6f, 0xcd, 0x99, 0xef, 0x2c, 0xdb, 0x8b,
  105. 0xa9, 0x8a, 0xef, 0x7e, 0xf0, 0x77, 0xba, 0xb5, 0x11, 0x43, 0x0d, 0x28,
  106. 0x1c, 0x01, 0x5b, 0xc9, 0x08, 0xce, 0x3e, 0x68};
  107. const std::vector<uint8_t> Epid11FileParser::kGroupPublicKeyFile = {
  108. // Epid Version
  109. 0x01, 0x00,
  110. // Epid type
  111. 0x00, 0x0c,
  112. // GID
  113. 0x00, 0x00, 0x00, 0x7b,
  114. // h1
  115. 0x08, 0x4a, 0x9d, 0x2e, 0xf9, 0x4f, 0x78, 0x02, 0xd7, 0x89, 0x75, 0xb4,
  116. 0xe7, 0x25, 0x26, 0x9f, 0x00, 0x57, 0xad, 0x33, 0x30, 0xea, 0xa9, 0x6c,
  117. 0x00, 0x9e, 0x8b, 0xc8, 0x13, 0x23, 0xcb, 0x06, 0x04, 0xbe, 0x42, 0x74,
  118. 0x11, 0x07, 0xb1, 0x06, 0xd7, 0xef, 0x5f, 0x66, 0x87, 0xd9, 0xfa, 0xdd,
  119. 0x53, 0xae, 0xd7, 0xf4, 0x54, 0xf8, 0xd0, 0x21, 0x75, 0xe0, 0x07, 0x44,
  120. 0xc9, 0xc3, 0x4e, 0xf7,
  121. // h2
  122. 0x06, 0xd8, 0xa9, 0x90, 0x02, 0x8f, 0xca, 0xa5, 0x73, 0x36, 0x24, 0x03,
  123. 0xc9, 0xa8, 0x7e, 0x9d, 0x64, 0x12, 0xac, 0xa7, 0xbd, 0x17, 0x7f, 0x7c,
  124. 0x96, 0x8d, 0x2e, 0x13, 0xd9, 0xb2, 0x69, 0x47, 0x09, 0xdb, 0xe3, 0xbf,
  125. 0xbc, 0xa1, 0x34, 0x0f, 0xc6, 0xe2, 0x00, 0x3d, 0x98, 0xa3, 0x7d, 0xab,
  126. 0xd4, 0x0e, 0xec, 0xde, 0x4f, 0x97, 0xa9, 0xbb, 0xdd, 0x60, 0x94, 0x24,
  127. 0x7b, 0xb3, 0xf5, 0x94,
  128. // w
  129. 0x02, 0x43, 0x78, 0x9f, 0x54, 0xc1, 0x21, 0x3a, 0x2b, 0x4d, 0x12, 0x65,
  130. 0x2f, 0x51, 0x94, 0xc6, 0x34, 0x24, 0xd9, 0x7b, 0x06, 0x3a, 0xc4, 0xf5,
  131. 0x56, 0xeb, 0x32, 0xe3, 0xee, 0x7b, 0xad, 0x6b, 0x04, 0x90, 0x86, 0x31,
  132. 0x18, 0x2a, 0xa4, 0xcf, 0xa3, 0x90, 0xa5, 0x80, 0x7b, 0xae, 0x3b, 0xb1,
  133. 0x77, 0x03, 0xe7, 0x7e, 0xf2, 0xfc, 0x6d, 0x3a, 0xab, 0x8f, 0xbf, 0x95,
  134. 0x40, 0xed, 0x08, 0x03, 0x01, 0x05, 0x86, 0xf5, 0x42, 0xea, 0x4d, 0xf7,
  135. 0x4f, 0xef, 0x46, 0xdf, 0x8f, 0xe8, 0x2d, 0xbb, 0x5d, 0x0d, 0x2f, 0x4f,
  136. 0xf4, 0xd8, 0x31, 0xc6, 0x5a, 0x97, 0x98, 0x44, 0xcf, 0x42, 0x5a, 0xf3,
  137. 0x03, 0x5f, 0xb6, 0x38, 0x45, 0x5a, 0x15, 0x1e, 0xb9, 0x54, 0xfa, 0x2c,
  138. 0x3f, 0x68, 0x7b, 0x4e, 0x85, 0x35, 0xf3, 0x5b, 0xe5, 0xdc, 0x96, 0x2b,
  139. 0x18, 0x84, 0x5e, 0x1e, 0x53, 0xdc, 0x22, 0x23, 0x06, 0x08, 0x91, 0x5a,
  140. 0x2d, 0x27, 0xe2, 0x12, 0x69, 0xfa, 0xab, 0x19, 0x7c, 0x47, 0x6b, 0xec,
  141. 0xde, 0xc6, 0x25, 0xd4, 0x43, 0xb4, 0x65, 0x23, 0x61, 0x0f, 0x1f, 0x2d,
  142. 0xfd, 0xb1, 0x18, 0xb0, 0x04, 0x8e, 0x1a, 0xc5, 0x95, 0x9a, 0x0e, 0x37,
  143. 0x7c, 0x5e, 0x95, 0x38, 0xc2, 0xcf, 0xfa, 0x1f, 0xe3, 0x3a, 0x2b, 0x85,
  144. 0xa5, 0xfd, 0x6b, 0xc4, 0x1d, 0xfb, 0x47, 0x27, 0xaf, 0xc1, 0x94, 0xcd,
  145. // Signature
  146. 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, 0xed, 0x2a,
  147. 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, 0x70, 0x2a, 0x6c, 0x06,
  148. 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, 0xf0, 0x6e, 0x43, 0x67,
  149. 0x68, 0x6f, 0x9e, 0x3b, 0xcf, 0xfd, 0x98, 0xcc, 0xae, 0x92, 0xcc, 0x94,
  150. 0x23, 0xb6, 0xbd, 0x57, 0xac, 0x06, 0x3c, 0xa1, 0xe5, 0x3e, 0xe9, 0xf5,
  151. 0x0e, 0x55, 0xb4, 0xe5};
  152. const std::vector<uint8_t> Epid11FileParser::kGroupPublicKey = {
  153. // GID
  154. 0x00, 0x00, 0x00, 0x7b,
  155. // h1
  156. 0x08, 0x4a, 0x9d, 0x2e, 0xf9, 0x4f, 0x78, 0x02, 0xd7, 0x89, 0x75, 0xb4,
  157. 0xe7, 0x25, 0x26, 0x9f, 0x00, 0x57, 0xad, 0x33, 0x30, 0xea, 0xa9, 0x6c,
  158. 0x00, 0x9e, 0x8b, 0xc8, 0x13, 0x23, 0xcb, 0x06, 0x04, 0xbe, 0x42, 0x74,
  159. 0x11, 0x07, 0xb1, 0x06, 0xd7, 0xef, 0x5f, 0x66, 0x87, 0xd9, 0xfa, 0xdd,
  160. 0x53, 0xae, 0xd7, 0xf4, 0x54, 0xf8, 0xd0, 0x21, 0x75, 0xe0, 0x07, 0x44,
  161. 0xc9, 0xc3, 0x4e, 0xf7,
  162. // h2
  163. 0x06, 0xd8, 0xa9, 0x90, 0x02, 0x8f, 0xca, 0xa5, 0x73, 0x36, 0x24, 0x03,
  164. 0xc9, 0xa8, 0x7e, 0x9d, 0x64, 0x12, 0xac, 0xa7, 0xbd, 0x17, 0x7f, 0x7c,
  165. 0x96, 0x8d, 0x2e, 0x13, 0xd9, 0xb2, 0x69, 0x47, 0x09, 0xdb, 0xe3, 0xbf,
  166. 0xbc, 0xa1, 0x34, 0x0f, 0xc6, 0xe2, 0x00, 0x3d, 0x98, 0xa3, 0x7d, 0xab,
  167. 0xd4, 0x0e, 0xec, 0xde, 0x4f, 0x97, 0xa9, 0xbb, 0xdd, 0x60, 0x94, 0x24,
  168. 0x7b, 0xb3, 0xf5, 0x94,
  169. // w
  170. 0x02, 0x43, 0x78, 0x9f, 0x54, 0xc1, 0x21, 0x3a, 0x2b, 0x4d, 0x12, 0x65,
  171. 0x2f, 0x51, 0x94, 0xc6, 0x34, 0x24, 0xd9, 0x7b, 0x06, 0x3a, 0xc4, 0xf5,
  172. 0x56, 0xeb, 0x32, 0xe3, 0xee, 0x7b, 0xad, 0x6b, 0x04, 0x90, 0x86, 0x31,
  173. 0x18, 0x2a, 0xa4, 0xcf, 0xa3, 0x90, 0xa5, 0x80, 0x7b, 0xae, 0x3b, 0xb1,
  174. 0x77, 0x03, 0xe7, 0x7e, 0xf2, 0xfc, 0x6d, 0x3a, 0xab, 0x8f, 0xbf, 0x95,
  175. 0x40, 0xed, 0x08, 0x03, 0x01, 0x05, 0x86, 0xf5, 0x42, 0xea, 0x4d, 0xf7,
  176. 0x4f, 0xef, 0x46, 0xdf, 0x8f, 0xe8, 0x2d, 0xbb, 0x5d, 0x0d, 0x2f, 0x4f,
  177. 0xf4, 0xd8, 0x31, 0xc6, 0x5a, 0x97, 0x98, 0x44, 0xcf, 0x42, 0x5a, 0xf3,
  178. 0x03, 0x5f, 0xb6, 0x38, 0x45, 0x5a, 0x15, 0x1e, 0xb9, 0x54, 0xfa, 0x2c,
  179. 0x3f, 0x68, 0x7b, 0x4e, 0x85, 0x35, 0xf3, 0x5b, 0xe5, 0xdc, 0x96, 0x2b,
  180. 0x18, 0x84, 0x5e, 0x1e, 0x53, 0xdc, 0x22, 0x23, 0x06, 0x08, 0x91, 0x5a,
  181. 0x2d, 0x27, 0xe2, 0x12, 0x69, 0xfa, 0xab, 0x19, 0x7c, 0x47, 0x6b, 0xec,
  182. 0xde, 0xc6, 0x25, 0xd4, 0x43, 0xb4, 0x65, 0x23, 0x61, 0x0f, 0x1f, 0x2d,
  183. 0xfd, 0xb1, 0x18, 0xb0, 0x04, 0x8e, 0x1a, 0xc5, 0x95, 0x9a, 0x0e, 0x37,
  184. 0x7c, 0x5e, 0x95, 0x38, 0xc2, 0xcf, 0xfa, 0x1f, 0xe3, 0x3a, 0x2b, 0x85,
  185. 0xa5, 0xfd, 0x6b, 0xc4, 0x1d, 0xfb, 0x47, 0x27, 0xaf, 0xc1, 0x94, 0xcd};
  186. const std::vector<uint8_t> Epid11FileParser::kGroupMultiPublicKeyFile = {
  187. // Epid Version
  188. 0x01, 0x00,
  189. // Epid type
  190. 0x00, 0x0c,
  191. // GID
  192. 0x00, 0x00, 0x00, 0x7b,
  193. // h1
  194. 0x08, 0x4a, 0x9d, 0x2e, 0xf9, 0x4f, 0x78, 0x02, 0xd7, 0x89, 0x75, 0xb4,
  195. 0xe7, 0x25, 0x26, 0x9f, 0x00, 0x57, 0xad, 0x33, 0x30, 0xea, 0xa9, 0x6c,
  196. 0x00, 0x9e, 0x8b, 0xc8, 0x13, 0x23, 0xcb, 0x06, 0x04, 0xbe, 0x42, 0x74,
  197. 0x11, 0x07, 0xb1, 0x06, 0xd7, 0xef, 0x5f, 0x66, 0x87, 0xd9, 0xfa, 0xdd,
  198. 0x53, 0xae, 0xd7, 0xf4, 0x54, 0xf8, 0xd0, 0x21, 0x75, 0xe0, 0x07, 0x44,
  199. 0xc9, 0xc3, 0x4e, 0xf7,
  200. // h2
  201. 0x06, 0xd8, 0xa9, 0x90, 0x02, 0x8f, 0xca, 0xa5, 0x73, 0x36, 0x24, 0x03,
  202. 0xc9, 0xa8, 0x7e, 0x9d, 0x64, 0x12, 0xac, 0xa7, 0xbd, 0x17, 0x7f, 0x7c,
  203. 0x96, 0x8d, 0x2e, 0x13, 0xd9, 0xb2, 0x69, 0x47, 0x09, 0xdb, 0xe3, 0xbf,
  204. 0xbc, 0xa1, 0x34, 0x0f, 0xc6, 0xe2, 0x00, 0x3d, 0x98, 0xa3, 0x7d, 0xab,
  205. 0xd4, 0x0e, 0xec, 0xde, 0x4f, 0x97, 0xa9, 0xbb, 0xdd, 0x60, 0x94, 0x24,
  206. 0x7b, 0xb3, 0xf5, 0x94,
  207. // w
  208. 0x02, 0x43, 0x78, 0x9f, 0x54, 0xc1, 0x21, 0x3a, 0x2b, 0x4d, 0x12, 0x65,
  209. 0x2f, 0x51, 0x94, 0xc6, 0x34, 0x24, 0xd9, 0x7b, 0x06, 0x3a, 0xc4, 0xf5,
  210. 0x56, 0xeb, 0x32, 0xe3, 0xee, 0x7b, 0xad, 0x6b, 0x04, 0x90, 0x86, 0x31,
  211. 0x18, 0x2a, 0xa4, 0xcf, 0xa3, 0x90, 0xa5, 0x80, 0x7b, 0xae, 0x3b, 0xb1,
  212. 0x77, 0x03, 0xe7, 0x7e, 0xf2, 0xfc, 0x6d, 0x3a, 0xab, 0x8f, 0xbf, 0x95,
  213. 0x40, 0xed, 0x08, 0x03, 0x01, 0x05, 0x86, 0xf5, 0x42, 0xea, 0x4d, 0xf7,
  214. 0x4f, 0xef, 0x46, 0xdf, 0x8f, 0xe8, 0x2d, 0xbb, 0x5d, 0x0d, 0x2f, 0x4f,
  215. 0xf4, 0xd8, 0x31, 0xc6, 0x5a, 0x97, 0x98, 0x44, 0xcf, 0x42, 0x5a, 0xf3,
  216. 0x03, 0x5f, 0xb6, 0x38, 0x45, 0x5a, 0x15, 0x1e, 0xb9, 0x54, 0xfa, 0x2c,
  217. 0x3f, 0x68, 0x7b, 0x4e, 0x85, 0x35, 0xf3, 0x5b, 0xe5, 0xdc, 0x96, 0x2b,
  218. 0x18, 0x84, 0x5e, 0x1e, 0x53, 0xdc, 0x22, 0x23, 0x06, 0x08, 0x91, 0x5a,
  219. 0x2d, 0x27, 0xe2, 0x12, 0x69, 0xfa, 0xab, 0x19, 0x7c, 0x47, 0x6b, 0xec,
  220. 0xde, 0xc6, 0x25, 0xd4, 0x43, 0xb4, 0x65, 0x23, 0x61, 0x0f, 0x1f, 0x2d,
  221. 0xfd, 0xb1, 0x18, 0xb0, 0x04, 0x8e, 0x1a, 0xc5, 0x95, 0x9a, 0x0e, 0x37,
  222. 0x7c, 0x5e, 0x95, 0x38, 0xc2, 0xcf, 0xfa, 0x1f, 0xe3, 0x3a, 0x2b, 0x85,
  223. 0xa5, 0xfd, 0x6b, 0xc4, 0x1d, 0xfb, 0x47, 0x27, 0xaf, 0xc1, 0x94, 0xcd,
  224. // Signature
  225. 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, 0xed, 0x2a,
  226. 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, 0x70, 0x2a, 0x6c, 0x06,
  227. 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, 0xf0, 0x6e, 0x43, 0x67,
  228. 0x68, 0x6f, 0x9e, 0x3b, 0xcf, 0xfd, 0x98, 0xcc, 0xae, 0x92, 0xcc, 0x94,
  229. 0x23, 0xb6, 0xbd, 0x57, 0xac, 0x06, 0x3c, 0xa1, 0xe5, 0x3e, 0xe9, 0xf5,
  230. 0x0e, 0x55, 0xb4, 0xe5,
  231. // Epid Version
  232. 0x01, 0x00,
  233. // Epid type
  234. 0x00, 0x0c,
  235. // GID
  236. 0x00, 0x00, 0x04, 0xd2,
  237. // h1
  238. 0x00, 0x6c, 0x38, 0x98, 0x41, 0x97, 0xf6, 0xf1, 0xb0, 0x41, 0x57, 0xd4,
  239. 0xf9, 0xce, 0xcc, 0x22, 0xce, 0x4f, 0xc8, 0x47, 0xaf, 0x2a, 0x6c, 0xa3,
  240. 0x02, 0xf2, 0x74, 0x80, 0xc9, 0x5c, 0x1c, 0xf7, 0x06, 0xed, 0xce, 0xc0,
  241. 0x0b, 0x29, 0x73, 0x1c, 0x09, 0x84, 0x4c, 0xcc, 0xff, 0x82, 0x9d, 0x29,
  242. 0xe7, 0x88, 0x57, 0xfd, 0xd2, 0x55, 0x41, 0x0f, 0x5e, 0x6e, 0xf5, 0xc4,
  243. 0x77, 0xa2, 0x5d, 0xaf,
  244. // h2
  245. 0x00, 0x50, 0x70, 0xe5, 0x66, 0x92, 0x77, 0x33, 0x82, 0xda, 0xc9, 0x27,
  246. 0x7c, 0x16, 0xf8, 0xf2, 0x69, 0x48, 0x2f, 0xf0, 0xdd, 0x8d, 0x9e, 0x27,
  247. 0x41, 0xaf, 0xcc, 0xb9, 0x04, 0xf4, 0x77, 0x8c, 0x06, 0x36, 0xee, 0xbd,
  248. 0x53, 0x0e, 0x20, 0xd8, 0x9f, 0xd7, 0xb7, 0x41, 0xdd, 0xe0, 0xee, 0xc7,
  249. 0xf8, 0xef, 0x91, 0x03, 0xe1, 0xfe, 0x6a, 0xe6, 0x3b, 0x91, 0xb7, 0xaa,
  250. 0xc4, 0x64, 0x72, 0x37,
  251. // w
  252. 0x06, 0xa3, 0x37, 0xa1, 0xfc, 0xe2, 0x3a, 0x99, 0x96, 0xb9, 0x8d, 0xad,
  253. 0x07, 0xec, 0xfc, 0x62, 0x39, 0x5c, 0x0c, 0x89, 0xba, 0x06, 0x3a, 0x1c,
  254. 0xea, 0x2d, 0xcc, 0xf2, 0x00, 0xaa, 0x08, 0x25, 0x06, 0x82, 0xa0, 0x68,
  255. 0x71, 0x4f, 0x5d, 0xbd, 0xc3, 0x80, 0xe6, 0x98, 0xe9, 0x14, 0x10, 0xdc,
  256. 0x9c, 0xa6, 0x4e, 0x75, 0x09, 0x0a, 0x45, 0x39, 0x2b, 0xcc, 0x6e, 0x6f,
  257. 0x66, 0xad, 0x1a, 0x63, 0x05, 0x9c, 0x6a, 0xeb, 0x7f, 0xd3, 0x16, 0x46,
  258. 0x37, 0xc8, 0x5f, 0x1a, 0x34, 0x46, 0x35, 0x92, 0x10, 0x7b, 0x7b, 0xe3,
  259. 0x9c, 0x65, 0x59, 0x2d, 0xa8, 0x8a, 0x4b, 0xfb, 0x81, 0x97, 0xf6, 0x25,
  260. 0x09, 0xf3, 0x6d, 0xcc, 0x50, 0x63, 0xe0, 0x9d, 0x69, 0x02, 0x0c, 0x52,
  261. 0x75, 0x95, 0x30, 0x38, 0x69, 0x1e, 0x8e, 0x6b, 0x52, 0xbf, 0x97, 0x9f,
  262. 0x20, 0x02, 0xec, 0xb3, 0x6b, 0x2b, 0xdd, 0xf3, 0x01, 0x11, 0xbb, 0xbe,
  263. 0x3b, 0xc9, 0xa0, 0xc3, 0x44, 0xfe, 0x49, 0x53, 0x89, 0x2d, 0x27, 0x40,
  264. 0x86, 0x87, 0xea, 0xce, 0x5f, 0x9a, 0xee, 0xc2, 0x15, 0x62, 0xc1, 0x87,
  265. 0x0f, 0x3a, 0x78, 0x03, 0x03, 0xd2, 0x8c, 0x24, 0x5a, 0x90, 0xa7, 0xc5,
  266. 0x35, 0x4f, 0xab, 0xcd, 0x40, 0xe8, 0x7c, 0xf0, 0xab, 0x96, 0x59, 0x3a,
  267. 0x96, 0xe4, 0x4a, 0x73, 0x67, 0x51, 0x1f, 0xad, 0x06, 0x94, 0x40, 0xcf,
  268. // Signature
  269. 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, 0xed, 0x2a,
  270. 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, 0x70, 0x2a, 0x6c, 0x06,
  271. 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, 0x4b, 0xba, 0x99, 0x05,
  272. 0x14, 0x98, 0x2c, 0x10, 0x5d, 0x25, 0x84, 0x93, 0x92, 0x0c, 0x7c, 0x44,
  273. 0x39, 0xb8, 0xd9, 0x65, 0x8a, 0x27, 0x20, 0x31, 0xb8, 0xc8, 0x47, 0xe2,
  274. 0xfb, 0x79, 0xa0, 0xa5};
  275. const std::vector<uint8_t> Epid11FileParser::kEmptyPrivRlFile = {
  276. // Epid Version
  277. 0x01, 0x00,
  278. // Epid type
  279. 0x00, 0x0d,
  280. // GID
  281. 0x00, 0x00, 0x00, 0x7b,
  282. // RL Ver
  283. 0x00, 0x00, 0x00, 0x00,
  284. // n1
  285. 0x00, 0x00, 0x00, 0x00,
  286. // sig
  287. 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, 0xed, 0x2a,
  288. 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, 0x70, 0x2a, 0x6c, 0x06,
  289. 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, 0x29, 0xa4, 0x10, 0x8f,
  290. 0x7d, 0xb4, 0xff, 0xae, 0x6a, 0xce, 0x8d, 0xcd, 0xc6, 0x84, 0x63, 0x9f,
  291. 0x89, 0x3d, 0x23, 0x42, 0xf5, 0x37, 0xba, 0xb9, 0x4a, 0xbb, 0x6e, 0xf2,
  292. 0xb2, 0x74, 0x8c, 0xcc,
  293. };
  294. const std::vector<uint8_t> Epid11FileParser::kEmptyPrivRl = {
  295. // GID
  296. 0x00, 0x00, 0x00, 0x7b,
  297. // RL Ver
  298. 0x00, 0x00, 0x00, 0x00,
  299. // n1
  300. 0x00, 0x00, 0x00, 0x00};
  301. const std::vector<uint8_t> Epid11FileParser::kShortPrivRlFile = {
  302. // Epid Version
  303. 0x01, 0x00,
  304. // Epid type
  305. 0x00, 0x0d,
  306. // GID
  307. 0x00, 0x00, 0x00, 0x7b,
  308. // RL Ver
  309. 0x00, 0x00, 0x00, 0x03,
  310. // n1
  311. 0x00, 0x00, 0x00, 0x01,
  312. // PrivRl
  313. 0x00, 0x00, 0x56, 0x1e, 0xb1, 0x91, 0xb6, 0xdf, 0x40, 0xbc, 0xa2, 0xe3,
  314. 0xe3, 0x92, 0x33, 0xd1, 0xd7, 0x5c, 0xcc, 0x4c, 0x3a, 0xe7, 0x91, 0x49,
  315. 0x73, 0xe2, 0x03, 0xd4, 0x5e, 0x4f, 0x87, 0xad,
  316. // Sig
  317. 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, 0xed, 0x2a,
  318. 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, 0x70, 0x2a, 0x6c, 0x06,
  319. 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, 0x60, 0xf3, 0xfa, 0xe8,
  320. 0x34, 0x9f, 0x50, 0xac, 0x1b, 0x75, 0xf4, 0x62, 0x41, 0xc4, 0xb7, 0x11,
  321. 0x64, 0xef, 0xe1, 0xd4, 0x3c, 0xee, 0xee, 0x86, 0x4c, 0xbb, 0x9a, 0x40,
  322. 0x77, 0x0b, 0xb2, 0xec,
  323. };
  324. const std::vector<uint8_t> Epid11FileParser::kShortPrivRl = {
  325. // GID
  326. 0x00, 0x00, 0x00, 0x7b,
  327. // RL Ver
  328. 0x00, 0x00, 0x00, 0x03,
  329. // n1
  330. 0x00, 0x00, 0x00, 0x01,
  331. // PrivRl
  332. 0x00, 0x00, 0x56, 0x1e, 0xb1, 0x91, 0xb6, 0xdf, 0x40, 0xbc, 0xa2, 0xe3,
  333. 0xe3, 0x92, 0x33, 0xd1, 0xd7, 0x5c, 0xcc, 0x4c, 0x3a, 0xe7, 0x91, 0x49,
  334. 0x73, 0xe2, 0x03, 0xd4, 0x5e, 0x4f, 0x87, 0xad,
  335. };
  336. const std::vector<uint8_t> Epid11FileParser::kEmptySigRlFile = {
  337. // Epid Version
  338. 0x01, 0x00,
  339. // Epid type
  340. 0x00, 0x0e,
  341. // GID
  342. 0x00, 0x00, 0x00, 0x7b,
  343. // RL Ver
  344. 0x00, 0x00, 0x00, 0x00,
  345. // n2
  346. 0x00, 0x00, 0x00, 0x00,
  347. // Signature
  348. 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, 0xed, 0x2a,
  349. 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, 0x70, 0x2a, 0x6c, 0x06,
  350. 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, 0x94, 0x29, 0xf2, 0x7e,
  351. 0x16, 0x19, 0x48, 0xa0, 0xed, 0xb7, 0x61, 0x5e, 0x63, 0x54, 0x87, 0xf4,
  352. 0xbb, 0x7f, 0x42, 0x8d, 0x39, 0x63, 0x62, 0x06, 0x69, 0x7b, 0x9d, 0x0b,
  353. 0x7e, 0xdf, 0xf2, 0x0d};
  354. const std::vector<uint8_t> Epid11FileParser::kEmptySigRl = {
  355. // GID
  356. 0x00, 0x00, 0x00, 0x7b,
  357. // RL Ver
  358. 0x00, 0x00, 0x00, 0x00,
  359. // n2
  360. 0x00, 0x00, 0x00, 0x00};
  361. const std::vector<uint8_t> Epid11FileParser::kShortSigRlFile = {
  362. // Epid Version
  363. 0x01, 0x00,
  364. // Epid type
  365. 0x00, 0x0e,
  366. // GID
  367. 0x00, 0x00, 0x00, 0x7b,
  368. // RL Ver
  369. 0x00, 0x00, 0x00, 0x03,
  370. // n2
  371. 0x00, 0x00, 0x00, 0x03,
  372. // bks
  373. 0x09, 0x0d, 0x6f, 0x82, 0x77, 0x88, 0x49, 0x53, 0xba, 0x1e, 0x1b, 0x0e,
  374. 0x5e, 0xae, 0xc0, 0x27, 0xad, 0xe3, 0xb1, 0x09, 0x4f, 0xcd, 0xb6, 0xe6,
  375. 0x6f, 0x7f, 0xa3, 0x1a, 0x1e, 0xfb, 0x52, 0x72, 0xfa, 0x85, 0x0f, 0x5c,
  376. 0x97, 0x61, 0xbf, 0x46, 0x7e, 0xec, 0xd6, 0x64, 0xda, 0xa9, 0x8e, 0xf5,
  377. 0xd3, 0xdf, 0xfa, 0x13, 0x5a, 0xb2, 0x3e, 0xeb, 0x0a, 0x9d, 0x02, 0xc0,
  378. 0x33, 0xec, 0x2a, 0x70, 0x6e, 0xdf, 0x9f, 0xe3, 0xe0, 0x8d, 0xe4, 0x0b,
  379. 0xbb, 0x86, 0x12, 0xd7, 0xc5, 0xd8, 0x14, 0x5e, 0x67, 0xbd, 0x1d, 0xa5,
  380. 0x0b, 0xdb, 0xf5, 0x87, 0x36, 0x6c, 0xda, 0x81, 0x2a, 0x8c, 0x2e, 0x78,
  381. 0xef, 0x6c, 0x42, 0xb2, 0xcd, 0x40, 0xda, 0xd3, 0x22, 0xf4, 0xd9, 0x7e,
  382. 0x34, 0x78, 0x49, 0x41, 0x0d, 0x1e, 0x64, 0xc1, 0x43, 0xa1, 0xb0, 0xe9,
  383. 0x6c, 0x45, 0xe2, 0x2d, 0xc3, 0xeb, 0xc8, 0x14, 0x09, 0x0d, 0x6f, 0x82,
  384. 0x77, 0x88, 0x49, 0x53, 0xba, 0x1e, 0x1b, 0x0e, 0x5e, 0xae, 0xc0, 0x27,
  385. 0xad, 0xe3, 0xb1, 0x09, 0x4f, 0xcd, 0xb6, 0xe6, 0x6f, 0x7f, 0xa3, 0x1a,
  386. 0x1e, 0xfb, 0x52, 0x72, 0xfa, 0x85, 0x0f, 0x5c, 0x97, 0x61, 0xbf, 0x46,
  387. 0x7e, 0xec, 0xd6, 0x64, 0xda, 0xa9, 0x8e, 0xf5, 0xd3, 0xdf, 0xfa, 0x13,
  388. 0x5a, 0xb2, 0x3e, 0xeb, 0x0a, 0x9d, 0x02, 0xc0, 0x33, 0xec, 0x2a, 0x70,
  389. 0x80, 0x85, 0x35, 0x04, 0x7b, 0xfc, 0x0a, 0x6c, 0xb4, 0x10, 0x2d, 0x4a,
  390. 0xbe, 0x35, 0x78, 0x41, 0x3a, 0xc6, 0x01, 0x3a, 0x59, 0x21, 0x17, 0x04,
  391. 0x60, 0x6a, 0x51, 0x6c, 0x84, 0xde, 0xc3, 0x3b, 0x1e, 0x6a, 0xaf, 0x82,
  392. 0x5d, 0x81, 0xe2, 0x44, 0x25, 0x98, 0x89, 0xdb, 0x82, 0x17, 0xe6, 0xb8,
  393. 0x9f, 0xfd, 0x03, 0x86, 0x63, 0x8c, 0xe1, 0x93, 0x77, 0x61, 0x3c, 0xc2,
  394. 0x75, 0x14, 0xa1, 0xc2, 0x09, 0x0d, 0x6f, 0x82, 0x77, 0x88, 0x49, 0x53,
  395. 0xba, 0x1e, 0x1b, 0x0e, 0x5e, 0xae, 0xc0, 0x27, 0xad, 0xe3, 0xb1, 0x09,
  396. 0x4f, 0xcd, 0xb6, 0xe6, 0x6f, 0x7f, 0xa3, 0x1a, 0x1e, 0xfb, 0x52, 0x72,
  397. 0xfa, 0x85, 0x0f, 0x5c, 0x97, 0x61, 0xbf, 0x46, 0x7e, 0xec, 0xd6, 0x64,
  398. 0xda, 0xa9, 0x8e, 0xf5, 0xd3, 0xdf, 0xfa, 0x13, 0x5a, 0xb2, 0x3e, 0xeb,
  399. 0x0a, 0x9d, 0x02, 0xc0, 0x33, 0xec, 0x2a, 0x70, 0x95, 0x8b, 0x05, 0x1e,
  400. 0x8b, 0xa5, 0x21, 0xdd, 0x63, 0xfd, 0x1a, 0x36, 0xb7, 0x42, 0x04, 0x92,
  401. 0x10, 0xe6, 0x29, 0x22, 0xc8, 0x97, 0xb1, 0x28, 0x01, 0x45, 0x95, 0xf1,
  402. 0x2a, 0xa0, 0x86, 0x41, 0xc4, 0x4c, 0xb6, 0x3b, 0x45, 0x23, 0x6e, 0x8d,
  403. 0x6e, 0x07, 0xc7, 0x5b, 0xe5, 0x46, 0xca, 0xd0, 0x68, 0x99, 0xb6, 0x30,
  404. 0x7b, 0x70, 0xb0, 0x92, 0x48, 0xc2, 0x89, 0xb6, 0x27, 0x3b, 0x95, 0x89,
  405. // Signature
  406. 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, 0xed, 0x2a,
  407. 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, 0x70, 0x2a, 0x6c, 0x06,
  408. 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, 0x1c, 0xab, 0x1f, 0xca,
  409. 0x99, 0x74, 0x76, 0x02, 0x4c, 0xa6, 0xca, 0x13, 0xda, 0x9d, 0x74, 0xfa,
  410. 0x56, 0x23, 0xf1, 0x86, 0xbe, 0xd4, 0xf2, 0x84, 0x7a, 0xdf, 0xd3, 0x62,
  411. 0x4f, 0xc2, 0x0d, 0x84};
  412. const std::vector<uint8_t> Epid11FileParser::kShortSigRl = {
  413. // GID
  414. 0x00, 0x00, 0x00, 0x7b,
  415. // RL Ver
  416. 0x00, 0x00, 0x00, 0x03,
  417. // n2
  418. 0x00, 0x00, 0x00, 0x03,
  419. // B, K
  420. 0x09, 0x0d, 0x6f, 0x82, 0x77, 0x88, 0x49, 0x53, 0xba, 0x1e, 0x1b, 0x0e,
  421. 0x5e, 0xae, 0xc0, 0x27, 0xad, 0xe3, 0xb1, 0x09, 0x4f, 0xcd, 0xb6, 0xe6,
  422. 0x6f, 0x7f, 0xa3, 0x1a, 0x1e, 0xfb, 0x52, 0x72, 0xfa, 0x85, 0x0f, 0x5c,
  423. 0x97, 0x61, 0xbf, 0x46, 0x7e, 0xec, 0xd6, 0x64, 0xda, 0xa9, 0x8e, 0xf5,
  424. 0xd3, 0xdf, 0xfa, 0x13, 0x5a, 0xb2, 0x3e, 0xeb, 0x0a, 0x9d, 0x02, 0xc0,
  425. 0x33, 0xec, 0x2a, 0x70, 0x6e, 0xdf, 0x9f, 0xe3, 0xe0, 0x8d, 0xe4, 0x0b,
  426. 0xbb, 0x86, 0x12, 0xd7, 0xc5, 0xd8, 0x14, 0x5e, 0x67, 0xbd, 0x1d, 0xa5,
  427. 0x0b, 0xdb, 0xf5, 0x87, 0x36, 0x6c, 0xda, 0x81, 0x2a, 0x8c, 0x2e, 0x78,
  428. 0xef, 0x6c, 0x42, 0xb2, 0xcd, 0x40, 0xda, 0xd3, 0x22, 0xf4, 0xd9, 0x7e,
  429. 0x34, 0x78, 0x49, 0x41, 0x0d, 0x1e, 0x64, 0xc1, 0x43, 0xa1, 0xb0, 0xe9,
  430. 0x6c, 0x45, 0xe2, 0x2d, 0xc3, 0xeb, 0xc8, 0x14,
  431. // B, K
  432. 0x09, 0x0d, 0x6f, 0x82, 0x77, 0x88, 0x49, 0x53, 0xba, 0x1e, 0x1b, 0x0e,
  433. 0x5e, 0xae, 0xc0, 0x27, 0xad, 0xe3, 0xb1, 0x09, 0x4f, 0xcd, 0xb6, 0xe6,
  434. 0x6f, 0x7f, 0xa3, 0x1a, 0x1e, 0xfb, 0x52, 0x72, 0xfa, 0x85, 0x0f, 0x5c,
  435. 0x97, 0x61, 0xbf, 0x46, 0x7e, 0xec, 0xd6, 0x64, 0xda, 0xa9, 0x8e, 0xf5,
  436. 0xd3, 0xdf, 0xfa, 0x13, 0x5a, 0xb2, 0x3e, 0xeb, 0x0a, 0x9d, 0x02, 0xc0,
  437. 0x33, 0xec, 0x2a, 0x70, 0x80, 0x85, 0x35, 0x04, 0x7b, 0xfc, 0x0a, 0x6c,
  438. 0xb4, 0x10, 0x2d, 0x4a, 0xbe, 0x35, 0x78, 0x41, 0x3a, 0xc6, 0x01, 0x3a,
  439. 0x59, 0x21, 0x17, 0x04, 0x60, 0x6a, 0x51, 0x6c, 0x84, 0xde, 0xc3, 0x3b,
  440. 0x1e, 0x6a, 0xaf, 0x82, 0x5d, 0x81, 0xe2, 0x44, 0x25, 0x98, 0x89, 0xdb,
  441. 0x82, 0x17, 0xe6, 0xb8, 0x9f, 0xfd, 0x03, 0x86, 0x63, 0x8c, 0xe1, 0x93,
  442. 0x77, 0x61, 0x3c, 0xc2, 0x75, 0x14, 0xa1, 0xc2,
  443. // B, K
  444. 0x09, 0x0d, 0x6f, 0x82, 0x77, 0x88, 0x49, 0x53, 0xba, 0x1e, 0x1b, 0x0e,
  445. 0x5e, 0xae, 0xc0, 0x27, 0xad, 0xe3, 0xb1, 0x09, 0x4f, 0xcd, 0xb6, 0xe6,
  446. 0x6f, 0x7f, 0xa3, 0x1a, 0x1e, 0xfb, 0x52, 0x72, 0xfa, 0x85, 0x0f, 0x5c,
  447. 0x97, 0x61, 0xbf, 0x46, 0x7e, 0xec, 0xd6, 0x64, 0xda, 0xa9, 0x8e, 0xf5,
  448. 0xd3, 0xdf, 0xfa, 0x13, 0x5a, 0xb2, 0x3e, 0xeb, 0x0a, 0x9d, 0x02, 0xc0,
  449. 0x33, 0xec, 0x2a, 0x70, 0x95, 0x8b, 0x05, 0x1e, 0x8b, 0xa5, 0x21, 0xdd,
  450. 0x63, 0xfd, 0x1a, 0x36, 0xb7, 0x42, 0x04, 0x92, 0x10, 0xe6, 0x29, 0x22,
  451. 0xc8, 0x97, 0xb1, 0x28, 0x01, 0x45, 0x95, 0xf1, 0x2a, 0xa0, 0x86, 0x41,
  452. 0xc4, 0x4c, 0xb6, 0x3b, 0x45, 0x23, 0x6e, 0x8d, 0x6e, 0x07, 0xc7, 0x5b,
  453. 0xe5, 0x46, 0xca, 0xd0, 0x68, 0x99, 0xb6, 0x30, 0x7b, 0x70, 0xb0, 0x92,
  454. 0x48, 0xc2, 0x89, 0xb6, 0x27, 0x3b, 0x95, 0x89};
  455. const std::vector<uint8_t> Epid11FileParser::kEmptyGroupRlFile = {
  456. // Epid version
  457. 0x01, 0x00,
  458. // Epid type
  459. 0x00, 0x0f,
  460. // RL ver
  461. 0x00, 0x00, 0x00, 0x00,
  462. // n3
  463. 0x00, 0x00, 0x00, 0x00,
  464. // Signature
  465. 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, 0xed, 0x2a,
  466. 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, 0x70, 0x2a, 0x6c, 0x06,
  467. 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, 0xc3, 0x21, 0x99, 0xe1,
  468. 0x18, 0x22, 0x4a, 0xd2, 0xa5, 0xe5, 0xbf, 0x4a, 0xd9, 0x83, 0x08, 0x9d,
  469. 0x62, 0x71, 0xa1, 0x39, 0x21, 0x49, 0x5d, 0xb2, 0x7a, 0xdb, 0x05, 0x2a,
  470. 0xa4, 0xde, 0xb0, 0xac};
  471. const std::vector<uint8_t> Epid11FileParser::kEmptyGroupRl = {
  472. // RL ver
  473. 0x00, 0x00, 0x00, 0x00,
  474. // n3
  475. 0x00, 0x00, 0x00, 0x00};
  476. const std::vector<uint8_t> Epid11FileParser::kShortGroupRlFile = {
  477. // Epid version
  478. 0x01, 0x00,
  479. // Epid type
  480. 0x00, 0x0f,
  481. // RL ver
  482. 0x00, 0x00, 0x00, 0x03,
  483. // n3
  484. 0x00, 0x00, 0x00, 0x03,
  485. // GIDs
  486. 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03,
  487. // Signature
  488. 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, 0xed, 0x2a,
  489. 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, 0x70, 0x2a, 0x6c, 0x06,
  490. 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, 0xc0, 0xec, 0x90, 0x92,
  491. 0xe9, 0xaa, 0x2e, 0x61, 0xca, 0x70, 0x8f, 0x48, 0xd4, 0x7d, 0xe7, 0x82,
  492. 0x22, 0x9f, 0x2f, 0x78, 0x5b, 0xfe, 0x56, 0x6e, 0x1a, 0xa1, 0x69, 0x9d,
  493. 0xcc, 0xb1, 0xaa, 0x62};
  494. const std::vector<uint8_t> Epid11FileParser::kShortGroupRl = {
  495. // RL ver
  496. 0x00, 0x00, 0x00, 0x03,
  497. // n3
  498. 0x00, 0x00, 0x00, 0x03,
  499. // GIDs
  500. 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03};
  501. //////////////////////////////////////////////////////////////////////////
  502. // Epid11ParseGroupPubKeyFile Tests
  503. TEST_F(Epid11FileParser, GroupPubKeyParseFailsGivenNullParameters) {
  504. Epid11GroupPubKey pubkey{};
  505. EXPECT_EQ(kEpidBadArgErr, Epid11ParseGroupPubKeyFile(
  506. nullptr, this->kGroupPublicKeyFile.size(),
  507. &this->kCert, &pubkey));
  508. EXPECT_EQ(kEpidBadArgErr,
  509. Epid11ParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(),
  510. this->kGroupPublicKeyFile.size(),
  511. nullptr, &pubkey));
  512. EXPECT_EQ(kEpidBadArgErr,
  513. Epid11ParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(),
  514. this->kGroupPublicKeyFile.size(),
  515. &this->kCert, nullptr));
  516. }
  517. TEST_F(Epid11FileParser, GroupPubKeyParseFailsGivenUnsupportedCurve) {
  518. Epid11GroupPubKey pubkey{};
  519. EpidCaCertificate unsupported_curve1(this->kCert);
  520. unsupported_curve1.a.data[0] = unsupported_curve1.a.data[0] ^ 0xFF;
  521. EXPECT_EQ(kEpidBadArgErr,
  522. Epid11ParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(),
  523. this->kGroupPublicKeyFile.size(),
  524. &unsupported_curve1, &pubkey));
  525. EpidCaCertificate unsupported_curve2(this->kCert);
  526. unsupported_curve2.b.data[0] = unsupported_curve2.b.data[0] ^ 0xFF;
  527. EXPECT_EQ(kEpidBadArgErr,
  528. Epid11ParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(),
  529. this->kGroupPublicKeyFile.size(),
  530. &unsupported_curve2, &pubkey));
  531. EpidCaCertificate unsupported_curve3(this->kCert);
  532. unsupported_curve3.x.data[0] = unsupported_curve3.x.data[0] ^ 0xFF;
  533. EXPECT_EQ(kEpidBadArgErr,
  534. Epid11ParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(),
  535. this->kGroupPublicKeyFile.size(),
  536. &unsupported_curve3, &pubkey));
  537. EpidCaCertificate unsupported_curve4(this->kCert);
  538. unsupported_curve4.y.data[0] = unsupported_curve4.y.data[0] ^ 0xFF;
  539. EXPECT_EQ(kEpidBadArgErr,
  540. Epid11ParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(),
  541. this->kGroupPublicKeyFile.size(),
  542. &unsupported_curve4, &pubkey));
  543. EpidCaCertificate unsupported_curve5(this->kCert);
  544. unsupported_curve5.r.data[0] = unsupported_curve5.r.data[0] ^ 0xFF;
  545. EXPECT_EQ(kEpidBadArgErr,
  546. Epid11ParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(),
  547. this->kGroupPublicKeyFile.size(),
  548. &unsupported_curve5, &pubkey));
  549. EpidCaCertificate unsupported_curve6(this->kCert);
  550. unsupported_curve6.prime.data[0] = unsupported_curve6.prime.data[0] ^ 0xFF;
  551. EXPECT_EQ(kEpidBadArgErr,
  552. Epid11ParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(),
  553. this->kGroupPublicKeyFile.size(),
  554. &unsupported_curve6, &pubkey));
  555. }
  556. TEST_F(Epid11FileParser, GroupPubKeyParseFailsGivenInvalidKeyInCertificate) {
  557. Epid11GroupPubKey pubkey{};
  558. EpidCaCertificate invalid_key_qx(this->kCert);
  559. invalid_key_qx.pubkey.data[0] = invalid_key_qx.pubkey.data[0] ^ 0xFF;
  560. EXPECT_EQ(kEpidBadArgErr,
  561. Epid11ParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(),
  562. this->kGroupPublicKeyFile.size(),
  563. &invalid_key_qx, &pubkey));
  564. EpidCaCertificate invalid_key_qy(this->kCert);
  565. invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] =
  566. invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] ^ 0xFF;
  567. EXPECT_EQ(kEpidBadArgErr,
  568. Epid11ParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(),
  569. this->kGroupPublicKeyFile.size(),
  570. &invalid_key_qy, &pubkey));
  571. EpidCaCertificate invalid_key_qx_qy(this->kCert);
  572. invalid_key_qx_qy.pubkey.data[0] = invalid_key_qx_qy.pubkey.data[0] ^ 0xFF;
  573. invalid_key_qx_qy.pubkey.data[sizeof(invalid_key_qx_qy.pubkey) - 1] =
  574. invalid_key_qx_qy.pubkey.data[sizeof(invalid_key_qx_qy.pubkey) - 1] ^
  575. 0xFF;
  576. EXPECT_EQ(kEpidBadArgErr,
  577. Epid11ParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(),
  578. this->kGroupPublicKeyFile.size(),
  579. &invalid_key_qx_qy, &pubkey));
  580. }
  581. TEST_F(Epid11FileParser, RejectsGroupPubKeyFileWithInvalidSize) {
  582. Epid11GroupPubKey pubkey{};
  583. EXPECT_EQ(kEpidBadArgErr,
  584. Epid11ParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(),
  585. 0, &this->kCert, &pubkey));
  586. EXPECT_EQ(kEpidBadArgErr,
  587. Epid11ParseGroupPubKeyFile((void*)this->kGroupPublicKeyFile.data(),
  588. this->kGroupPublicKeyFile.size() - 1,
  589. &this->kCert, &pubkey));
  590. }
  591. TEST_F(Epid11FileParser, RejectsInvalidGroupPubKeyFileType) {
  592. Epid11GroupPubKey pubkey{};
  593. EXPECT_EQ(kEpidBadArgErr,
  594. Epid11ParseGroupPubKeyFile((void*)this->kShortPrivRlFile.data(),
  595. this->kGroupPublicKeyFile.size(),
  596. &this->kCert, &pubkey));
  597. }
  598. TEST_F(Epid11FileParser, RejectsGroupPubKeyFileWithUnsupportedEpidVersion) {
  599. Epid11GroupPubKey pubkey{};
  600. std::vector<uint8_t> unsupported_epidver_file(this->kGroupPublicKeyFile);
  601. unsupported_epidver_file[0] = {0x02};
  602. EXPECT_EQ(kEpidBadArgErr,
  603. Epid11ParseGroupPubKeyFile((void*)unsupported_epidver_file.data(),
  604. unsupported_epidver_file.size(),
  605. &this->kCert, &pubkey));
  606. }
  607. TEST_F(Epid11FileParser, ParsesValidPubKeyFile) {
  608. std::vector<uint8_t> pubkey(sizeof(Epid11GroupPubKey), 0);
  609. EXPECT_EQ(kEpidNoErr, Epid11ParseGroupPubKeyFile(
  610. (void*)this->kGroupPublicKeyFile.data(),
  611. this->kGroupPublicKeyFile.size(), &this->kCert,
  612. (Epid11GroupPubKey*)pubkey.data()));
  613. EXPECT_EQ(this->kGroupPublicKey, pubkey);
  614. }
  615. TEST_F(Epid11FileParser, ParsesValidMultiPubKeyFile) {
  616. std::vector<uint8_t> pubkey(sizeof(Epid11GroupPubKey), 0);
  617. EXPECT_EQ(kEpidNoErr, Epid11ParseGroupPubKeyFile(
  618. (void*)this->kGroupMultiPublicKeyFile.data(),
  619. this->kGroupMultiPublicKeyFile.size(), &this->kCert,
  620. (Epid11GroupPubKey*)pubkey.data()));
  621. EXPECT_EQ(this->kGroupPublicKey, pubkey);
  622. }
  623. TEST_F(Epid11FileParser, RejectsGroupPubKeyFileWithInvalidSignature) {
  624. Epid11GroupPubKey pubkey{};
  625. std::vector<uint8_t> pubkey_inv_sign(this->kGroupPublicKeyFile);
  626. pubkey_inv_sign[pubkey_inv_sign.size() - 1] =
  627. pubkey_inv_sign[pubkey_inv_sign.size() - 1] ^ 0xFF;
  628. EXPECT_EQ(kEpidSigInvalid,
  629. Epid11ParseGroupPubKeyFile((void*)pubkey_inv_sign.data(),
  630. pubkey_inv_sign.size(), &this->kCert,
  631. &pubkey));
  632. }
  633. //////////////////////////////////////////////////////////////////////////
  634. // Epid11ParsePrivRlFile Tests
  635. TEST_F(Epid11FileParser, PrivRlParseProvidesRequiredLenWithNullDest) {
  636. size_t rl_len = 0;
  637. EXPECT_EQ(kEpidNoErr,
  638. Epid11ParsePrivRlFile((void*)this->kShortPrivRlFile.data(),
  639. this->kShortPrivRlFile.size(), &this->kCert,
  640. nullptr, &rl_len));
  641. EXPECT_EQ(this->kShortPrivRl.size(), rl_len);
  642. }
  643. TEST_F(Epid11FileParser, PrivRlParseFailsGivenNullParameters) {
  644. size_t rl_len = this->kShortPrivRl.size();
  645. std::vector<uint8_t> rl(rl_len);
  646. // null input buffer
  647. EXPECT_EQ(
  648. kEpidBadArgErr,
  649. Epid11ParsePrivRlFile(nullptr, this->kShortPrivRlFile.size(),
  650. &this->kCert, (Epid11PrivRl*)rl.data(), &rl_len));
  651. // null kCert
  652. EXPECT_EQ(kEpidBadArgErr,
  653. Epid11ParsePrivRlFile((void*)this->kShortPrivRlFile.data(),
  654. this->kShortPrivRlFile.size(), nullptr,
  655. (Epid11PrivRl*)rl.data(), &rl_len));
  656. // null rl_length
  657. EXPECT_EQ(kEpidBadArgErr,
  658. Epid11ParsePrivRlFile((void*)this->kShortPrivRlFile.data(),
  659. this->kShortPrivRlFile.size(), &this->kCert,
  660. (Epid11PrivRl*)rl.data(), nullptr));
  661. // null rl_length with null dest
  662. EXPECT_EQ(kEpidBadArgErr,
  663. Epid11ParsePrivRlFile((void*)this->kShortPrivRlFile.data(),
  664. this->kShortPrivRlFile.size(), &this->kCert,
  665. nullptr, nullptr));
  666. }
  667. TEST_F(Epid11FileParser, PrivRlParseFailsGivenUnsupportedCurveInCA) {
  668. size_t rl_len = this->kShortPrivRl.size();
  669. std::vector<uint8_t> rl(rl_len);
  670. EpidCaCertificate unsupported_curve(kCert);
  671. unsupported_curve.a.data[0] = unsupported_curve.a.data[0] ^ 0xFF;
  672. EXPECT_EQ(
  673. kEpidBadArgErr,
  674. Epid11ParsePrivRlFile((void*)this->kShortPrivRlFile.data(),
  675. this->kShortPrivRlFile.size(), &unsupported_curve,
  676. (Epid11PrivRl*)rl.data(), &rl_len));
  677. EpidCaCertificate unsupported_curve2(kCert);
  678. unsupported_curve2.b.data[0] = unsupported_curve2.b.data[0] ^ 0xFF;
  679. EXPECT_EQ(
  680. kEpidBadArgErr,
  681. Epid11ParsePrivRlFile((void*)this->kShortPrivRlFile.data(),
  682. this->kShortPrivRlFile.size(), &unsupported_curve2,
  683. (Epid11PrivRl*)rl.data(), &rl_len));
  684. EpidCaCertificate unsupported_curve3(kCert);
  685. unsupported_curve3.x.data[0] = unsupported_curve3.x.data[0] ^ 0xFF;
  686. EXPECT_EQ(
  687. kEpidBadArgErr,
  688. Epid11ParsePrivRlFile((void*)this->kShortPrivRlFile.data(),
  689. this->kShortPrivRlFile.size(), &unsupported_curve3,
  690. (Epid11PrivRl*)rl.data(), &rl_len));
  691. EpidCaCertificate unsupported_curve4(kCert);
  692. unsupported_curve4.y.data[0] = unsupported_curve4.y.data[0] ^ 0xFF;
  693. EXPECT_EQ(
  694. kEpidBadArgErr,
  695. Epid11ParsePrivRlFile((void*)this->kShortPrivRlFile.data(),
  696. this->kShortPrivRlFile.size(), &unsupported_curve4,
  697. (Epid11PrivRl*)rl.data(), &rl_len));
  698. EpidCaCertificate unsupported_curve5(kCert);
  699. unsupported_curve5.r.data[0] = unsupported_curve5.r.data[0] ^ 0xFF;
  700. EXPECT_EQ(
  701. kEpidBadArgErr,
  702. Epid11ParsePrivRlFile((void*)this->kShortPrivRlFile.data(),
  703. this->kShortPrivRlFile.size(), &unsupported_curve5,
  704. (Epid11PrivRl*)rl.data(), &rl_len));
  705. EpidCaCertificate unsupported_curve6(kCert);
  706. unsupported_curve6.prime.data[0] = unsupported_curve6.prime.data[0] ^ 0xFF;
  707. EXPECT_EQ(
  708. kEpidBadArgErr,
  709. Epid11ParsePrivRlFile((void*)this->kShortPrivRlFile.data(),
  710. this->kShortPrivRlFile.size(), &unsupported_curve6,
  711. (Epid11PrivRl*)rl.data(), &rl_len));
  712. }
  713. TEST_F(Epid11FileParser, PrivRlParseFailsGivenInvalidKeyInCertificate) {
  714. size_t rl_len = this->kShortPrivRl.size();
  715. std::vector<uint8_t> rl(rl_len);
  716. EpidCaCertificate invalid_key_qx(kCert);
  717. invalid_key_qx.pubkey.data[0] = invalid_key_qx.pubkey.data[0] ^ 0xFF;
  718. EXPECT_EQ(kEpidBadArgErr, Epid11ParsePrivRlFile(
  719. (void*)this->kShortPrivRlFile.data(),
  720. this->kShortPrivRlFile.size(), &invalid_key_qx,
  721. (Epid11PrivRl*)rl.data(), &rl_len));
  722. EpidCaCertificate invalid_key_qy(kCert);
  723. invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] =
  724. invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] ^ 0xFF;
  725. EXPECT_EQ(kEpidBadArgErr, Epid11ParsePrivRlFile(
  726. (void*)this->kShortPrivRlFile.data(),
  727. this->kShortPrivRlFile.size(), &invalid_key_qy,
  728. (Epid11PrivRl*)rl.data(), &rl_len));
  729. EpidCaCertificate invalid_key_qx_qy(kCert);
  730. invalid_key_qx_qy.pubkey.data[0] = invalid_key_qx_qy.pubkey.data[0] ^ 0xFF;
  731. invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] =
  732. invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] ^ 0xFF;
  733. EXPECT_EQ(
  734. kEpidBadArgErr,
  735. Epid11ParsePrivRlFile((void*)this->kShortPrivRlFile.data(),
  736. this->kShortPrivRlFile.size(), &invalid_key_qx_qy,
  737. (Epid11PrivRl*)rl.data(), &rl_len));
  738. }
  739. TEST_F(Epid11FileParser, PrivRlParseRejectsPrivRlFileWithInvalidSize) {
  740. size_t rl_len = this->kEmptyPrivRl.size();
  741. std::vector<uint8_t> rl(rl_len);
  742. EXPECT_EQ(kEpidBadArgErr, Epid11ParsePrivRlFile(
  743. (void*)this->kEmptyPrivRlFile.data(),
  744. this->kEmptyPrivRlFile.size() + 1, &this->kCert,
  745. (Epid11PrivRl*)rl.data(), &rl_len));
  746. EXPECT_EQ(kEpidBadArgErr, Epid11ParsePrivRlFile(
  747. (void*)this->kEmptyPrivRlFile.data(),
  748. this->kEmptyPrivRlFile.size() - 1, &this->kCert,
  749. (Epid11PrivRl*)rl.data(), &rl_len));
  750. EXPECT_EQ(
  751. kEpidBadArgErr,
  752. Epid11ParsePrivRlFile((void*)this->kEmptyPrivRlFile.data(), 0,
  753. &this->kCert, (Epid11PrivRl*)rl.data(), &rl_len));
  754. }
  755. TEST_F(Epid11FileParser, PrivRlParseRejectsInvalidPrivRlFileType) {
  756. size_t rl_len = this->kShortPrivRl.size();
  757. std::vector<uint8_t> rl(rl_len);
  758. EXPECT_EQ(kEpidBadArgErr,
  759. Epid11ParsePrivRlFile((void*)this->kShortGroupRlFile.data(),
  760. this->kShortGroupRlFile.size(), &this->kCert,
  761. (Epid11PrivRl*)rl.data(), &rl_len));
  762. }
  763. TEST_F(Epid11FileParser, PrivRlRejectsPrivRlFileWithUnsupportedEpidVersion) {
  764. size_t rl_len = this->kShortPrivRl.size();
  765. std::vector<uint8_t> rl(rl_len);
  766. std::vector<uint8_t> unsupported_epidver_file(this->kShortPrivRlFile);
  767. unsupported_epidver_file[0] = {0x02};
  768. EXPECT_EQ(kEpidBadArgErr,
  769. Epid11ParsePrivRlFile((void*)unsupported_epidver_file.data(),
  770. unsupported_epidver_file.size(), &this->kCert,
  771. (Epid11PrivRl*)rl.data(), &rl_len));
  772. }
  773. TEST_F(Epid11FileParser, PrivRlParseParsesEmptyPrivRl) {
  774. size_t rl_len = this->kEmptyPrivRl.size();
  775. std::vector<uint8_t> rl(rl_len);
  776. EXPECT_EQ(kEpidNoErr,
  777. Epid11ParsePrivRlFile((void*)this->kEmptyPrivRlFile.data(),
  778. this->kEmptyPrivRlFile.size(), &this->kCert,
  779. (Epid11PrivRl*)rl.data(), &rl_len));
  780. EXPECT_EQ(this->kEmptyPrivRl, rl);
  781. }
  782. TEST_F(Epid11FileParser, PrivRlParseParsesShortPrivRl) {
  783. size_t rl_len = this->kShortPrivRl.size();
  784. std::vector<uint8_t> rl(rl_len);
  785. EXPECT_EQ(kEpidNoErr,
  786. Epid11ParsePrivRlFile((void*)this->kShortPrivRlFile.data(),
  787. this->kShortPrivRlFile.size(), &this->kCert,
  788. (Epid11PrivRl*)rl.data(), &rl_len));
  789. EXPECT_EQ(this->kShortPrivRl, rl);
  790. }
  791. TEST_F(Epid11FileParser, PrivRlParseParsesLongPrivRl) {
  792. EcdsaSignature signature = {
  793. 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, 0xed,
  794. 0x2a, 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, 0x70, 0x2a,
  795. 0x6c, 0x06, 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, 0x31,
  796. 0x02, 0x1e, 0x05, 0xa2, 0x80, 0x99, 0xef, 0xa9, 0xed, 0x69, 0x90,
  797. 0x36, 0x83, 0xaf, 0x95, 0xb8, 0x11, 0x5b, 0xb1, 0x83, 0x5f, 0x86,
  798. 0x6b, 0x82, 0x17, 0x8f, 0x00, 0x3d, 0x79, 0x25, 0xda,
  799. };
  800. std::vector<uint8_t> long_privrl_file = {
  801. // Epid Version
  802. 0x01, 0x00,
  803. // Epid type
  804. 0x00, 0x0d,
  805. // GID
  806. 0x00, 0x00, 0x00, 0x7b,
  807. // RL Ver
  808. 0x00, 0x00, 0x00, 0x03,
  809. // n1
  810. 0x00, 0x00, 0x00, 0x32,
  811. };
  812. const std::vector<uint8_t> FToCreateLongRl = {
  813. 0x00, 0x00, 0x56, 0x1e, 0xb1, 0x91, 0xb6, 0xdf, 0x40, 0xbc, 0xa2,
  814. 0xe3, 0xe3, 0x92, 0x33, 0xd1, 0xd7, 0x5c, 0xcc, 0x4c, 0x3a, 0xe7,
  815. 0x91, 0x49, 0x73, 0xe2, 0x03, 0xd4, 0x5e, 0x4f, 0x87, 0xad,
  816. };
  817. for (int i = 0; i < 50; ++i) {
  818. for (auto it : FToCreateLongRl) {
  819. long_privrl_file.push_back(it);
  820. }
  821. }
  822. for (auto it : signature.x.data) {
  823. long_privrl_file.push_back(it);
  824. }
  825. for (auto it : signature.y.data) {
  826. long_privrl_file.push_back(it);
  827. }
  828. size_t rl_len = long_privrl_file.size() - 68;
  829. std::vector<uint8_t> rl(rl_len);
  830. EXPECT_EQ(kEpidNoErr,
  831. Epid11ParsePrivRlFile((void*)long_privrl_file.data(),
  832. long_privrl_file.size(), &this->kCert,
  833. (Epid11PrivRl*)rl.data(), &rl_len));
  834. EXPECT_EQ(
  835. std::vector<uint8_t>(&long_privrl_file[4],
  836. &long_privrl_file[long_privrl_file.size() - 64]),
  837. rl);
  838. }
  839. TEST_F(Epid11FileParser, PrivRlRejectsPrivRlFileWithInvalidSignature) {
  840. size_t rl_len = this->kShortPrivRl.size();
  841. std::vector<uint8_t> rl(rl_len);
  842. std::vector<uint8_t> privrl_inv_sign(kShortPrivRlFile);
  843. privrl_inv_sign[privrl_inv_sign.size() - 1] =
  844. privrl_inv_sign[privrl_inv_sign.size() - 1] ^ 0xFF;
  845. EXPECT_EQ(
  846. kEpidSigInvalid,
  847. Epid11ParsePrivRlFile(privrl_inv_sign.data(), privrl_inv_sign.size(),
  848. &this->kCert, (Epid11PrivRl*)rl.data(), &rl_len));
  849. }
  850. TEST_F(Epid11FileParser, PrivRlRejectsGivenInsufficientOutputBufSize) {
  851. size_t rl_len = this->kShortPrivRl.size() - 1;
  852. std::vector<uint8_t> rl(rl_len);
  853. EXPECT_EQ(kEpidBadArgErr,
  854. Epid11ParsePrivRlFile((void*)this->kShortPrivRlFile.data(),
  855. this->kShortPrivRlFile.size(), &this->kCert,
  856. (Epid11PrivRl*)rl.data(), &rl_len));
  857. }
  858. TEST_F(Epid11FileParser, PrivRlReturnsProperSizeGivenOversizedPrivRlBuf) {
  859. size_t rl_len = this->kShortPrivRl.size() + 1;
  860. std::vector<uint8_t> oversized_rl(rl_len);
  861. EXPECT_EQ(kEpidNoErr,
  862. Epid11ParsePrivRlFile((void*)this->kShortPrivRlFile.data(),
  863. this->kShortPrivRlFile.size(), &this->kCert,
  864. (Epid11PrivRl*)oversized_rl.data(), &rl_len));
  865. std::vector<uint8_t> rl(oversized_rl.begin(), oversized_rl.end() - 1);
  866. EXPECT_EQ(this->kShortPrivRl, rl);
  867. EXPECT_EQ(this->kShortPrivRl.size(), rl_len);
  868. }
  869. //////////////////////////////////////////////////////////////////////////
  870. // Epid11ParseSigRlFile Tests
  871. TEST_F(Epid11FileParser, SigRlParseProvidesRequiredLenWithNullDest) {
  872. size_t rl_len = 0;
  873. EXPECT_EQ(kEpidNoErr,
  874. Epid11ParseSigRlFile((void*)this->kShortSigRlFile.data(),
  875. this->kShortSigRlFile.size(), &kCert, nullptr,
  876. &rl_len));
  877. EXPECT_EQ(rl_len, this->kShortSigRl.size());
  878. }
  879. TEST_F(Epid11FileParser, SigRlParseFailsGivenNullParameters) {
  880. size_t rl_len = this->kShortSigRl.size();
  881. std::vector<uint8_t> rl(rl_len);
  882. EXPECT_EQ(kEpidBadArgErr,
  883. Epid11ParseSigRlFile(nullptr, this->kShortSigRlFile.size(), &kCert,
  884. (Epid11SigRl*)rl.data(), &rl_len));
  885. EXPECT_EQ(kEpidBadArgErr,
  886. Epid11ParseSigRlFile((void*)this->kShortSigRlFile.data(),
  887. this->kShortSigRlFile.size(), nullptr,
  888. (Epid11SigRl*)rl.data(), &rl_len));
  889. EXPECT_EQ(kEpidBadArgErr,
  890. Epid11ParseSigRlFile((void*)this->kShortSigRlFile.data(),
  891. this->kShortSigRlFile.size(), &kCert,
  892. (Epid11SigRl*)rl.data(), nullptr));
  893. EXPECT_EQ(kEpidBadArgErr,
  894. Epid11ParseSigRlFile((void*)this->kShortSigRlFile.data(),
  895. this->kShortSigRlFile.size(), &kCert, nullptr,
  896. nullptr));
  897. }
  898. TEST_F(Epid11FileParser, SigRlParseFailsGivenUnsupportedCurveInCA) {
  899. size_t rl_len = this->kShortSigRl.size();
  900. std::vector<uint8_t> rl(rl_len);
  901. EpidCaCertificate unsupported_curve1(kCert);
  902. unsupported_curve1.a.data[0] = unsupported_curve1.a.data[0] ^ 0xFF;
  903. EXPECT_EQ(
  904. kEpidBadArgErr,
  905. Epid11ParseSigRlFile((void*)this->kShortSigRlFile.data(),
  906. this->kShortSigRlFile.size(), &unsupported_curve1,
  907. (Epid11SigRl*)rl.data(), &rl_len));
  908. EpidCaCertificate unsupported_curve2(kCert);
  909. unsupported_curve2.b.data[0] = unsupported_curve2.b.data[0] ^ 0xFF;
  910. EXPECT_EQ(
  911. kEpidBadArgErr,
  912. Epid11ParseSigRlFile((void*)this->kShortSigRlFile.data(),
  913. this->kShortSigRlFile.size(), &unsupported_curve2,
  914. (Epid11SigRl*)rl.data(), &rl_len));
  915. EpidCaCertificate unsupported_curve3(kCert);
  916. unsupported_curve3.x.data[0] = unsupported_curve3.x.data[0] ^ 0xFF;
  917. EXPECT_EQ(
  918. kEpidBadArgErr,
  919. Epid11ParseSigRlFile((void*)this->kShortSigRlFile.data(),
  920. this->kShortSigRlFile.size(), &unsupported_curve3,
  921. (Epid11SigRl*)rl.data(), &rl_len));
  922. EpidCaCertificate unsupported_curve4(kCert);
  923. unsupported_curve4.y.data[0] = unsupported_curve4.y.data[0] ^ 0xFF;
  924. EXPECT_EQ(
  925. kEpidBadArgErr,
  926. Epid11ParseSigRlFile((void*)this->kShortSigRlFile.data(),
  927. this->kShortSigRlFile.size(), &unsupported_curve4,
  928. (Epid11SigRl*)rl.data(), &rl_len));
  929. EpidCaCertificate unsupported_curve5(kCert);
  930. unsupported_curve5.r.data[0] = unsupported_curve5.r.data[0] ^ 0xFF;
  931. EXPECT_EQ(
  932. kEpidBadArgErr,
  933. Epid11ParseSigRlFile((void*)this->kShortSigRlFile.data(),
  934. this->kShortSigRlFile.size(), &unsupported_curve5,
  935. (Epid11SigRl*)rl.data(), &rl_len));
  936. EpidCaCertificate unsupported_curve6(kCert);
  937. unsupported_curve6.prime.data[0] = unsupported_curve6.prime.data[0] ^ 0xFF;
  938. EXPECT_EQ(
  939. kEpidBadArgErr,
  940. Epid11ParseSigRlFile((void*)this->kShortSigRlFile.data(),
  941. this->kShortSigRlFile.size(), &unsupported_curve6,
  942. (Epid11SigRl*)rl.data(), &rl_len));
  943. }
  944. TEST_F(Epid11FileParser, SigRlParseFailsGivenInvalidKeyInCertificate) {
  945. size_t rl_len = this->kShortSigRl.size();
  946. std::vector<uint8_t> rl(rl_len);
  947. EpidCaCertificate invalid_key_qx(kCert);
  948. invalid_key_qx.pubkey.data[0] = invalid_key_qx.pubkey.data[0] ^ 0xFF;
  949. EXPECT_EQ(kEpidBadArgErr,
  950. Epid11ParseSigRlFile((void*)this->kShortSigRlFile.data(),
  951. this->kShortSigRlFile.size(), &invalid_key_qx,
  952. (Epid11SigRl*)rl.data(), &rl_len));
  953. EpidCaCertificate invalid_key_qy(kCert);
  954. invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] =
  955. invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] ^ 0xFF;
  956. EXPECT_EQ(kEpidBadArgErr,
  957. Epid11ParseSigRlFile((void*)this->kShortSigRlFile.data(),
  958. this->kShortSigRlFile.size(), &invalid_key_qy,
  959. (Epid11SigRl*)rl.data(), &rl_len));
  960. EpidCaCertificate invalid_key_qx_qy(kCert);
  961. invalid_key_qx_qy.pubkey.data[0] = invalid_key_qx_qy.pubkey.data[0] ^ 0xFF;
  962. invalid_key_qx_qy.pubkey.data[sizeof(invalid_key_qx_qy.pubkey) - 1] =
  963. invalid_key_qx_qy.pubkey.data[sizeof(invalid_key_qx_qy.pubkey) - 1] ^
  964. 0xFF;
  965. EXPECT_EQ(
  966. kEpidBadArgErr,
  967. Epid11ParseSigRlFile((void*)this->kShortSigRlFile.data(),
  968. this->kShortSigRlFile.size(), &invalid_key_qx_qy,
  969. (Epid11SigRl*)rl.data(), &rl_len));
  970. }
  971. TEST_F(Epid11FileParser, SigRlParseRejectsSigRlFileWithInvalidSize) {
  972. size_t rl_len = this->kEmptySigRl.size();
  973. std::vector<uint8_t> rl(rl_len);
  974. EXPECT_EQ(
  975. kEpidBadArgErr,
  976. Epid11ParseSigRlFile((void*)this->kEmptySigRlFile.data(), 0, &this->kCert,
  977. (Epid11SigRl*)rl.data(), &rl_len));
  978. EXPECT_EQ(kEpidBadArgErr,
  979. Epid11ParseSigRlFile((void*)this->kEmptySigRlFile.data(),
  980. this->kEmptySigRlFile.size() - 1, &this->kCert,
  981. (Epid11SigRl*)rl.data(), &rl_len));
  982. EXPECT_EQ(kEpidBadArgErr,
  983. Epid11ParseSigRlFile((void*)this->kShortSigRlFile.data(),
  984. this->kEmptySigRlFile.size() + 1, &this->kCert,
  985. (Epid11SigRl*)rl.data(), &rl_len));
  986. }
  987. TEST_F(Epid11FileParser, SigRlParseRejectsInvalidSigRlFileType) {
  988. size_t rl_len = this->kShortPrivRl.size();
  989. std::vector<uint8_t> rl(rl_len);
  990. EXPECT_EQ(kEpidBadArgErr,
  991. Epid11ParseSigRlFile((void*)this->kShortPrivRlFile.data(),
  992. this->kShortPrivRlFile.size(), &this->kCert,
  993. (Epid11SigRl*)rl.data(), &rl_len));
  994. }
  995. TEST_F(Epid11FileParser, RejectsSigRlFileWithUnsupportedEpidVersion) {
  996. size_t rl_len = this->kShortSigRl.size();
  997. std::vector<uint8_t> rl(rl_len);
  998. std::vector<uint8_t> unsupported_epidver_file(this->kShortSigRlFile);
  999. unsupported_epidver_file[0] = {0x02};
  1000. EXPECT_EQ(kEpidBadArgErr,
  1001. Epid11ParseSigRlFile((void*)unsupported_epidver_file.data(),
  1002. unsupported_epidver_file.size(), &this->kCert,
  1003. (Epid11SigRl*)rl.data(), &rl_len));
  1004. }
  1005. TEST_F(Epid11FileParser, SigRlParseParsesEmptySigRl) {
  1006. size_t rl_len = this->kEmptySigRl.size();
  1007. std::vector<uint8_t> rl(rl_len);
  1008. EXPECT_EQ(kEpidNoErr,
  1009. Epid11ParseSigRlFile(this->kEmptySigRlFile.data(),
  1010. this->kEmptySigRlFile.size(), &this->kCert,
  1011. (Epid11SigRl*)rl.data(), &rl_len));
  1012. EXPECT_EQ(rl, this->kEmptySigRl);
  1013. }
  1014. TEST_F(Epid11FileParser, SigRlParseParsesShortSigRl) {
  1015. size_t rl_len = this->kShortSigRl.size();
  1016. std::vector<uint8_t> rl(rl_len);
  1017. EXPECT_EQ(kEpidNoErr,
  1018. Epid11ParseSigRlFile(this->kShortSigRlFile.data(),
  1019. this->kShortSigRlFile.size(), &this->kCert,
  1020. (Epid11SigRl*)rl.data(), &rl_len));
  1021. EXPECT_EQ(rl, this->kShortSigRl);
  1022. }
  1023. TEST_F(Epid11FileParser, SigRlParseParsesLongSigRl) {
  1024. std::vector<uint8_t> bk = {
  1025. 0x09, 0x0d, 0x6f, 0x82, 0x77, 0x88, 0x49, 0x53, 0xba, 0x1e, 0x1b, 0x0e,
  1026. 0x5e, 0xae, 0xc0, 0x27, 0xad, 0xe3, 0xb1, 0x09, 0x4f, 0xcd, 0xb6, 0xe6,
  1027. 0x6f, 0x7f, 0xa3, 0x1a, 0x1e, 0xfb, 0x52, 0x72, 0xfa, 0x85, 0x0f, 0x5c,
  1028. 0x97, 0x61, 0xbf, 0x46, 0x7e, 0xec, 0xd6, 0x64, 0xda, 0xa9, 0x8e, 0xf5,
  1029. 0xd3, 0xdf, 0xfa, 0x13, 0x5a, 0xb2, 0x3e, 0xeb, 0x0a, 0x9d, 0x02, 0xc0,
  1030. 0x33, 0xec, 0x2a, 0x70, 0x80, 0x85, 0x35, 0x04, 0x7b, 0xfc, 0x0a, 0x6c,
  1031. 0xb4, 0x10, 0x2d, 0x4a, 0xbe, 0x35, 0x78, 0x41, 0x3a, 0xc6, 0x01, 0x3a,
  1032. 0x59, 0x21, 0x17, 0x04, 0x60, 0x6a, 0x51, 0x6c, 0x84, 0xde, 0xc3, 0x3b,
  1033. 0x1e, 0x6a, 0xaf, 0x82, 0x5d, 0x81, 0xe2, 0x44, 0x25, 0x98, 0x89, 0xdb,
  1034. 0x82, 0x17, 0xe6, 0xb8, 0x9f, 0xfd, 0x03, 0x86, 0x63, 0x8c, 0xe1, 0x93,
  1035. 0x77, 0x61, 0x3c, 0xc2, 0x75, 0x14, 0xa1, 0xc2};
  1036. EcdsaSignature signature = {
  1037. 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, 0xed,
  1038. 0x2a, 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, 0x70, 0x2a,
  1039. 0x6c, 0x06, 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, 0x02,
  1040. 0x23, 0x1d, 0x31, 0x17, 0x88, 0x49, 0x13, 0x47, 0xe7, 0xda, 0xfe,
  1041. 0x8d, 0x67, 0xba, 0x16, 0x1d, 0x0a, 0xd3, 0x4a, 0x2d, 0xd1, 0xf8,
  1042. 0x60, 0x21, 0xa5, 0x00, 0x9a, 0x0d, 0x4d, 0xc4, 0xbd};
  1043. std::vector<uint8_t> long_sigrl_file = {// EPID Version
  1044. 0x01, 0x00,
  1045. // Epid type
  1046. 0x00, 0x0e,
  1047. // GID
  1048. 0x00, 0x00, 0x00, 0x7b,
  1049. // RL ver
  1050. 0x00, 0x00, 0x00, 0x32,
  1051. // n2
  1052. 0x00, 0x00, 0x00, 0x32};
  1053. for (int i = 0; i < 50; ++i) {
  1054. for (auto it : bk) {
  1055. long_sigrl_file.push_back(it);
  1056. }
  1057. }
  1058. for (auto it : signature.x.data) {
  1059. long_sigrl_file.push_back(it);
  1060. }
  1061. for (auto it : signature.y.data) {
  1062. long_sigrl_file.push_back(it);
  1063. }
  1064. size_t rl_len = long_sigrl_file.size() - sizeof(signature) - 4;
  1065. std::vector<uint8_t> rl(rl_len);
  1066. EXPECT_EQ(kEpidNoErr, Epid11ParseSigRlFile(
  1067. long_sigrl_file.data(), long_sigrl_file.size(),
  1068. &this->kCert, (Epid11SigRl*)rl.data(), &rl_len));
  1069. std::vector<uint8_t> expected_long_sig_rl(std::vector<uint8_t>(
  1070. &long_sigrl_file[4],
  1071. &long_sigrl_file[long_sigrl_file.size() - sizeof(signature)]));
  1072. EXPECT_EQ(expected_long_sig_rl, rl);
  1073. }
  1074. TEST_F(Epid11FileParser, RejectsSigRlFileWithInvalidSignature) {
  1075. size_t rl_len = this->kShortSigRl.size();
  1076. std::vector<uint8_t> rl(rl_len);
  1077. std::vector<uint8_t> sigrl_inv_sign(kShortSigRlFile);
  1078. sigrl_inv_sign[sigrl_inv_sign.size() - 1] =
  1079. sigrl_inv_sign[sigrl_inv_sign.size() - 1] ^ 0xFF;
  1080. EXPECT_EQ(
  1081. kEpidSigInvalid,
  1082. Epid11ParseSigRlFile((void*)sigrl_inv_sign.data(), sigrl_inv_sign.size(),
  1083. &this->kCert, (Epid11SigRl*)rl.data(), &rl_len));
  1084. }
  1085. TEST_F(Epid11FileParser, RejectsGivenInsufficientOutputBufSize) {
  1086. size_t rl_len = this->kShortSigRl.size() - 1;
  1087. std::vector<uint8_t> rl(rl_len);
  1088. EXPECT_EQ(kEpidBadArgErr,
  1089. Epid11ParseSigRlFile((void*)this->kShortSigRlFile.data(),
  1090. this->kShortSigRlFile.size(), &this->kCert,
  1091. (Epid11SigRl*)rl.data(), &rl_len));
  1092. }
  1093. TEST_F(Epid11FileParser, ReturnsProperSizeGivenOversizedSigRlBuf) {
  1094. size_t rl_len = this->kShortSigRl.size() + 1;
  1095. std::vector<uint8_t> oversized_rl(rl_len);
  1096. EXPECT_EQ(kEpidNoErr,
  1097. Epid11ParseSigRlFile((void*)this->kShortSigRlFile.data(),
  1098. this->kShortSigRlFile.size(), &this->kCert,
  1099. (Epid11SigRl*)oversized_rl.data(), &rl_len));
  1100. std::vector<uint8_t> rl(oversized_rl.begin(), oversized_rl.end() - 1);
  1101. EXPECT_EQ(this->kShortSigRl, rl);
  1102. EXPECT_EQ(this->kShortSigRl.size(), rl_len);
  1103. }
  1104. //////////////////////////////////////////////////////////////////////////
  1105. // Epid11ParseGroupRlFile Tests
  1106. TEST_F(Epid11FileParser, GroupRlParseProvidesRequiredLenWithNullDest) {
  1107. size_t rl_len = 0;
  1108. EXPECT_EQ(kEpidNoErr,
  1109. Epid11ParseGroupRlFile((void*)this->kShortGroupRlFile.data(),
  1110. this->kShortGroupRlFile.size(), &kCert,
  1111. nullptr, &rl_len));
  1112. EXPECT_EQ(this->kShortGroupRl.size(), rl_len);
  1113. }
  1114. TEST_F(Epid11FileParser, GroupRlParseFailsGivenNullParameters) {
  1115. size_t rl_len = this->kShortGroupRl.size();
  1116. std::vector<uint8_t> rl(rl_len);
  1117. EXPECT_EQ(kEpidBadArgErr,
  1118. Epid11ParseGroupRlFile(nullptr, this->kShortGroupRlFile.size(),
  1119. &kCert, (Epid11GroupRl*)rl.data(), &rl_len));
  1120. EXPECT_EQ(kEpidBadArgErr,
  1121. Epid11ParseGroupRlFile((void*)this->kShortGroupRlFile.data(),
  1122. this->kShortGroupRlFile.size(), nullptr,
  1123. (Epid11GroupRl*)rl.data(), &rl_len));
  1124. EXPECT_EQ(kEpidBadArgErr,
  1125. Epid11ParseGroupRlFile((void*)this->kShortGroupRlFile.data(),
  1126. this->kShortGroupRlFile.size(), &kCert,
  1127. (Epid11GroupRl*)rl.data(), nullptr));
  1128. EXPECT_EQ(kEpidBadArgErr,
  1129. Epid11ParseGroupRlFile((void*)this->kShortGroupRlFile.data(),
  1130. this->kShortGroupRlFile.size(), &kCert,
  1131. nullptr, nullptr));
  1132. }
  1133. TEST_F(Epid11FileParser, GroupRlParseFailsGivenUnsupportedCurve) {
  1134. size_t rl_len = this->kShortGroupRl.size();
  1135. std::vector<uint8_t> rl(rl_len);
  1136. EpidCaCertificate unsupported_curve1(kCert);
  1137. unsupported_curve1.a.data[0] = unsupported_curve1.a.data[0] ^ 0xFF;
  1138. EXPECT_EQ(kEpidBadArgErr,
  1139. Epid11ParseGroupRlFile((void*)this->kShortGroupRlFile.data(),
  1140. this->kShortGroupRlFile.size(),
  1141. &unsupported_curve1,
  1142. (Epid11GroupRl*)rl.data(), &rl_len));
  1143. EpidCaCertificate unsupported_curve2(kCert);
  1144. unsupported_curve2.b.data[0] = unsupported_curve2.b.data[0] ^ 0xFF;
  1145. EXPECT_EQ(kEpidBadArgErr,
  1146. Epid11ParseGroupRlFile((void*)this->kShortGroupRlFile.data(),
  1147. this->kShortGroupRlFile.size(),
  1148. &unsupported_curve2,
  1149. (Epid11GroupRl*)rl.data(), &rl_len));
  1150. EpidCaCertificate unsupported_curve3(kCert);
  1151. unsupported_curve3.x.data[0] = unsupported_curve3.x.data[0] ^ 0xFF;
  1152. EXPECT_EQ(kEpidBadArgErr,
  1153. Epid11ParseGroupRlFile((void*)this->kShortGroupRlFile.data(),
  1154. this->kShortGroupRlFile.size(),
  1155. &unsupported_curve3,
  1156. (Epid11GroupRl*)rl.data(), &rl_len));
  1157. EpidCaCertificate unsupported_curve4(kCert);
  1158. unsupported_curve4.y.data[0] = unsupported_curve4.y.data[0] ^ 0xFF;
  1159. EXPECT_EQ(kEpidBadArgErr,
  1160. Epid11ParseGroupRlFile((void*)this->kShortGroupRlFile.data(),
  1161. this->kShortGroupRlFile.size(),
  1162. &unsupported_curve4,
  1163. (Epid11GroupRl*)rl.data(), &rl_len));
  1164. EpidCaCertificate unsupported_curve5(kCert);
  1165. unsupported_curve5.r.data[0] = unsupported_curve5.r.data[0] ^ 0xFF;
  1166. EXPECT_EQ(kEpidBadArgErr,
  1167. Epid11ParseGroupRlFile((void*)this->kShortGroupRlFile.data(),
  1168. this->kShortGroupRlFile.size(),
  1169. &unsupported_curve5,
  1170. (Epid11GroupRl*)rl.data(), &rl_len));
  1171. EpidCaCertificate unsupported_curve6(kCert);
  1172. unsupported_curve6.prime.data[0] = unsupported_curve6.prime.data[0] ^ 0xFF;
  1173. EXPECT_EQ(kEpidBadArgErr,
  1174. Epid11ParseGroupRlFile((void*)this->kShortGroupRlFile.data(),
  1175. this->kShortGroupRlFile.size(),
  1176. &unsupported_curve6,
  1177. (Epid11GroupRl*)rl.data(), &rl_len));
  1178. }
  1179. TEST_F(Epid11FileParser, GroupRlParseFailsGivenInvalidKeyInCertificate) {
  1180. size_t rl_len = this->kShortGroupRl.size();
  1181. std::vector<uint8_t> rl(rl_len);
  1182. EpidCaCertificate invalid_key_qx(kCert);
  1183. invalid_key_qx.pubkey.data[0] = invalid_key_qx.pubkey.data[0] ^ 0xFF;
  1184. EXPECT_EQ(kEpidBadArgErr, Epid11ParseGroupRlFile(
  1185. (void*)this->kShortGroupRlFile.data(),
  1186. this->kShortGroupRlFile.size(), &invalid_key_qx,
  1187. (Epid11GroupRl*)rl.data(), &rl_len));
  1188. EpidCaCertificate invalid_key_qy(kCert);
  1189. invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] =
  1190. invalid_key_qy.pubkey.data[sizeof(invalid_key_qy.pubkey) - 1] ^ 0xFF;
  1191. EXPECT_EQ(kEpidBadArgErr, Epid11ParseGroupRlFile(
  1192. (void*)this->kShortGroupRlFile.data(),
  1193. this->kShortGroupRlFile.size(), &invalid_key_qy,
  1194. (Epid11GroupRl*)rl.data(), &rl_len));
  1195. EpidCaCertificate invalid_key_qx_qy(kCert);
  1196. invalid_key_qx_qy.pubkey.data[0] = invalid_key_qx_qy.pubkey.data[0] ^ 0xFF;
  1197. invalid_key_qx_qy.pubkey.data[sizeof(invalid_key_qx_qy.pubkey) - 1] =
  1198. invalid_key_qx_qy.pubkey.data[sizeof(invalid_key_qx_qy.pubkey) - 1] ^
  1199. 0xFF;
  1200. EXPECT_EQ(
  1201. kEpidBadArgErr,
  1202. Epid11ParseGroupRlFile((void*)this->kShortGroupRlFile.data(),
  1203. this->kShortGroupRlFile.size(), &invalid_key_qx_qy,
  1204. (Epid11GroupRl*)rl.data(), &rl_len));
  1205. }
  1206. TEST_F(Epid11FileParser, RejectsGroupRlFileWithInvalidSize) {
  1207. size_t rl_len = this->kEmptyGroupRl.size();
  1208. std::vector<uint8_t> rl(rl_len);
  1209. EXPECT_EQ(
  1210. kEpidBadArgErr,
  1211. Epid11ParseGroupRlFile((void*)this->kEmptyGroupRlFile.data(), 0,
  1212. &this->kCert, (Epid11GroupRl*)rl.data(), &rl_len));
  1213. EXPECT_EQ(
  1214. kEpidBadArgErr,
  1215. Epid11ParseGroupRlFile((void*)this->kEmptyGroupRlFile.data(),
  1216. this->kEmptyGroupRlFile.size() - 1, &this->kCert,
  1217. (Epid11GroupRl*)rl.data(), &rl_len));
  1218. EXPECT_EQ(
  1219. kEpidBadArgErr,
  1220. Epid11ParseGroupRlFile((void*)this->kShortGroupRlFile.data(),
  1221. this->kEmptyGroupRlFile.size() + 1, &this->kCert,
  1222. (Epid11GroupRl*)rl.data(), &rl_len));
  1223. }
  1224. TEST_F(Epid11FileParser, RejectsInvalidGroupRlFileType) {
  1225. size_t rl_len = this->kShortPrivRl.size();
  1226. std::vector<uint8_t> rl(rl_len);
  1227. EXPECT_EQ(kEpidBadArgErr,
  1228. Epid11ParseGroupRlFile((void*)this->kShortPrivRlFile.data(),
  1229. this->kShortPrivRlFile.size(), &this->kCert,
  1230. (Epid11GroupRl*)rl.data(), &rl_len));
  1231. }
  1232. TEST_F(Epid11FileParser, RejectsGroupRlFileWithUnsupportedEpidVersion) {
  1233. size_t rl_len = this->kShortGroupRl.size();
  1234. std::vector<uint8_t> rl(rl_len);
  1235. std::vector<uint8_t> unsupported_epidver_file(this->kShortGroupRlFile);
  1236. unsupported_epidver_file[0] = {0x02};
  1237. EXPECT_EQ(kEpidBadArgErr, Epid11ParseGroupRlFile(
  1238. (void*)unsupported_epidver_file.data(),
  1239. unsupported_epidver_file.size(), &this->kCert,
  1240. (Epid11GroupRl*)rl.data(), &rl_len));
  1241. }
  1242. TEST_F(Epid11FileParser, ParsesEmptyGroupRl) {
  1243. size_t rl_len = this->kEmptyGroupRl.size();
  1244. std::vector<uint8_t> rl(rl_len);
  1245. EXPECT_EQ(kEpidNoErr,
  1246. Epid11ParseGroupRlFile(this->kEmptyGroupRlFile.data(),
  1247. this->kEmptyGroupRlFile.size(), &this->kCert,
  1248. (Epid11GroupRl*)rl.data(), &rl_len));
  1249. EXPECT_EQ(rl, this->kEmptyGroupRl);
  1250. }
  1251. TEST_F(Epid11FileParser, ParsesShortGroupRl) {
  1252. size_t rl_len = this->kShortGroupRl.size();
  1253. std::vector<uint8_t> rl(rl_len);
  1254. EXPECT_EQ(kEpidNoErr,
  1255. Epid11ParseGroupRlFile(this->kShortGroupRlFile.data(),
  1256. this->kShortGroupRlFile.size(), &this->kCert,
  1257. (Epid11GroupRl*)rl.data(), &rl_len));
  1258. EXPECT_EQ(rl, this->kShortGroupRl);
  1259. }
  1260. TEST_F(Epid11FileParser, ParsesLongGroupRl) {
  1261. std::vector<uint8_t> gid = {0x00, 0x00, 0x00, 0x01};
  1262. EcdsaSignature signature = {
  1263. 0xfb, 0x57, 0x6f, 0x15, 0x3e, 0xf8, 0x41, 0x47, 0x51, 0x71, 0xed,
  1264. 0x2a, 0x9b, 0x88, 0x99, 0x5b, 0x85, 0x3b, 0xdf, 0xf9, 0x70, 0x2a,
  1265. 0x6c, 0x06, 0x3b, 0x72, 0x02, 0x32, 0xb9, 0x3a, 0x76, 0xe7, 0x64,
  1266. 0x0c, 0xa9, 0x25, 0xb2, 0x50, 0xc8, 0xd7, 0x9d, 0xb8, 0xb4, 0x37,
  1267. 0x30, 0x90, 0x53, 0x8f, 0x55, 0x50, 0xcf, 0xed, 0x9e, 0xaa, 0x31,
  1268. 0x4f, 0x7f, 0xb2, 0x27, 0xf9, 0xbb, 0xfa, 0x52, 0x70};
  1269. std::vector<uint8_t> long_grouprl_file = {
  1270. /// EPID version
  1271. 0x01, 0x00,
  1272. // File type
  1273. 0x00, 0x0f,
  1274. // RL ver
  1275. 0x00, 0x00, 0x00, 0x32,
  1276. // n3
  1277. 0x00, 0x00, 0x00, 0x32,
  1278. };
  1279. for (int i = 0; i < 50; ++i) {
  1280. for (auto it : gid) {
  1281. long_grouprl_file.push_back(it);
  1282. }
  1283. gid[3]++;
  1284. }
  1285. for (auto it : signature.x.data) {
  1286. long_grouprl_file.push_back(it);
  1287. }
  1288. for (auto it : signature.y.data) {
  1289. long_grouprl_file.push_back(it);
  1290. }
  1291. size_t rl_len = long_grouprl_file.size() - sizeof(signature) - 4;
  1292. std::vector<uint8_t> rl(rl_len);
  1293. EXPECT_EQ(kEpidNoErr, Epid11ParseGroupRlFile(
  1294. long_grouprl_file.data(), long_grouprl_file.size(),
  1295. &this->kCert, (Epid11GroupRl*)rl.data(), &rl_len));
  1296. std::vector<uint8_t> expected_long_gr_rl(std::vector<uint8_t>(
  1297. &long_grouprl_file[4],
  1298. &long_grouprl_file[long_grouprl_file.size() - sizeof(signature)]));
  1299. EXPECT_EQ(expected_long_gr_rl, rl);
  1300. }
  1301. TEST_F(Epid11FileParser, RejectsGroupRlFileWithInvalidSignature) {
  1302. size_t rl_len = this->kShortGroupRl.size();
  1303. std::vector<uint8_t> rl(rl_len);
  1304. std::vector<uint8_t> grouprl_inv_sign(this->kShortGroupRlFile);
  1305. grouprl_inv_sign[grouprl_inv_sign.size() - 1] =
  1306. grouprl_inv_sign[grouprl_inv_sign.size() - 1] ^ 0xFF;
  1307. EXPECT_EQ(kEpidSigInvalid,
  1308. Epid11ParseGroupRlFile((void*)grouprl_inv_sign.data(),
  1309. grouprl_inv_sign.size(), &this->kCert,
  1310. (Epid11GroupRl*)rl.data(), &rl_len));
  1311. }
  1312. TEST_F(Epid11FileParser, GroupRlParseRejectsBufWithInsufficientSize) {
  1313. size_t rl_len = this->kShortGroupRl.size() - 1;
  1314. std::vector<uint8_t> rl(rl_len);
  1315. EXPECT_EQ(kEpidBadArgErr,
  1316. Epid11ParseGroupRlFile((void*)this->kShortGroupRlFile.data(),
  1317. this->kShortGroupRlFile.size(), &this->kCert,
  1318. (Epid11GroupRl*)rl.data(), &rl_len));
  1319. }
  1320. TEST_F(Epid11FileParser, ReturnsProperSizeGivenOversizedGroupRlBuf) {
  1321. size_t rl_len = this->kShortGroupRl.size() + 1;
  1322. std::vector<uint8_t> oversized_rl(rl_len);
  1323. EXPECT_EQ(kEpidNoErr, Epid11ParseGroupRlFile(
  1324. (void*)this->kShortGroupRlFile.data(),
  1325. this->kShortGroupRlFile.size(), &this->kCert,
  1326. (Epid11GroupRl*)oversized_rl.data(), &rl_len));
  1327. std::vector<uint8_t> rl(oversized_rl.begin(), oversized_rl.end() - 1);
  1328. EXPECT_EQ(this->kShortGroupRl, rl);
  1329. EXPECT_EQ(this->kShortGroupRl.size(), rl_len);
  1330. }
  1331. } // namespace