Leaked source code of windows server 2003
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.

1194 lines
37 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. default:
  318. /* impossible */
  319. ASN1EncSetError(enc, ASN1_ERR_CHOICE);
  320. return 0;
  321. }
  322. return 1;
  323. }
  324. static int ASN1CALL ASN1Dec_SpcString(ASN1decoding_t dec, ASN1uint32_t tag, SpcString *val)
  325. {
  326. ASN1uint32_t t;
  327. if (!ASN1BERDecPeekTag(dec, &t))
  328. return 0;
  329. switch (t) {
  330. case 0x80000000:
  331. (val)->choice = 1;
  332. if (!ASN1BERDecChar16String(dec, 0x80000000, &(val)->u.unicode))
  333. return 0;
  334. break;
  335. case 0x80000001:
  336. (val)->choice = 2;
  337. if (!ASN1BERDecCharString(dec, 0x80000001, &(val)->u.ascii))
  338. return 0;
  339. break;
  340. default:
  341. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  342. return 0;
  343. }
  344. return 1;
  345. }
  346. static void ASN1CALL ASN1Free_SpcString(SpcString *val)
  347. {
  348. if (val) {
  349. switch ((val)->choice) {
  350. case 1:
  351. ASN1char16string_free(&(val)->u.unicode);
  352. break;
  353. case 2:
  354. ASN1charstring_free(&(val)->u.ascii);
  355. break;
  356. }
  357. }
  358. }
  359. static int ASN1CALL ASN1Enc_SpcSerializedObject(ASN1encoding_t enc, ASN1uint32_t tag, SpcSerializedObject *val)
  360. {
  361. ASN1uint32_t nLenOff;
  362. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  363. return 0;
  364. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->classId).length, ((val)->classId).value))
  365. return 0;
  366. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->serializedData).length, ((val)->serializedData).value))
  367. return 0;
  368. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  369. return 0;
  370. return 1;
  371. }
  372. static int ASN1CALL ASN1Dec_SpcSerializedObject(ASN1decoding_t dec, ASN1uint32_t tag, SpcSerializedObject *val)
  373. {
  374. ASN1decoding_t dd;
  375. ASN1octet_t *di;
  376. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  377. return 0;
  378. if (!ASN1BERDecOctetString2(dd, 0x4, &(val)->classId))
  379. return 0;
  380. if (!ASN1BERDecOctetString2(dd, 0x4, &(val)->serializedData))
  381. return 0;
  382. if (!ASN1BERDecEndOfContents(dec, dd, di))
  383. return 0;
  384. return 1;
  385. }
  386. static void ASN1CALL ASN1Free_SpcSerializedObject(SpcSerializedObject *val)
  387. {
  388. if (val) {
  389. }
  390. }
  391. static int ASN1CALL ASN1Enc_SpcLink(ASN1encoding_t enc, ASN1uint32_t tag, SpcLink *val)
  392. {
  393. ASN1uint32_t nLenOff0;
  394. switch ((val)->choice) {
  395. case 1:
  396. if (!ASN1DEREncCharString(enc, 0x80000000, ((val)->u.url).length, ((val)->u.url).value))
  397. return 0;
  398. break;
  399. case 2:
  400. if (!ASN1Enc_SpcSerializedObject(enc, 0x80000001, &(val)->u.moniker))
  401. return 0;
  402. break;
  403. case 3:
  404. if (!ASN1BEREncExplicitTag(enc, 0x80000002, &nLenOff0))
  405. return 0;
  406. if (!ASN1Enc_SpcString(enc, 0, &(val)->u.file))
  407. return 0;
  408. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  409. return 0;
  410. break;
  411. default:
  412. /* impossible */
  413. ASN1EncSetError(enc, ASN1_ERR_CHOICE);
  414. return 0;
  415. }
  416. return 1;
  417. }
  418. static int ASN1CALL ASN1Dec_SpcLink(ASN1decoding_t dec, ASN1uint32_t tag, SpcLink *val)
  419. {
  420. ASN1uint32_t t;
  421. ASN1decoding_t dd0;
  422. ASN1octet_t *di0;
  423. if (!ASN1BERDecPeekTag(dec, &t))
  424. return 0;
  425. switch (t) {
  426. case 0x80000000:
  427. (val)->choice = 1;
  428. if (!ASN1BERDecCharString(dec, 0x80000000, &(val)->u.url))
  429. return 0;
  430. break;
  431. case 0x80000001:
  432. (val)->choice = 2;
  433. if (!ASN1Dec_SpcSerializedObject(dec, 0x80000001, &(val)->u.moniker))
  434. return 0;
  435. break;
  436. case 0x80000002:
  437. (val)->choice = 3;
  438. if (!ASN1BERDecExplicitTag(dec, 0x80000002, &dd0, &di0))
  439. return 0;
  440. if (!ASN1Dec_SpcString(dd0, 0, &(val)->u.file))
  441. return 0;
  442. if (!ASN1BERDecEndOfContents(dec, dd0, di0))
  443. return 0;
  444. break;
  445. default:
  446. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  447. return 0;
  448. }
  449. return 1;
  450. }
  451. static void ASN1CALL ASN1Free_SpcLink(SpcLink *val)
  452. {
  453. if (val) {
  454. switch ((val)->choice) {
  455. case 1:
  456. ASN1charstring_free(&(val)->u.url);
  457. break;
  458. case 2:
  459. ASN1Free_SpcSerializedObject(&(val)->u.moniker);
  460. break;
  461. case 3:
  462. ASN1Free_SpcString(&(val)->u.file);
  463. break;
  464. }
  465. }
  466. }
  467. static int ASN1CALL ASN1Enc_SpcPeImageData(ASN1encoding_t enc, ASN1uint32_t tag, SpcPeImageData *val)
  468. {
  469. ASN1uint32_t nLenOff;
  470. ASN1octet_t o[1];
  471. ASN1uint32_t r;
  472. ASN1uint32_t nLenOff0;
  473. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  474. return 0;
  475. CopyMemory(o, (val)->o, 1);
  476. if (!ASN1bitstring_cmp(&val->flags, &SpcPeImageData_flags_default, 1))
  477. o[0] &= ~0x80;
  478. if (o[0] & 0x80) {
  479. r = ((val)->flags).length;
  480. ASN1BEREncRemoveZeroBits(&r, ((val)->flags).value);
  481. if (!ASN1DEREncBitString(enc, 0x3, r, ((val)->flags).value))
  482. return 0;
  483. }
  484. if (o[0] & 0x40) {
  485. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  486. return 0;
  487. if (!ASN1Enc_SpcLink(enc, 0, &(val)->file))
  488. return 0;
  489. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  490. return 0;
  491. }
  492. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  493. return 0;
  494. return 1;
  495. }
  496. static int ASN1CALL ASN1Dec_SpcPeImageData(ASN1decoding_t dec, ASN1uint32_t tag, SpcPeImageData *val)
  497. {
  498. ASN1decoding_t dd;
  499. ASN1octet_t *di;
  500. ASN1uint32_t t;
  501. ASN1decoding_t dd0;
  502. ASN1octet_t *di0;
  503. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  504. return 0;
  505. ZeroMemory((val)->o, 1);
  506. ASN1BERDecPeekTag(dd, &t);
  507. if (t == 0x3) {
  508. (val)->o[0] |= 0x80;
  509. if (!ASN1BERDecBitString(dd, 0x3, &(val)->flags))
  510. return 0;
  511. }
  512. ASN1BERDecPeekTag(dd, &t);
  513. if (t == 0x80000000) {
  514. (val)->o[0] |= 0x40;
  515. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  516. return 0;
  517. if (!ASN1Dec_SpcLink(dd0, 0, &(val)->file))
  518. return 0;
  519. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  520. return 0;
  521. }
  522. if (!ASN1BERDecEndOfContents(dec, dd, di))
  523. return 0;
  524. return 1;
  525. }
  526. static void ASN1CALL ASN1Free_SpcPeImageData(SpcPeImageData *val)
  527. {
  528. if (val) {
  529. if ((val)->o[0] & 0x80) {
  530. ASN1bitstring_free(&(val)->flags);
  531. }
  532. if ((val)->o[0] & 0x40) {
  533. ASN1Free_SpcLink(&(val)->file);
  534. }
  535. }
  536. }
  537. static int ASN1CALL ASN1Enc_SpcSigInfo(ASN1encoding_t enc, ASN1uint32_t tag, SpcSigInfo *val)
  538. {
  539. ASN1uint32_t nLenOff;
  540. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  541. return 0;
  542. if (!ASN1BEREncS32(enc, 0x2, (val)->dwSIPversion))
  543. return 0;
  544. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->gSIPguid).length, ((val)->gSIPguid).value))
  545. return 0;
  546. if (!ASN1BEREncS32(enc, 0x2, (val)->dwReserved1))
  547. return 0;
  548. if (!ASN1BEREncS32(enc, 0x2, (val)->dwReserved2))
  549. return 0;
  550. if (!ASN1BEREncS32(enc, 0x2, (val)->dwReserved3))
  551. return 0;
  552. if (!ASN1BEREncS32(enc, 0x2, (val)->dwReserved4))
  553. return 0;
  554. if (!ASN1BEREncS32(enc, 0x2, (val)->dwReserved5))
  555. return 0;
  556. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  557. return 0;
  558. return 1;
  559. }
  560. static int ASN1CALL ASN1Dec_SpcSigInfo(ASN1decoding_t dec, ASN1uint32_t tag, SpcSigInfo *val)
  561. {
  562. ASN1decoding_t dd;
  563. ASN1octet_t *di;
  564. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  565. return 0;
  566. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->dwSIPversion))
  567. return 0;
  568. if (!ASN1BERDecOctetString2(dd, 0x4, &(val)->gSIPguid))
  569. return 0;
  570. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->dwReserved1))
  571. return 0;
  572. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->dwReserved2))
  573. return 0;
  574. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->dwReserved3))
  575. return 0;
  576. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->dwReserved4))
  577. return 0;
  578. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->dwReserved5))
  579. return 0;
  580. if (!ASN1BERDecEndOfContents(dec, dd, di))
  581. return 0;
  582. return 1;
  583. }
  584. static void ASN1CALL ASN1Free_SpcSigInfo(SpcSigInfo *val)
  585. {
  586. if (val) {
  587. }
  588. }
  589. static int ASN1CALL ASN1Enc_SpcImage(ASN1encoding_t enc, ASN1uint32_t tag, SpcImage *val)
  590. {
  591. ASN1uint32_t nLenOff;
  592. ASN1uint32_t nLenOff0;
  593. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  594. return 0;
  595. if ((val)->o[0] & 0x80) {
  596. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  597. return 0;
  598. if (!ASN1Enc_SpcLink(enc, 0, &(val)->imageLink))
  599. return 0;
  600. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  601. return 0;
  602. }
  603. if ((val)->o[0] & 0x40) {
  604. if (!ASN1DEREncOctetString(enc, 0x80000001, ((val)->bitmap).length, ((val)->bitmap).value))
  605. return 0;
  606. }
  607. if ((val)->o[0] & 0x20) {
  608. if (!ASN1DEREncOctetString(enc, 0x80000002, ((val)->metafile).length, ((val)->metafile).value))
  609. return 0;
  610. }
  611. if ((val)->o[0] & 0x10) {
  612. if (!ASN1DEREncOctetString(enc, 0x80000003, ((val)->enhancedMetafile).length, ((val)->enhancedMetafile).value))
  613. return 0;
  614. }
  615. if ((val)->o[0] & 0x8) {
  616. if (!ASN1DEREncOctetString(enc, 0x80000004, ((val)->gifFile).length, ((val)->gifFile).value))
  617. return 0;
  618. }
  619. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  620. return 0;
  621. return 1;
  622. }
  623. static int ASN1CALL ASN1Dec_SpcImage(ASN1decoding_t dec, ASN1uint32_t tag, SpcImage *val)
  624. {
  625. ASN1decoding_t dd;
  626. ASN1octet_t *di;
  627. ASN1uint32_t t;
  628. ASN1decoding_t dd0;
  629. ASN1octet_t *di0;
  630. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  631. return 0;
  632. ZeroMemory((val)->o, 1);
  633. ASN1BERDecPeekTag(dd, &t);
  634. if (t == 0x80000000) {
  635. (val)->o[0] |= 0x80;
  636. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  637. return 0;
  638. if (!ASN1Dec_SpcLink(dd0, 0, &(val)->imageLink))
  639. return 0;
  640. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  641. return 0;
  642. }
  643. ASN1BERDecPeekTag(dd, &t);
  644. if (t == 0x80000001) {
  645. (val)->o[0] |= 0x40;
  646. if (!ASN1BERDecOctetString2(dd, 0x80000001, &(val)->bitmap))
  647. return 0;
  648. }
  649. ASN1BERDecPeekTag(dd, &t);
  650. if (t == 0x80000002) {
  651. (val)->o[0] |= 0x20;
  652. if (!ASN1BERDecOctetString2(dd, 0x80000002, &(val)->metafile))
  653. return 0;
  654. }
  655. ASN1BERDecPeekTag(dd, &t);
  656. if (t == 0x80000003) {
  657. (val)->o[0] |= 0x10;
  658. if (!ASN1BERDecOctetString2(dd, 0x80000003, &(val)->enhancedMetafile))
  659. return 0;
  660. }
  661. ASN1BERDecPeekTag(dd, &t);
  662. if (t == 0x80000004) {
  663. (val)->o[0] |= 0x8;
  664. if (!ASN1BERDecOctetString2(dd, 0x80000004, &(val)->gifFile))
  665. return 0;
  666. }
  667. if (!ASN1BERDecEndOfContents(dec, dd, di))
  668. return 0;
  669. return 1;
  670. }
  671. static void ASN1CALL ASN1Free_SpcImage(SpcImage *val)
  672. {
  673. if (val) {
  674. if ((val)->o[0] & 0x80) {
  675. ASN1Free_SpcLink(&(val)->imageLink);
  676. }
  677. if ((val)->o[0] & 0x40) {
  678. }
  679. if ((val)->o[0] & 0x20) {
  680. }
  681. if ((val)->o[0] & 0x10) {
  682. }
  683. if ((val)->o[0] & 0x8) {
  684. }
  685. }
  686. }
  687. static int ASN1CALL ASN1Enc_SpcFinancialCriteria(ASN1encoding_t enc, ASN1uint32_t tag, SpcFinancialCriteria *val)
  688. {
  689. ASN1uint32_t nLenOff;
  690. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  691. return 0;
  692. if (!ASN1BEREncBool(enc, 0x1, (val)->financialInfoAvailable))
  693. return 0;
  694. if (!ASN1BEREncBool(enc, 0x1, (val)->meetsCriteria))
  695. return 0;
  696. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  697. return 0;
  698. return 1;
  699. }
  700. static int ASN1CALL ASN1Dec_SpcFinancialCriteria(ASN1decoding_t dec, ASN1uint32_t tag, SpcFinancialCriteria *val)
  701. {
  702. ASN1decoding_t dd;
  703. ASN1octet_t *di;
  704. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  705. return 0;
  706. if (!ASN1BERDecBool(dd, 0x1, &(val)->financialInfoAvailable))
  707. return 0;
  708. if (!ASN1BERDecBool(dd, 0x1, &(val)->meetsCriteria))
  709. return 0;
  710. if (!ASN1BERDecEndOfContents(dec, dd, di))
  711. return 0;
  712. return 1;
  713. }
  714. static int ASN1CALL ASN1Enc_SpcStatementType(ASN1encoding_t enc, ASN1uint32_t tag, SpcStatementType *val)
  715. {
  716. ASN1uint32_t nLenOff;
  717. ASN1uint32_t i;
  718. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  719. return 0;
  720. for (i = 0; i < (val)->count; i++) {
  721. if (!ASN1BEREncObjectIdentifier2(enc, 0x6, &((val)->value)[i]))
  722. return 0;
  723. }
  724. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  725. return 0;
  726. return 1;
  727. }
  728. static int ASN1CALL ASN1Dec_SpcStatementType(ASN1decoding_t dec, ASN1uint32_t tag, SpcStatementType *val)
  729. {
  730. ASN1decoding_t dd;
  731. ASN1octet_t *di;
  732. ASN1uint32_t t;
  733. ASN1uint32_t n;
  734. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  735. return 0;
  736. (val)->count = n = 0;
  737. (val)->value = NULL;
  738. while (ASN1BERDecNotEndOfContents(dd, di)) {
  739. if (!ASN1BERDecPeekTag(dd, &t))
  740. return 0;
  741. if ((val)->count >= n) {
  742. void *pvASN1DecRealloc;
  743. n = n ? (n << 1) : 16;
  744. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  745. return 0;
  746. (val)->value = (ObjectID *) pvASN1DecRealloc;
  747. }
  748. if (!ASN1BERDecObjectIdentifier2(dd, 0x6, &((val)->value)[(val)->count]))
  749. return 0;
  750. ((val)->count)++;
  751. }
  752. if (!ASN1BERDecEndOfContents(dec, dd, di))
  753. return 0;
  754. return 1;
  755. }
  756. static void ASN1CALL ASN1Free_SpcStatementType(SpcStatementType *val)
  757. {
  758. ASN1uint32_t i;
  759. if (val) {
  760. for (i = 1; i < (val)->count; i++) {
  761. }
  762. ASN1Free((val)->value);
  763. }
  764. }
  765. static int ASN1CALL ASN1Enc_SpcSpOpusInfo(ASN1encoding_t enc, ASN1uint32_t tag, SpcSpOpusInfo *val)
  766. {
  767. ASN1uint32_t nLenOff;
  768. ASN1uint32_t nLenOff0;
  769. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  770. return 0;
  771. if ((val)->o[0] & 0x80) {
  772. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  773. return 0;
  774. if (!ASN1Enc_SpcString(enc, 0, &(val)->programName))
  775. return 0;
  776. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  777. return 0;
  778. }
  779. if ((val)->o[0] & 0x40) {
  780. if (!ASN1BEREncExplicitTag(enc, 0x80000001, &nLenOff0))
  781. return 0;
  782. if (!ASN1Enc_SpcLink(enc, 0, &(val)->moreInfo))
  783. return 0;
  784. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  785. return 0;
  786. }
  787. if ((val)->o[0] & 0x20) {
  788. if (!ASN1BEREncExplicitTag(enc, 0x80000002, &nLenOff0))
  789. return 0;
  790. if (!ASN1Enc_SpcLink(enc, 0, &(val)->publisherInfo))
  791. return 0;
  792. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  793. return 0;
  794. }
  795. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  796. return 0;
  797. return 1;
  798. }
  799. static int ASN1CALL ASN1Dec_SpcSpOpusInfo(ASN1decoding_t dec, ASN1uint32_t tag, SpcSpOpusInfo *val)
  800. {
  801. ASN1decoding_t dd;
  802. ASN1octet_t *di;
  803. ASN1uint32_t t;
  804. ASN1decoding_t dd0;
  805. ASN1octet_t *di0;
  806. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  807. return 0;
  808. ZeroMemory((val)->o, 1);
  809. ASN1BERDecPeekTag(dd, &t);
  810. if (t == 0x80000000) {
  811. (val)->o[0] |= 0x80;
  812. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  813. return 0;
  814. if (!ASN1Dec_SpcString(dd0, 0, &(val)->programName))
  815. return 0;
  816. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  817. return 0;
  818. }
  819. ASN1BERDecPeekTag(dd, &t);
  820. if (t == 0x80000001) {
  821. (val)->o[0] |= 0x40;
  822. if (!ASN1BERDecExplicitTag(dd, 0x80000001, &dd0, &di0))
  823. return 0;
  824. if (!ASN1Dec_SpcLink(dd0, 0, &(val)->moreInfo))
  825. return 0;
  826. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  827. return 0;
  828. }
  829. ASN1BERDecPeekTag(dd, &t);
  830. if (t == 0x80000002) {
  831. (val)->o[0] |= 0x20;
  832. if (!ASN1BERDecExplicitTag(dd, 0x80000002, &dd0, &di0))
  833. return 0;
  834. if (!ASN1Dec_SpcLink(dd0, 0, &(val)->publisherInfo))
  835. return 0;
  836. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  837. return 0;
  838. }
  839. if (!ASN1BERDecEndOfContents(dec, dd, di))
  840. return 0;
  841. return 1;
  842. }
  843. static void ASN1CALL ASN1Free_SpcSpOpusInfo(SpcSpOpusInfo *val)
  844. {
  845. if (val) {
  846. if ((val)->o[0] & 0x80) {
  847. ASN1Free_SpcString(&(val)->programName);
  848. }
  849. if ((val)->o[0] & 0x40) {
  850. ASN1Free_SpcLink(&(val)->moreInfo);
  851. }
  852. if ((val)->o[0] & 0x20) {
  853. ASN1Free_SpcLink(&(val)->publisherInfo);
  854. }
  855. }
  856. }
  857. static int ASN1CALL ASN1Enc_NameValue(ASN1encoding_t enc, ASN1uint32_t tag, NameValue *val)
  858. {
  859. ASN1uint32_t nLenOff;
  860. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  861. return 0;
  862. if (!ASN1DEREncChar16String(enc, 0x1e, ((val)->refname).length, ((val)->refname).value))
  863. return 0;
  864. if (!ASN1BEREncS32(enc, 0x2, (val)->typeaction))
  865. return 0;
  866. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->value).length, ((val)->value).value))
  867. return 0;
  868. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  869. return 0;
  870. return 1;
  871. }
  872. static int ASN1CALL ASN1Dec_NameValue(ASN1decoding_t dec, ASN1uint32_t tag, NameValue *val)
  873. {
  874. ASN1decoding_t dd;
  875. ASN1octet_t *di;
  876. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  877. return 0;
  878. if (!ASN1BERDecChar16String(dd, 0x1e, &(val)->refname))
  879. return 0;
  880. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->typeaction))
  881. return 0;
  882. if (!ASN1BERDecOctetString2(dd, 0x4, &(val)->value))
  883. return 0;
  884. if (!ASN1BERDecEndOfContents(dec, dd, di))
  885. return 0;
  886. return 1;
  887. }
  888. static void ASN1CALL ASN1Free_NameValue(NameValue *val)
  889. {
  890. if (val) {
  891. ASN1char16string_free(&(val)->refname);
  892. }
  893. }
  894. static int ASN1CALL ASN1Enc_NameValues(ASN1encoding_t enc, ASN1uint32_t tag, NameValues *val)
  895. {
  896. ASN1uint32_t nLenOff;
  897. void *pBlk;
  898. ASN1uint32_t i;
  899. ASN1encoding_t enc2;
  900. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x11, &nLenOff))
  901. return 0;
  902. if (!ASN1DEREncBeginBlk(enc, ASN1_DER_SET_OF_BLOCK, &pBlk))
  903. return 0;
  904. for (i = 0; i < (val)->count; i++) {
  905. if (!ASN1DEREncNewBlkElement(pBlk, &enc2))
  906. return 0;
  907. if (!ASN1Enc_NameValue(enc2, 0, &((val)->value)[i]))
  908. return 0;
  909. if (!ASN1DEREncFlushBlkElement(pBlk))
  910. return 0;
  911. }
  912. if (!ASN1DEREncEndBlk(pBlk))
  913. return 0;
  914. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  915. return 0;
  916. return 1;
  917. }
  918. static int ASN1CALL ASN1Dec_NameValues(ASN1decoding_t dec, ASN1uint32_t tag, NameValues *val)
  919. {
  920. ASN1decoding_t dd;
  921. ASN1octet_t *di;
  922. ASN1uint32_t t;
  923. ASN1uint32_t n;
  924. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x11, &dd, &di))
  925. return 0;
  926. (val)->count = n = 0;
  927. (val)->value = NULL;
  928. while (ASN1BERDecNotEndOfContents(dd, di)) {
  929. if (!ASN1BERDecPeekTag(dd, &t))
  930. return 0;
  931. if ((val)->count >= n) {
  932. void *pvASN1DecRealloc;
  933. n = n ? (n << 1) : 16;
  934. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  935. return 0;
  936. (val)->value = (NameValue *) pvASN1DecRealloc;
  937. }
  938. if (!ASN1Dec_NameValue(dd, 0, &((val)->value)[(val)->count]))
  939. return 0;
  940. ((val)->count)++;
  941. }
  942. if (!ASN1BERDecEndOfContents(dec, dd, di))
  943. return 0;
  944. return 1;
  945. }
  946. static void ASN1CALL ASN1Free_NameValues(NameValues *val)
  947. {
  948. ASN1uint32_t i;
  949. if (val) {
  950. ASN1Free_NameValue(&(val)->value[0]);
  951. for (i = 1; i < (val)->count; i++) {
  952. ASN1Free_NameValue(&(val)->value[i]);
  953. }
  954. ASN1Free((val)->value);
  955. }
  956. }
  957. static int ASN1CALL ASN1Enc_MemberInfo(ASN1encoding_t enc, ASN1uint32_t tag, MemberInfo *val)
  958. {
  959. ASN1uint32_t nLenOff;
  960. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  961. return 0;
  962. if (!ASN1DEREncChar16String(enc, 0x1e, ((val)->subguid).length, ((val)->subguid).value))
  963. return 0;
  964. if (!ASN1BEREncS32(enc, 0x2, (val)->certversion))
  965. return 0;
  966. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  967. return 0;
  968. return 1;
  969. }
  970. static int ASN1CALL ASN1Dec_MemberInfo(ASN1decoding_t dec, ASN1uint32_t tag, MemberInfo *val)
  971. {
  972. ASN1decoding_t dd;
  973. ASN1octet_t *di;
  974. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  975. return 0;
  976. if (!ASN1BERDecChar16String(dd, 0x1e, &(val)->subguid))
  977. return 0;
  978. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->certversion))
  979. return 0;
  980. if (!ASN1BERDecEndOfContents(dec, dd, di))
  981. return 0;
  982. return 1;
  983. }
  984. static void ASN1CALL ASN1Free_MemberInfo(MemberInfo *val)
  985. {
  986. if (val) {
  987. ASN1char16string_free(&(val)->subguid);
  988. }
  989. }
  990. static int ASN1CALL ASN1Enc_SpcIndirectDataContent(ASN1encoding_t enc, ASN1uint32_t tag, SpcIndirectDataContent *val)
  991. {
  992. ASN1uint32_t nLenOff;
  993. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  994. return 0;
  995. if (!ASN1Enc_SpcAttributeTypeAndOptionalValue(enc, 0, &(val)->data))
  996. return 0;
  997. if (!ASN1Enc_DigestInfo(enc, 0, &(val)->messageDigest))
  998. return 0;
  999. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1000. return 0;
  1001. return 1;
  1002. }
  1003. static int ASN1CALL ASN1Dec_SpcIndirectDataContent(ASN1decoding_t dec, ASN1uint32_t tag, SpcIndirectDataContent *val)
  1004. {
  1005. ASN1decoding_t dd;
  1006. ASN1octet_t *di;
  1007. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1008. return 0;
  1009. if (!ASN1Dec_SpcAttributeTypeAndOptionalValue(dd, 0, &(val)->data))
  1010. return 0;
  1011. if (!ASN1Dec_DigestInfo(dd, 0, &(val)->messageDigest))
  1012. return 0;
  1013. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1014. return 0;
  1015. return 1;
  1016. }
  1017. static void ASN1CALL ASN1Free_SpcIndirectDataContent(SpcIndirectDataContent *val)
  1018. {
  1019. if (val) {
  1020. ASN1Free_SpcAttributeTypeAndOptionalValue(&(val)->data);
  1021. ASN1Free_DigestInfo(&(val)->messageDigest);
  1022. }
  1023. }
  1024. static int ASN1CALL ASN1Enc_SpcSpAgencyInformation(ASN1encoding_t enc, ASN1uint32_t tag, SpcSpAgencyInformation *val)
  1025. {
  1026. ASN1uint32_t nLenOff;
  1027. ASN1uint32_t nLenOff0;
  1028. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1029. return 0;
  1030. if ((val)->o[0] & 0x80) {
  1031. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  1032. return 0;
  1033. if (!ASN1Enc_SpcLink(enc, 0, &(val)->policyInformation))
  1034. return 0;
  1035. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  1036. return 0;
  1037. }
  1038. if ((val)->o[0] & 0x40) {
  1039. if (!ASN1BEREncExplicitTag(enc, 0x80000001, &nLenOff0))
  1040. return 0;
  1041. if (!ASN1Enc_SpcString(enc, 0, &(val)->policyDisplayText))
  1042. return 0;
  1043. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  1044. return 0;
  1045. }
  1046. if ((val)->o[0] & 0x20) {
  1047. if (!ASN1Enc_SpcImage(enc, 0x80000002, &(val)->logoImage))
  1048. return 0;
  1049. }
  1050. if ((val)->o[0] & 0x10) {
  1051. if (!ASN1BEREncExplicitTag(enc, 0x80000003, &nLenOff0))
  1052. return 0;
  1053. if (!ASN1Enc_SpcLink(enc, 0, &(val)->logoLink))
  1054. return 0;
  1055. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  1056. return 0;
  1057. }
  1058. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1059. return 0;
  1060. return 1;
  1061. }
  1062. static int ASN1CALL ASN1Dec_SpcSpAgencyInformation(ASN1decoding_t dec, ASN1uint32_t tag, SpcSpAgencyInformation *val)
  1063. {
  1064. ASN1decoding_t dd;
  1065. ASN1octet_t *di;
  1066. ASN1uint32_t t;
  1067. ASN1decoding_t dd0;
  1068. ASN1octet_t *di0;
  1069. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1070. return 0;
  1071. ZeroMemory((val)->o, 1);
  1072. ASN1BERDecPeekTag(dd, &t);
  1073. if (t == 0x80000000) {
  1074. (val)->o[0] |= 0x80;
  1075. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  1076. return 0;
  1077. if (!ASN1Dec_SpcLink(dd0, 0, &(val)->policyInformation))
  1078. return 0;
  1079. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  1080. return 0;
  1081. }
  1082. ASN1BERDecPeekTag(dd, &t);
  1083. if (t == 0x80000001) {
  1084. (val)->o[0] |= 0x40;
  1085. if (!ASN1BERDecExplicitTag(dd, 0x80000001, &dd0, &di0))
  1086. return 0;
  1087. if (!ASN1Dec_SpcString(dd0, 0, &(val)->policyDisplayText))
  1088. return 0;
  1089. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  1090. return 0;
  1091. }
  1092. ASN1BERDecPeekTag(dd, &t);
  1093. if (t == 0x80000002) {
  1094. (val)->o[0] |= 0x20;
  1095. if (!ASN1Dec_SpcImage(dd, 0x80000002, &(val)->logoImage))
  1096. return 0;
  1097. }
  1098. ASN1BERDecPeekTag(dd, &t);
  1099. if (t == 0x80000003) {
  1100. (val)->o[0] |= 0x10;
  1101. if (!ASN1BERDecExplicitTag(dd, 0x80000003, &dd0, &di0))
  1102. return 0;
  1103. if (!ASN1Dec_SpcLink(dd0, 0, &(val)->logoLink))
  1104. return 0;
  1105. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  1106. return 0;
  1107. }
  1108. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1109. return 0;
  1110. return 1;
  1111. }
  1112. static void ASN1CALL ASN1Free_SpcSpAgencyInformation(SpcSpAgencyInformation *val)
  1113. {
  1114. if (val) {
  1115. if ((val)->o[0] & 0x80) {
  1116. ASN1Free_SpcLink(&(val)->policyInformation);
  1117. }
  1118. if ((val)->o[0] & 0x40) {
  1119. ASN1Free_SpcString(&(val)->policyDisplayText);
  1120. }
  1121. if ((val)->o[0] & 0x20) {
  1122. ASN1Free_SpcImage(&(val)->logoImage);
  1123. }
  1124. if ((val)->o[0] & 0x10) {
  1125. ASN1Free_SpcLink(&(val)->logoLink);
  1126. }
  1127. }
  1128. }