Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1182 lines
36 KiB

  1. /* Copyright (C) Microsoft Corporation, 1996 - 1999 All rights reserved. */
  2. /* ASN.1 definitions for Indirect data contents */
  3. #include <windows.h>
  4. #include "wtasn.h"
  5. ASN1module_t WTASN_Module = NULL;
  6. static int ASN1CALL ASN1Enc_ObjectID(ASN1encoding_t enc, ASN1uint32_t tag, ObjectID *val);
  7. static int ASN1CALL ASN1Enc_SpcMinimalCriteria(ASN1encoding_t enc, ASN1uint32_t tag, SpcMinimalCriteria *val);
  8. static int ASN1CALL ASN1Enc_UtcTime(ASN1encoding_t enc, ASN1uint32_t tag, UtcTime *val);
  9. static int ASN1CALL ASN1Enc_AlgorithmIdentifier(ASN1encoding_t enc, ASN1uint32_t tag, AlgorithmIdentifier *val);
  10. static int ASN1CALL ASN1Enc_DigestInfo(ASN1encoding_t enc, ASN1uint32_t tag, DigestInfo *val);
  11. static int ASN1CALL ASN1Enc_SpcAttributeTypeAndOptionalValue(ASN1encoding_t enc, ASN1uint32_t tag, SpcAttributeTypeAndOptionalValue *val);
  12. static int ASN1CALL ASN1Enc_SpcString(ASN1encoding_t enc, ASN1uint32_t tag, SpcString *val);
  13. static int ASN1CALL ASN1Enc_SpcSerializedObject(ASN1encoding_t enc, ASN1uint32_t tag, SpcSerializedObject *val);
  14. static int ASN1CALL ASN1Enc_SpcLink(ASN1encoding_t enc, ASN1uint32_t tag, SpcLink *val);
  15. static int ASN1CALL ASN1Enc_SpcPeImageData(ASN1encoding_t enc, ASN1uint32_t tag, SpcPeImageData *val);
  16. static int ASN1CALL ASN1Enc_SpcSigInfo(ASN1encoding_t enc, ASN1uint32_t tag, SpcSigInfo *val);
  17. static int ASN1CALL ASN1Enc_SpcImage(ASN1encoding_t enc, ASN1uint32_t tag, SpcImage *val);
  18. static int ASN1CALL ASN1Enc_SpcFinancialCriteria(ASN1encoding_t enc, ASN1uint32_t tag, SpcFinancialCriteria *val);
  19. static int ASN1CALL ASN1Enc_SpcStatementType(ASN1encoding_t enc, ASN1uint32_t tag, SpcStatementType *val);
  20. static int ASN1CALL ASN1Enc_SpcSpOpusInfo(ASN1encoding_t enc, ASN1uint32_t tag, SpcSpOpusInfo *val);
  21. static int ASN1CALL ASN1Enc_NameValue(ASN1encoding_t enc, ASN1uint32_t tag, NameValue *val);
  22. static int ASN1CALL ASN1Enc_NameValues(ASN1encoding_t enc, ASN1uint32_t tag, NameValues *val);
  23. static int ASN1CALL ASN1Enc_MemberInfo(ASN1encoding_t enc, ASN1uint32_t tag, MemberInfo *val);
  24. static int ASN1CALL ASN1Enc_SpcIndirectDataContent(ASN1encoding_t enc, ASN1uint32_t tag, SpcIndirectDataContent *val);
  25. static int ASN1CALL ASN1Enc_SpcSpAgencyInformation(ASN1encoding_t enc, ASN1uint32_t tag, SpcSpAgencyInformation *val);
  26. static int ASN1CALL ASN1Dec_ObjectID(ASN1decoding_t dec, ASN1uint32_t tag, ObjectID *val);
  27. static int ASN1CALL ASN1Dec_SpcMinimalCriteria(ASN1decoding_t dec, ASN1uint32_t tag, SpcMinimalCriteria *val);
  28. static int ASN1CALL ASN1Dec_UtcTime(ASN1decoding_t dec, ASN1uint32_t tag, UtcTime *val);
  29. static int ASN1CALL ASN1Dec_AlgorithmIdentifier(ASN1decoding_t dec, ASN1uint32_t tag, AlgorithmIdentifier *val);
  30. static int ASN1CALL ASN1Dec_DigestInfo(ASN1decoding_t dec, ASN1uint32_t tag, DigestInfo *val);
  31. static int ASN1CALL ASN1Dec_SpcAttributeTypeAndOptionalValue(ASN1decoding_t dec, ASN1uint32_t tag, SpcAttributeTypeAndOptionalValue *val);
  32. static int ASN1CALL ASN1Dec_SpcString(ASN1decoding_t dec, ASN1uint32_t tag, SpcString *val);
  33. static int ASN1CALL ASN1Dec_SpcSerializedObject(ASN1decoding_t dec, ASN1uint32_t tag, SpcSerializedObject *val);
  34. static int ASN1CALL ASN1Dec_SpcLink(ASN1decoding_t dec, ASN1uint32_t tag, SpcLink *val);
  35. static int ASN1CALL ASN1Dec_SpcPeImageData(ASN1decoding_t dec, ASN1uint32_t tag, SpcPeImageData *val);
  36. static int ASN1CALL ASN1Dec_SpcSigInfo(ASN1decoding_t dec, ASN1uint32_t tag, SpcSigInfo *val);
  37. static int ASN1CALL ASN1Dec_SpcImage(ASN1decoding_t dec, ASN1uint32_t tag, SpcImage *val);
  38. static int ASN1CALL ASN1Dec_SpcFinancialCriteria(ASN1decoding_t dec, ASN1uint32_t tag, SpcFinancialCriteria *val);
  39. static int ASN1CALL ASN1Dec_SpcStatementType(ASN1decoding_t dec, ASN1uint32_t tag, SpcStatementType *val);
  40. static int ASN1CALL ASN1Dec_SpcSpOpusInfo(ASN1decoding_t dec, ASN1uint32_t tag, SpcSpOpusInfo *val);
  41. static int ASN1CALL ASN1Dec_NameValue(ASN1decoding_t dec, ASN1uint32_t tag, NameValue *val);
  42. static int ASN1CALL ASN1Dec_NameValues(ASN1decoding_t dec, ASN1uint32_t tag, NameValues *val);
  43. static int ASN1CALL ASN1Dec_MemberInfo(ASN1decoding_t dec, ASN1uint32_t tag, MemberInfo *val);
  44. static int ASN1CALL ASN1Dec_SpcIndirectDataContent(ASN1decoding_t dec, ASN1uint32_t tag, SpcIndirectDataContent *val);
  45. static int ASN1CALL ASN1Dec_SpcSpAgencyInformation(ASN1decoding_t dec, ASN1uint32_t tag, SpcSpAgencyInformation *val);
  46. static void ASN1CALL ASN1Free_ObjectID(ObjectID *val);
  47. static void ASN1CALL ASN1Free_UtcTime(UtcTime *val);
  48. static void ASN1CALL ASN1Free_AlgorithmIdentifier(AlgorithmIdentifier *val);
  49. static void ASN1CALL ASN1Free_DigestInfo(DigestInfo *val);
  50. static void ASN1CALL ASN1Free_SpcAttributeTypeAndOptionalValue(SpcAttributeTypeAndOptionalValue *val);
  51. static void ASN1CALL ASN1Free_SpcString(SpcString *val);
  52. static void ASN1CALL ASN1Free_SpcSerializedObject(SpcSerializedObject *val);
  53. static void ASN1CALL ASN1Free_SpcLink(SpcLink *val);
  54. static void ASN1CALL ASN1Free_SpcPeImageData(SpcPeImageData *val);
  55. static void ASN1CALL ASN1Free_SpcSigInfo(SpcSigInfo *val);
  56. static void ASN1CALL ASN1Free_SpcImage(SpcImage *val);
  57. static void ASN1CALL ASN1Free_SpcStatementType(SpcStatementType *val);
  58. static void ASN1CALL ASN1Free_SpcSpOpusInfo(SpcSpOpusInfo *val);
  59. static void ASN1CALL ASN1Free_NameValue(NameValue *val);
  60. static void ASN1CALL ASN1Free_NameValues(NameValues *val);
  61. static void ASN1CALL ASN1Free_MemberInfo(MemberInfo *val);
  62. static void ASN1CALL ASN1Free_SpcIndirectDataContent(SpcIndirectDataContent *val);
  63. static void ASN1CALL ASN1Free_SpcSpAgencyInformation(SpcSpAgencyInformation *val);
  64. typedef ASN1BerEncFun_t ASN1EncFun_t;
  65. static const ASN1EncFun_t encfntab[14] = {
  66. (ASN1EncFun_t) ASN1Enc_ObjectID,
  67. (ASN1EncFun_t) ASN1Enc_SpcMinimalCriteria,
  68. (ASN1EncFun_t) ASN1Enc_UtcTime,
  69. (ASN1EncFun_t) ASN1Enc_SpcLink,
  70. (ASN1EncFun_t) ASN1Enc_SpcPeImageData,
  71. (ASN1EncFun_t) ASN1Enc_SpcSigInfo,
  72. (ASN1EncFun_t) ASN1Enc_SpcFinancialCriteria,
  73. (ASN1EncFun_t) ASN1Enc_SpcStatementType,
  74. (ASN1EncFun_t) ASN1Enc_SpcSpOpusInfo,
  75. (ASN1EncFun_t) ASN1Enc_NameValue,
  76. (ASN1EncFun_t) ASN1Enc_NameValues,
  77. (ASN1EncFun_t) ASN1Enc_MemberInfo,
  78. (ASN1EncFun_t) ASN1Enc_SpcIndirectDataContent,
  79. (ASN1EncFun_t) ASN1Enc_SpcSpAgencyInformation,
  80. };
  81. typedef ASN1BerDecFun_t ASN1DecFun_t;
  82. static const ASN1DecFun_t decfntab[14] = {
  83. (ASN1DecFun_t) ASN1Dec_ObjectID,
  84. (ASN1DecFun_t) ASN1Dec_SpcMinimalCriteria,
  85. (ASN1DecFun_t) ASN1Dec_UtcTime,
  86. (ASN1DecFun_t) ASN1Dec_SpcLink,
  87. (ASN1DecFun_t) ASN1Dec_SpcPeImageData,
  88. (ASN1DecFun_t) ASN1Dec_SpcSigInfo,
  89. (ASN1DecFun_t) ASN1Dec_SpcFinancialCriteria,
  90. (ASN1DecFun_t) ASN1Dec_SpcStatementType,
  91. (ASN1DecFun_t) ASN1Dec_SpcSpOpusInfo,
  92. (ASN1DecFun_t) ASN1Dec_NameValue,
  93. (ASN1DecFun_t) ASN1Dec_NameValues,
  94. (ASN1DecFun_t) ASN1Dec_MemberInfo,
  95. (ASN1DecFun_t) ASN1Dec_SpcIndirectDataContent,
  96. (ASN1DecFun_t) ASN1Dec_SpcSpAgencyInformation,
  97. };
  98. static const ASN1FreeFun_t freefntab[14] = {
  99. (ASN1FreeFun_t) ASN1Free_ObjectID,
  100. (ASN1FreeFun_t) NULL,
  101. (ASN1FreeFun_t) ASN1Free_UtcTime,
  102. (ASN1FreeFun_t) ASN1Free_SpcLink,
  103. (ASN1FreeFun_t) ASN1Free_SpcPeImageData,
  104. (ASN1FreeFun_t) ASN1Free_SpcSigInfo,
  105. (ASN1FreeFun_t) NULL,
  106. (ASN1FreeFun_t) ASN1Free_SpcStatementType,
  107. (ASN1FreeFun_t) ASN1Free_SpcSpOpusInfo,
  108. (ASN1FreeFun_t) ASN1Free_NameValue,
  109. (ASN1FreeFun_t) ASN1Free_NameValues,
  110. (ASN1FreeFun_t) ASN1Free_MemberInfo,
  111. (ASN1FreeFun_t) ASN1Free_SpcIndirectDataContent,
  112. (ASN1FreeFun_t) ASN1Free_SpcSpAgencyInformation,
  113. };
  114. static const ULONG sizetab[14] = {
  115. SIZE_WTASN_Module_PDU_0,
  116. SIZE_WTASN_Module_PDU_1,
  117. SIZE_WTASN_Module_PDU_2,
  118. SIZE_WTASN_Module_PDU_3,
  119. SIZE_WTASN_Module_PDU_4,
  120. SIZE_WTASN_Module_PDU_5,
  121. SIZE_WTASN_Module_PDU_6,
  122. SIZE_WTASN_Module_PDU_7,
  123. SIZE_WTASN_Module_PDU_8,
  124. SIZE_WTASN_Module_PDU_9,
  125. SIZE_WTASN_Module_PDU_10,
  126. SIZE_WTASN_Module_PDU_11,
  127. SIZE_WTASN_Module_PDU_12,
  128. SIZE_WTASN_Module_PDU_13,
  129. };
  130. /* forward declarations of values: */
  131. extern ASN1octet_t SpcPeImageData_flags_default_octets[1];
  132. /* definitions of value components: */
  133. static ASN1octet_t SpcPeImageData_flags_default_octets[1] = { 0x80 };
  134. /* definitions of values: */
  135. SpcPeImageFlags SpcPeImageData_flags_default = { 1, SpcPeImageData_flags_default_octets };
  136. void ASN1CALL WTASN_Module_Startup(void)
  137. {
  138. WTASN_Module = ASN1_CreateModule(0x10000, ASN1_BER_RULE_DER, ASN1FLAGS_NOASSERT, 14, (const ASN1GenericFun_t *) encfntab, (const ASN1GenericFun_t *) decfntab, freefntab, sizetab, 0x7477);
  139. }
  140. void ASN1CALL WTASN_Module_Cleanup(void)
  141. {
  142. ASN1_CloseModule(WTASN_Module);
  143. WTASN_Module = NULL;
  144. }
  145. static int ASN1CALL ASN1Enc_ObjectID(ASN1encoding_t enc, ASN1uint32_t tag, ObjectID *val)
  146. {
  147. if (!ASN1BEREncObjectIdentifier2(enc, tag ? tag : 0x6, val))
  148. return 0;
  149. return 1;
  150. }
  151. static int ASN1CALL ASN1Dec_ObjectID(ASN1decoding_t dec, ASN1uint32_t tag, ObjectID *val)
  152. {
  153. if (!ASN1BERDecObjectIdentifier2(dec, tag ? tag : 0x6, val))
  154. return 0;
  155. return 1;
  156. }
  157. static void ASN1CALL ASN1Free_ObjectID(ObjectID *val)
  158. {
  159. if (val) {
  160. }
  161. }
  162. static int ASN1CALL ASN1Enc_SpcMinimalCriteria(ASN1encoding_t enc, ASN1uint32_t tag, SpcMinimalCriteria *val)
  163. {
  164. if (!ASN1BEREncBool(enc, tag ? tag : 0x1, *val))
  165. return 0;
  166. return 1;
  167. }
  168. static int ASN1CALL ASN1Dec_SpcMinimalCriteria(ASN1decoding_t dec, ASN1uint32_t tag, SpcMinimalCriteria *val)
  169. {
  170. if (!ASN1BERDecBool(dec, tag ? tag : 0x1, val))
  171. return 0;
  172. return 1;
  173. }
  174. static int ASN1CALL ASN1Enc_UtcTime(ASN1encoding_t enc, ASN1uint32_t tag, UtcTime *val)
  175. {
  176. if (!ASN1DEREncUTCTime(enc, tag ? tag : 0x17, val))
  177. return 0;
  178. return 1;
  179. }
  180. static int ASN1CALL ASN1Dec_UtcTime(ASN1decoding_t dec, ASN1uint32_t tag, UtcTime *val)
  181. {
  182. if (!ASN1BERDecUTCTime(dec, tag ? tag : 0x17, val))
  183. return 0;
  184. return 1;
  185. }
  186. static void ASN1CALL ASN1Free_UtcTime(UtcTime *val)
  187. {
  188. if (val) {
  189. }
  190. }
  191. static int ASN1CALL ASN1Enc_AlgorithmIdentifier(ASN1encoding_t enc, ASN1uint32_t tag, AlgorithmIdentifier *val)
  192. {
  193. ASN1uint32_t nLenOff;
  194. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  195. return 0;
  196. if (!ASN1BEREncObjectIdentifier2(enc, 0x6, &(val)->algorithm))
  197. return 0;
  198. if ((val)->o[0] & 0x80) {
  199. if (!ASN1BEREncOpenType(enc, &(val)->parameters))
  200. return 0;
  201. }
  202. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  203. return 0;
  204. return 1;
  205. }
  206. static int ASN1CALL ASN1Dec_AlgorithmIdentifier(ASN1decoding_t dec, ASN1uint32_t tag, AlgorithmIdentifier *val)
  207. {
  208. ASN1decoding_t dd;
  209. ASN1octet_t *di;
  210. ASN1uint32_t t;
  211. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  212. return 0;
  213. ZeroMemory((val)->o, 1);
  214. if (!ASN1BERDecObjectIdentifier2(dd, 0x6, &(val)->algorithm))
  215. return 0;
  216. if (ASN1BERDecPeekTag(dd, &t)) {
  217. (val)->o[0] |= 0x80;
  218. if (!ASN1BERDecOpenType2(dd, &(val)->parameters))
  219. return 0;
  220. }
  221. if (!ASN1BERDecEndOfContents(dec, dd, di))
  222. return 0;
  223. return 1;
  224. }
  225. static void ASN1CALL ASN1Free_AlgorithmIdentifier(AlgorithmIdentifier *val)
  226. {
  227. if (val) {
  228. if ((val)->o[0] & 0x80) {
  229. }
  230. }
  231. }
  232. static int ASN1CALL ASN1Enc_DigestInfo(ASN1encoding_t enc, ASN1uint32_t tag, DigestInfo *val)
  233. {
  234. ASN1uint32_t nLenOff;
  235. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  236. return 0;
  237. if (!ASN1Enc_AlgorithmIdentifier(enc, 0, &(val)->digestAlgorithm))
  238. return 0;
  239. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->digest).length, ((val)->digest).value))
  240. return 0;
  241. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  242. return 0;
  243. return 1;
  244. }
  245. static int ASN1CALL ASN1Dec_DigestInfo(ASN1decoding_t dec, ASN1uint32_t tag, DigestInfo *val)
  246. {
  247. ASN1decoding_t dd;
  248. ASN1octet_t *di;
  249. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  250. return 0;
  251. if (!ASN1Dec_AlgorithmIdentifier(dd, 0, &(val)->digestAlgorithm))
  252. return 0;
  253. if (!ASN1BERDecOctetString2(dd, 0x4, &(val)->digest))
  254. return 0;
  255. if (!ASN1BERDecEndOfContents(dec, dd, di))
  256. return 0;
  257. return 1;
  258. }
  259. static void ASN1CALL ASN1Free_DigestInfo(DigestInfo *val)
  260. {
  261. if (val) {
  262. ASN1Free_AlgorithmIdentifier(&(val)->digestAlgorithm);
  263. }
  264. }
  265. static int ASN1CALL ASN1Enc_SpcAttributeTypeAndOptionalValue(ASN1encoding_t enc, ASN1uint32_t tag, SpcAttributeTypeAndOptionalValue *val)
  266. {
  267. ASN1uint32_t nLenOff;
  268. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  269. return 0;
  270. if (!ASN1BEREncObjectIdentifier2(enc, 0x6, &(val)->type))
  271. return 0;
  272. if ((val)->o[0] & 0x80) {
  273. if (!ASN1BEREncOpenType(enc, &(val)->value))
  274. return 0;
  275. }
  276. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  277. return 0;
  278. return 1;
  279. }
  280. static int ASN1CALL ASN1Dec_SpcAttributeTypeAndOptionalValue(ASN1decoding_t dec, ASN1uint32_t tag, SpcAttributeTypeAndOptionalValue *val)
  281. {
  282. ASN1decoding_t dd;
  283. ASN1octet_t *di;
  284. ASN1uint32_t t;
  285. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  286. return 0;
  287. ZeroMemory((val)->o, 1);
  288. if (!ASN1BERDecObjectIdentifier2(dd, 0x6, &(val)->type))
  289. return 0;
  290. if (ASN1BERDecPeekTag(dd, &t)) {
  291. (val)->o[0] |= 0x80;
  292. if (!ASN1BERDecOpenType2(dd, &(val)->value))
  293. return 0;
  294. }
  295. if (!ASN1BERDecEndOfContents(dec, dd, di))
  296. return 0;
  297. return 1;
  298. }
  299. static void ASN1CALL ASN1Free_SpcAttributeTypeAndOptionalValue(SpcAttributeTypeAndOptionalValue *val)
  300. {
  301. if (val) {
  302. if ((val)->o[0] & 0x80) {
  303. }
  304. }
  305. }
  306. static int ASN1CALL ASN1Enc_SpcString(ASN1encoding_t enc, ASN1uint32_t tag, SpcString *val)
  307. {
  308. switch ((val)->choice) {
  309. case 1:
  310. if (!ASN1DEREncChar16String(enc, 0x80000000, ((val)->u.unicode).length, ((val)->u.unicode).value))
  311. return 0;
  312. break;
  313. case 2:
  314. if (!ASN1DEREncCharString(enc, 0x80000001, ((val)->u.ascii).length, ((val)->u.ascii).value))
  315. return 0;
  316. break;
  317. }
  318. return 1;
  319. }
  320. static int ASN1CALL ASN1Dec_SpcString(ASN1decoding_t dec, ASN1uint32_t tag, SpcString *val)
  321. {
  322. ASN1uint32_t t;
  323. if (!ASN1BERDecPeekTag(dec, &t))
  324. return 0;
  325. switch (t) {
  326. case 0x80000000:
  327. (val)->choice = 1;
  328. if (!ASN1BERDecChar16String(dec, 0x80000000, &(val)->u.unicode))
  329. return 0;
  330. break;
  331. case 0x80000001:
  332. (val)->choice = 2;
  333. if (!ASN1BERDecCharString(dec, 0x80000001, &(val)->u.ascii))
  334. return 0;
  335. break;
  336. default:
  337. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  338. return 0;
  339. }
  340. return 1;
  341. }
  342. static void ASN1CALL ASN1Free_SpcString(SpcString *val)
  343. {
  344. if (val) {
  345. switch ((val)->choice) {
  346. case 1:
  347. ASN1char16string_free(&(val)->u.unicode);
  348. break;
  349. case 2:
  350. ASN1charstring_free(&(val)->u.ascii);
  351. break;
  352. }
  353. }
  354. }
  355. static int ASN1CALL ASN1Enc_SpcSerializedObject(ASN1encoding_t enc, ASN1uint32_t tag, SpcSerializedObject *val)
  356. {
  357. ASN1uint32_t nLenOff;
  358. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  359. return 0;
  360. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->classId).length, ((val)->classId).value))
  361. return 0;
  362. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->serializedData).length, ((val)->serializedData).value))
  363. return 0;
  364. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  365. return 0;
  366. return 1;
  367. }
  368. static int ASN1CALL ASN1Dec_SpcSerializedObject(ASN1decoding_t dec, ASN1uint32_t tag, SpcSerializedObject *val)
  369. {
  370. ASN1decoding_t dd;
  371. ASN1octet_t *di;
  372. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  373. return 0;
  374. if (!ASN1BERDecOctetString2(dd, 0x4, &(val)->classId))
  375. return 0;
  376. if (!ASN1BERDecOctetString2(dd, 0x4, &(val)->serializedData))
  377. return 0;
  378. if (!ASN1BERDecEndOfContents(dec, dd, di))
  379. return 0;
  380. return 1;
  381. }
  382. static void ASN1CALL ASN1Free_SpcSerializedObject(SpcSerializedObject *val)
  383. {
  384. if (val) {
  385. }
  386. }
  387. static int ASN1CALL ASN1Enc_SpcLink(ASN1encoding_t enc, ASN1uint32_t tag, SpcLink *val)
  388. {
  389. ASN1uint32_t nLenOff0;
  390. switch ((val)->choice) {
  391. case 1:
  392. if (!ASN1DEREncCharString(enc, 0x80000000, ((val)->u.url).length, ((val)->u.url).value))
  393. return 0;
  394. break;
  395. case 2:
  396. if (!ASN1Enc_SpcSerializedObject(enc, 0x80000001, &(val)->u.moniker))
  397. return 0;
  398. break;
  399. case 3:
  400. if (!ASN1BEREncExplicitTag(enc, 0x80000002, &nLenOff0))
  401. return 0;
  402. if (!ASN1Enc_SpcString(enc, 0, &(val)->u.file))
  403. return 0;
  404. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  405. return 0;
  406. break;
  407. }
  408. return 1;
  409. }
  410. static int ASN1CALL ASN1Dec_SpcLink(ASN1decoding_t dec, ASN1uint32_t tag, SpcLink *val)
  411. {
  412. ASN1uint32_t t;
  413. ASN1decoding_t dd0;
  414. ASN1octet_t *di0;
  415. if (!ASN1BERDecPeekTag(dec, &t))
  416. return 0;
  417. switch (t) {
  418. case 0x80000000:
  419. (val)->choice = 1;
  420. if (!ASN1BERDecCharString(dec, 0x80000000, &(val)->u.url))
  421. return 0;
  422. break;
  423. case 0x80000001:
  424. (val)->choice = 2;
  425. if (!ASN1Dec_SpcSerializedObject(dec, 0x80000001, &(val)->u.moniker))
  426. return 0;
  427. break;
  428. case 0x80000002:
  429. (val)->choice = 3;
  430. if (!ASN1BERDecExplicitTag(dec, 0x80000002, &dd0, &di0))
  431. return 0;
  432. if (!ASN1Dec_SpcString(dd0, 0, &(val)->u.file))
  433. return 0;
  434. if (!ASN1BERDecEndOfContents(dec, dd0, di0))
  435. return 0;
  436. break;
  437. default:
  438. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  439. return 0;
  440. }
  441. return 1;
  442. }
  443. static void ASN1CALL ASN1Free_SpcLink(SpcLink *val)
  444. {
  445. if (val) {
  446. switch ((val)->choice) {
  447. case 1:
  448. ASN1charstring_free(&(val)->u.url);
  449. break;
  450. case 2:
  451. ASN1Free_SpcSerializedObject(&(val)->u.moniker);
  452. break;
  453. case 3:
  454. ASN1Free_SpcString(&(val)->u.file);
  455. break;
  456. }
  457. }
  458. }
  459. static int ASN1CALL ASN1Enc_SpcPeImageData(ASN1encoding_t enc, ASN1uint32_t tag, SpcPeImageData *val)
  460. {
  461. ASN1uint32_t nLenOff;
  462. ASN1octet_t o[1];
  463. ASN1uint32_t r;
  464. ASN1uint32_t nLenOff0;
  465. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  466. return 0;
  467. CopyMemory(o, (val)->o, 1);
  468. if (!ASN1bitstring_cmp(&val->flags, &SpcPeImageData_flags_default, 1))
  469. o[0] &= ~0x80;
  470. if (o[0] & 0x80) {
  471. r = ((val)->flags).length;
  472. ASN1BEREncRemoveZeroBits(&r, ((val)->flags).value);
  473. if (!ASN1DEREncBitString(enc, 0x3, r, ((val)->flags).value))
  474. return 0;
  475. }
  476. if (o[0] & 0x40) {
  477. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  478. return 0;
  479. if (!ASN1Enc_SpcLink(enc, 0, &(val)->file))
  480. return 0;
  481. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  482. return 0;
  483. }
  484. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  485. return 0;
  486. return 1;
  487. }
  488. static int ASN1CALL ASN1Dec_SpcPeImageData(ASN1decoding_t dec, ASN1uint32_t tag, SpcPeImageData *val)
  489. {
  490. ASN1decoding_t dd;
  491. ASN1octet_t *di;
  492. ASN1uint32_t t;
  493. ASN1decoding_t dd0;
  494. ASN1octet_t *di0;
  495. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  496. return 0;
  497. ZeroMemory((val)->o, 1);
  498. ASN1BERDecPeekTag(dd, &t);
  499. if (t == 0x3) {
  500. (val)->o[0] |= 0x80;
  501. if (!ASN1BERDecBitString(dd, 0x3, &(val)->flags))
  502. return 0;
  503. }
  504. ASN1BERDecPeekTag(dd, &t);
  505. if (t == 0x80000000) {
  506. (val)->o[0] |= 0x40;
  507. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  508. return 0;
  509. if (!ASN1Dec_SpcLink(dd0, 0, &(val)->file))
  510. return 0;
  511. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  512. return 0;
  513. }
  514. if (!ASN1BERDecEndOfContents(dec, dd, di))
  515. return 0;
  516. return 1;
  517. }
  518. static void ASN1CALL ASN1Free_SpcPeImageData(SpcPeImageData *val)
  519. {
  520. if (val) {
  521. if ((val)->o[0] & 0x80) {
  522. ASN1bitstring_free(&(val)->flags);
  523. }
  524. if ((val)->o[0] & 0x40) {
  525. ASN1Free_SpcLink(&(val)->file);
  526. }
  527. }
  528. }
  529. static int ASN1CALL ASN1Enc_SpcSigInfo(ASN1encoding_t enc, ASN1uint32_t tag, SpcSigInfo *val)
  530. {
  531. ASN1uint32_t nLenOff;
  532. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  533. return 0;
  534. if (!ASN1BEREncS32(enc, 0x2, (val)->dwSIPversion))
  535. return 0;
  536. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->gSIPguid).length, ((val)->gSIPguid).value))
  537. return 0;
  538. if (!ASN1BEREncS32(enc, 0x2, (val)->dwReserved1))
  539. return 0;
  540. if (!ASN1BEREncS32(enc, 0x2, (val)->dwReserved2))
  541. return 0;
  542. if (!ASN1BEREncS32(enc, 0x2, (val)->dwReserved3))
  543. return 0;
  544. if (!ASN1BEREncS32(enc, 0x2, (val)->dwReserved4))
  545. return 0;
  546. if (!ASN1BEREncS32(enc, 0x2, (val)->dwReserved5))
  547. return 0;
  548. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  549. return 0;
  550. return 1;
  551. }
  552. static int ASN1CALL ASN1Dec_SpcSigInfo(ASN1decoding_t dec, ASN1uint32_t tag, SpcSigInfo *val)
  553. {
  554. ASN1decoding_t dd;
  555. ASN1octet_t *di;
  556. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  557. return 0;
  558. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->dwSIPversion))
  559. return 0;
  560. if (!ASN1BERDecOctetString2(dd, 0x4, &(val)->gSIPguid))
  561. return 0;
  562. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->dwReserved1))
  563. return 0;
  564. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->dwReserved2))
  565. return 0;
  566. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->dwReserved3))
  567. return 0;
  568. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->dwReserved4))
  569. return 0;
  570. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->dwReserved5))
  571. return 0;
  572. if (!ASN1BERDecEndOfContents(dec, dd, di))
  573. return 0;
  574. return 1;
  575. }
  576. static void ASN1CALL ASN1Free_SpcSigInfo(SpcSigInfo *val)
  577. {
  578. if (val) {
  579. }
  580. }
  581. static int ASN1CALL ASN1Enc_SpcImage(ASN1encoding_t enc, ASN1uint32_t tag, SpcImage *val)
  582. {
  583. ASN1uint32_t nLenOff;
  584. ASN1uint32_t nLenOff0;
  585. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  586. return 0;
  587. if ((val)->o[0] & 0x80) {
  588. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  589. return 0;
  590. if (!ASN1Enc_SpcLink(enc, 0, &(val)->imageLink))
  591. return 0;
  592. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  593. return 0;
  594. }
  595. if ((val)->o[0] & 0x40) {
  596. if (!ASN1DEREncOctetString(enc, 0x80000001, ((val)->bitmap).length, ((val)->bitmap).value))
  597. return 0;
  598. }
  599. if ((val)->o[0] & 0x20) {
  600. if (!ASN1DEREncOctetString(enc, 0x80000002, ((val)->metafile).length, ((val)->metafile).value))
  601. return 0;
  602. }
  603. if ((val)->o[0] & 0x10) {
  604. if (!ASN1DEREncOctetString(enc, 0x80000003, ((val)->enhancedMetafile).length, ((val)->enhancedMetafile).value))
  605. return 0;
  606. }
  607. if ((val)->o[0] & 0x8) {
  608. if (!ASN1DEREncOctetString(enc, 0x80000004, ((val)->gifFile).length, ((val)->gifFile).value))
  609. return 0;
  610. }
  611. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  612. return 0;
  613. return 1;
  614. }
  615. static int ASN1CALL ASN1Dec_SpcImage(ASN1decoding_t dec, ASN1uint32_t tag, SpcImage *val)
  616. {
  617. ASN1decoding_t dd;
  618. ASN1octet_t *di;
  619. ASN1uint32_t t;
  620. ASN1decoding_t dd0;
  621. ASN1octet_t *di0;
  622. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  623. return 0;
  624. ZeroMemory((val)->o, 1);
  625. ASN1BERDecPeekTag(dd, &t);
  626. if (t == 0x80000000) {
  627. (val)->o[0] |= 0x80;
  628. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  629. return 0;
  630. if (!ASN1Dec_SpcLink(dd0, 0, &(val)->imageLink))
  631. return 0;
  632. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  633. return 0;
  634. }
  635. ASN1BERDecPeekTag(dd, &t);
  636. if (t == 0x80000001) {
  637. (val)->o[0] |= 0x40;
  638. if (!ASN1BERDecOctetString2(dd, 0x80000001, &(val)->bitmap))
  639. return 0;
  640. }
  641. ASN1BERDecPeekTag(dd, &t);
  642. if (t == 0x80000002) {
  643. (val)->o[0] |= 0x20;
  644. if (!ASN1BERDecOctetString2(dd, 0x80000002, &(val)->metafile))
  645. return 0;
  646. }
  647. ASN1BERDecPeekTag(dd, &t);
  648. if (t == 0x80000003) {
  649. (val)->o[0] |= 0x10;
  650. if (!ASN1BERDecOctetString2(dd, 0x80000003, &(val)->enhancedMetafile))
  651. return 0;
  652. }
  653. ASN1BERDecPeekTag(dd, &t);
  654. if (t == 0x80000004) {
  655. (val)->o[0] |= 0x8;
  656. if (!ASN1BERDecOctetString2(dd, 0x80000004, &(val)->gifFile))
  657. return 0;
  658. }
  659. if (!ASN1BERDecEndOfContents(dec, dd, di))
  660. return 0;
  661. return 1;
  662. }
  663. static void ASN1CALL ASN1Free_SpcImage(SpcImage *val)
  664. {
  665. if (val) {
  666. if ((val)->o[0] & 0x80) {
  667. ASN1Free_SpcLink(&(val)->imageLink);
  668. }
  669. if ((val)->o[0] & 0x40) {
  670. }
  671. if ((val)->o[0] & 0x20) {
  672. }
  673. if ((val)->o[0] & 0x10) {
  674. }
  675. if ((val)->o[0] & 0x8) {
  676. }
  677. }
  678. }
  679. static int ASN1CALL ASN1Enc_SpcFinancialCriteria(ASN1encoding_t enc, ASN1uint32_t tag, SpcFinancialCriteria *val)
  680. {
  681. ASN1uint32_t nLenOff;
  682. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  683. return 0;
  684. if (!ASN1BEREncBool(enc, 0x1, (val)->financialInfoAvailable))
  685. return 0;
  686. if (!ASN1BEREncBool(enc, 0x1, (val)->meetsCriteria))
  687. return 0;
  688. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  689. return 0;
  690. return 1;
  691. }
  692. static int ASN1CALL ASN1Dec_SpcFinancialCriteria(ASN1decoding_t dec, ASN1uint32_t tag, SpcFinancialCriteria *val)
  693. {
  694. ASN1decoding_t dd;
  695. ASN1octet_t *di;
  696. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  697. return 0;
  698. if (!ASN1BERDecBool(dd, 0x1, &(val)->financialInfoAvailable))
  699. return 0;
  700. if (!ASN1BERDecBool(dd, 0x1, &(val)->meetsCriteria))
  701. return 0;
  702. if (!ASN1BERDecEndOfContents(dec, dd, di))
  703. return 0;
  704. return 1;
  705. }
  706. static int ASN1CALL ASN1Enc_SpcStatementType(ASN1encoding_t enc, ASN1uint32_t tag, SpcStatementType *val)
  707. {
  708. ASN1uint32_t nLenOff;
  709. ASN1uint32_t i;
  710. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  711. return 0;
  712. for (i = 0; i < (val)->count; i++) {
  713. if (!ASN1BEREncObjectIdentifier2(enc, 0x6, &((val)->value)[i]))
  714. return 0;
  715. }
  716. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  717. return 0;
  718. return 1;
  719. }
  720. static int ASN1CALL ASN1Dec_SpcStatementType(ASN1decoding_t dec, ASN1uint32_t tag, SpcStatementType *val)
  721. {
  722. ASN1decoding_t dd;
  723. ASN1octet_t *di;
  724. ASN1uint32_t t;
  725. ASN1uint32_t n;
  726. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  727. return 0;
  728. (val)->count = n = 0;
  729. (val)->value = NULL;
  730. while (ASN1BERDecNotEndOfContents(dd, di)) {
  731. if (!ASN1BERDecPeekTag(dd, &t))
  732. return 0;
  733. if ((val)->count >= n) {
  734. n = n ? (n << 1) : 16;
  735. if (!((val)->value = (ObjectID *)ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  736. return 0;
  737. }
  738. if (!ASN1BERDecObjectIdentifier2(dd, 0x6, &((val)->value)[(val)->count]))
  739. return 0;
  740. ((val)->count)++;
  741. }
  742. if (!ASN1BERDecEndOfContents(dec, dd, di))
  743. return 0;
  744. return 1;
  745. }
  746. static void ASN1CALL ASN1Free_SpcStatementType(SpcStatementType *val)
  747. {
  748. ASN1uint32_t i;
  749. if (val) {
  750. for (i = 1; i < (val)->count; i++) {
  751. }
  752. ASN1Free((val)->value);
  753. }
  754. }
  755. static int ASN1CALL ASN1Enc_SpcSpOpusInfo(ASN1encoding_t enc, ASN1uint32_t tag, SpcSpOpusInfo *val)
  756. {
  757. ASN1uint32_t nLenOff;
  758. ASN1uint32_t nLenOff0;
  759. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  760. return 0;
  761. if ((val)->o[0] & 0x80) {
  762. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  763. return 0;
  764. if (!ASN1Enc_SpcString(enc, 0, &(val)->programName))
  765. return 0;
  766. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  767. return 0;
  768. }
  769. if ((val)->o[0] & 0x40) {
  770. if (!ASN1BEREncExplicitTag(enc, 0x80000001, &nLenOff0))
  771. return 0;
  772. if (!ASN1Enc_SpcLink(enc, 0, &(val)->moreInfo))
  773. return 0;
  774. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  775. return 0;
  776. }
  777. if ((val)->o[0] & 0x20) {
  778. if (!ASN1BEREncExplicitTag(enc, 0x80000002, &nLenOff0))
  779. return 0;
  780. if (!ASN1Enc_SpcLink(enc, 0, &(val)->publisherInfo))
  781. return 0;
  782. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  783. return 0;
  784. }
  785. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  786. return 0;
  787. return 1;
  788. }
  789. static int ASN1CALL ASN1Dec_SpcSpOpusInfo(ASN1decoding_t dec, ASN1uint32_t tag, SpcSpOpusInfo *val)
  790. {
  791. ASN1decoding_t dd;
  792. ASN1octet_t *di;
  793. ASN1uint32_t t;
  794. ASN1decoding_t dd0;
  795. ASN1octet_t *di0;
  796. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  797. return 0;
  798. ZeroMemory((val)->o, 1);
  799. ASN1BERDecPeekTag(dd, &t);
  800. if (t == 0x80000000) {
  801. (val)->o[0] |= 0x80;
  802. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  803. return 0;
  804. if (!ASN1Dec_SpcString(dd0, 0, &(val)->programName))
  805. return 0;
  806. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  807. return 0;
  808. }
  809. ASN1BERDecPeekTag(dd, &t);
  810. if (t == 0x80000001) {
  811. (val)->o[0] |= 0x40;
  812. if (!ASN1BERDecExplicitTag(dd, 0x80000001, &dd0, &di0))
  813. return 0;
  814. if (!ASN1Dec_SpcLink(dd0, 0, &(val)->moreInfo))
  815. return 0;
  816. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  817. return 0;
  818. }
  819. ASN1BERDecPeekTag(dd, &t);
  820. if (t == 0x80000002) {
  821. (val)->o[0] |= 0x20;
  822. if (!ASN1BERDecExplicitTag(dd, 0x80000002, &dd0, &di0))
  823. return 0;
  824. if (!ASN1Dec_SpcLink(dd0, 0, &(val)->publisherInfo))
  825. return 0;
  826. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  827. return 0;
  828. }
  829. if (!ASN1BERDecEndOfContents(dec, dd, di))
  830. return 0;
  831. return 1;
  832. }
  833. static void ASN1CALL ASN1Free_SpcSpOpusInfo(SpcSpOpusInfo *val)
  834. {
  835. if (val) {
  836. if ((val)->o[0] & 0x80) {
  837. ASN1Free_SpcString(&(val)->programName);
  838. }
  839. if ((val)->o[0] & 0x40) {
  840. ASN1Free_SpcLink(&(val)->moreInfo);
  841. }
  842. if ((val)->o[0] & 0x20) {
  843. ASN1Free_SpcLink(&(val)->publisherInfo);
  844. }
  845. }
  846. }
  847. static int ASN1CALL ASN1Enc_NameValue(ASN1encoding_t enc, ASN1uint32_t tag, NameValue *val)
  848. {
  849. ASN1uint32_t nLenOff;
  850. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  851. return 0;
  852. if (!ASN1DEREncChar16String(enc, 0x1e, ((val)->refname).length, ((val)->refname).value))
  853. return 0;
  854. if (!ASN1BEREncS32(enc, 0x2, (val)->typeaction))
  855. return 0;
  856. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->value).length, ((val)->value).value))
  857. return 0;
  858. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  859. return 0;
  860. return 1;
  861. }
  862. static int ASN1CALL ASN1Dec_NameValue(ASN1decoding_t dec, ASN1uint32_t tag, NameValue *val)
  863. {
  864. ASN1decoding_t dd;
  865. ASN1octet_t *di;
  866. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  867. return 0;
  868. if (!ASN1BERDecChar16String(dd, 0x1e, &(val)->refname))
  869. return 0;
  870. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->typeaction))
  871. return 0;
  872. if (!ASN1BERDecOctetString2(dd, 0x4, &(val)->value))
  873. return 0;
  874. if (!ASN1BERDecEndOfContents(dec, dd, di))
  875. return 0;
  876. return 1;
  877. }
  878. static void ASN1CALL ASN1Free_NameValue(NameValue *val)
  879. {
  880. if (val) {
  881. ASN1char16string_free(&(val)->refname);
  882. }
  883. }
  884. static int ASN1CALL ASN1Enc_NameValues(ASN1encoding_t enc, ASN1uint32_t tag, NameValues *val)
  885. {
  886. ASN1uint32_t nLenOff;
  887. void *pBlk;
  888. ASN1uint32_t i;
  889. ASN1encoding_t enc2;
  890. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x11, &nLenOff))
  891. return 0;
  892. if (!ASN1DEREncBeginBlk(enc, ASN1_DER_SET_OF_BLOCK, &pBlk))
  893. return 0;
  894. for (i = 0; i < (val)->count; i++) {
  895. if (!ASN1DEREncNewBlkElement(pBlk, &enc2))
  896. return 0;
  897. if (!ASN1Enc_NameValue(enc2, 0, &((val)->value)[i]))
  898. return 0;
  899. if (!ASN1DEREncFlushBlkElement(pBlk))
  900. return 0;
  901. }
  902. if (!ASN1DEREncEndBlk(pBlk))
  903. return 0;
  904. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  905. return 0;
  906. return 1;
  907. }
  908. static int ASN1CALL ASN1Dec_NameValues(ASN1decoding_t dec, ASN1uint32_t tag, NameValues *val)
  909. {
  910. ASN1decoding_t dd;
  911. ASN1octet_t *di;
  912. ASN1uint32_t t;
  913. ASN1uint32_t n;
  914. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x11, &dd, &di))
  915. return 0;
  916. (val)->count = n = 0;
  917. (val)->value = NULL;
  918. while (ASN1BERDecNotEndOfContents(dd, di)) {
  919. if (!ASN1BERDecPeekTag(dd, &t))
  920. return 0;
  921. if ((val)->count >= n) {
  922. n = n ? (n << 1) : 16;
  923. if (!((val)->value = (NameValue *)ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  924. return 0;
  925. }
  926. if (!ASN1Dec_NameValue(dd, 0, &((val)->value)[(val)->count]))
  927. return 0;
  928. ((val)->count)++;
  929. }
  930. if (!ASN1BERDecEndOfContents(dec, dd, di))
  931. return 0;
  932. return 1;
  933. }
  934. static void ASN1CALL ASN1Free_NameValues(NameValues *val)
  935. {
  936. ASN1uint32_t i;
  937. if (val) {
  938. ASN1Free_NameValue(&(val)->value[0]);
  939. for (i = 1; i < (val)->count; i++) {
  940. ASN1Free_NameValue(&(val)->value[i]);
  941. }
  942. ASN1Free((val)->value);
  943. }
  944. }
  945. static int ASN1CALL ASN1Enc_MemberInfo(ASN1encoding_t enc, ASN1uint32_t tag, MemberInfo *val)
  946. {
  947. ASN1uint32_t nLenOff;
  948. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  949. return 0;
  950. if (!ASN1DEREncChar16String(enc, 0x1e, ((val)->subguid).length, ((val)->subguid).value))
  951. return 0;
  952. if (!ASN1BEREncS32(enc, 0x2, (val)->certversion))
  953. return 0;
  954. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  955. return 0;
  956. return 1;
  957. }
  958. static int ASN1CALL ASN1Dec_MemberInfo(ASN1decoding_t dec, ASN1uint32_t tag, MemberInfo *val)
  959. {
  960. ASN1decoding_t dd;
  961. ASN1octet_t *di;
  962. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  963. return 0;
  964. if (!ASN1BERDecChar16String(dd, 0x1e, &(val)->subguid))
  965. return 0;
  966. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->certversion))
  967. return 0;
  968. if (!ASN1BERDecEndOfContents(dec, dd, di))
  969. return 0;
  970. return 1;
  971. }
  972. static void ASN1CALL ASN1Free_MemberInfo(MemberInfo *val)
  973. {
  974. if (val) {
  975. ASN1char16string_free(&(val)->subguid);
  976. }
  977. }
  978. static int ASN1CALL ASN1Enc_SpcIndirectDataContent(ASN1encoding_t enc, ASN1uint32_t tag, SpcIndirectDataContent *val)
  979. {
  980. ASN1uint32_t nLenOff;
  981. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  982. return 0;
  983. if (!ASN1Enc_SpcAttributeTypeAndOptionalValue(enc, 0, &(val)->data))
  984. return 0;
  985. if (!ASN1Enc_DigestInfo(enc, 0, &(val)->messageDigest))
  986. return 0;
  987. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  988. return 0;
  989. return 1;
  990. }
  991. static int ASN1CALL ASN1Dec_SpcIndirectDataContent(ASN1decoding_t dec, ASN1uint32_t tag, SpcIndirectDataContent *val)
  992. {
  993. ASN1decoding_t dd;
  994. ASN1octet_t *di;
  995. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  996. return 0;
  997. if (!ASN1Dec_SpcAttributeTypeAndOptionalValue(dd, 0, &(val)->data))
  998. return 0;
  999. if (!ASN1Dec_DigestInfo(dd, 0, &(val)->messageDigest))
  1000. return 0;
  1001. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1002. return 0;
  1003. return 1;
  1004. }
  1005. static void ASN1CALL ASN1Free_SpcIndirectDataContent(SpcIndirectDataContent *val)
  1006. {
  1007. if (val) {
  1008. ASN1Free_SpcAttributeTypeAndOptionalValue(&(val)->data);
  1009. ASN1Free_DigestInfo(&(val)->messageDigest);
  1010. }
  1011. }
  1012. static int ASN1CALL ASN1Enc_SpcSpAgencyInformation(ASN1encoding_t enc, ASN1uint32_t tag, SpcSpAgencyInformation *val)
  1013. {
  1014. ASN1uint32_t nLenOff;
  1015. ASN1uint32_t nLenOff0;
  1016. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1017. return 0;
  1018. if ((val)->o[0] & 0x80) {
  1019. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  1020. return 0;
  1021. if (!ASN1Enc_SpcLink(enc, 0, &(val)->policyInformation))
  1022. return 0;
  1023. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  1024. return 0;
  1025. }
  1026. if ((val)->o[0] & 0x40) {
  1027. if (!ASN1BEREncExplicitTag(enc, 0x80000001, &nLenOff0))
  1028. return 0;
  1029. if (!ASN1Enc_SpcString(enc, 0, &(val)->policyDisplayText))
  1030. return 0;
  1031. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  1032. return 0;
  1033. }
  1034. if ((val)->o[0] & 0x20) {
  1035. if (!ASN1Enc_SpcImage(enc, 0x80000002, &(val)->logoImage))
  1036. return 0;
  1037. }
  1038. if ((val)->o[0] & 0x10) {
  1039. if (!ASN1BEREncExplicitTag(enc, 0x80000003, &nLenOff0))
  1040. return 0;
  1041. if (!ASN1Enc_SpcLink(enc, 0, &(val)->logoLink))
  1042. return 0;
  1043. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  1044. return 0;
  1045. }
  1046. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1047. return 0;
  1048. return 1;
  1049. }
  1050. static int ASN1CALL ASN1Dec_SpcSpAgencyInformation(ASN1decoding_t dec, ASN1uint32_t tag, SpcSpAgencyInformation *val)
  1051. {
  1052. ASN1decoding_t dd;
  1053. ASN1octet_t *di;
  1054. ASN1uint32_t t;
  1055. ASN1decoding_t dd0;
  1056. ASN1octet_t *di0;
  1057. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1058. return 0;
  1059. ZeroMemory((val)->o, 1);
  1060. ASN1BERDecPeekTag(dd, &t);
  1061. if (t == 0x80000000) {
  1062. (val)->o[0] |= 0x80;
  1063. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  1064. return 0;
  1065. if (!ASN1Dec_SpcLink(dd0, 0, &(val)->policyInformation))
  1066. return 0;
  1067. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  1068. return 0;
  1069. }
  1070. ASN1BERDecPeekTag(dd, &t);
  1071. if (t == 0x80000001) {
  1072. (val)->o[0] |= 0x40;
  1073. if (!ASN1BERDecExplicitTag(dd, 0x80000001, &dd0, &di0))
  1074. return 0;
  1075. if (!ASN1Dec_SpcString(dd0, 0, &(val)->policyDisplayText))
  1076. return 0;
  1077. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  1078. return 0;
  1079. }
  1080. ASN1BERDecPeekTag(dd, &t);
  1081. if (t == 0x80000002) {
  1082. (val)->o[0] |= 0x20;
  1083. if (!ASN1Dec_SpcImage(dd, 0x80000002, &(val)->logoImage))
  1084. return 0;
  1085. }
  1086. ASN1BERDecPeekTag(dd, &t);
  1087. if (t == 0x80000003) {
  1088. (val)->o[0] |= 0x10;
  1089. if (!ASN1BERDecExplicitTag(dd, 0x80000003, &dd0, &di0))
  1090. return 0;
  1091. if (!ASN1Dec_SpcLink(dd0, 0, &(val)->logoLink))
  1092. return 0;
  1093. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  1094. return 0;
  1095. }
  1096. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1097. return 0;
  1098. return 1;
  1099. }
  1100. static void ASN1CALL ASN1Free_SpcSpAgencyInformation(SpcSpAgencyInformation *val)
  1101. {
  1102. if (val) {
  1103. if ((val)->o[0] & 0x80) {
  1104. ASN1Free_SpcLink(&(val)->policyInformation);
  1105. }
  1106. if ((val)->o[0] & 0x40) {
  1107. ASN1Free_SpcString(&(val)->policyDisplayText);
  1108. }
  1109. if ((val)->o[0] & 0x20) {
  1110. ASN1Free_SpcImage(&(val)->logoImage);
  1111. }
  1112. if ((val)->o[0] & 0x10) {
  1113. ASN1Free_SpcLink(&(val)->logoLink);
  1114. }
  1115. }
  1116. }