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.

1834 lines
63 KiB

  1. #include <windows.h>
  2. #include <windows.h>
  3. #include "badstrfunctions.h"
  4. #include "msber.h"
  5. #include "crypttls.h"
  6. #include "demand2.h"
  7. #include "ess.h"
  8. #include "msber.inl"
  9. ASN1module_t ESS_Module = NULL;
  10. static int ASN1CALL ASN1Enc_SigningCertificate_policies(ASN1encoding_t enc, ASN1uint32_t tag, SigningCertificate_policies *val);
  11. static int ASN1CALL ASN1Enc_SigningCertificate_certs(ASN1encoding_t enc, ASN1uint32_t tag, SigningCertificate_certs *val);
  12. static int ASN1CALL ASN1Enc_MLReceiptPolicy_inAdditionTo(ASN1encoding_t enc, ASN1uint32_t tag, MLReceiptPolicy_inAdditionTo *val);
  13. static int ASN1CALL ASN1Enc_MLReceiptPolicy_insteadOf(ASN1encoding_t enc, ASN1uint32_t tag, MLReceiptPolicy_insteadOf *val);
  14. static int ASN1CALL ASN1Enc_ReceiptsFrom_receiptList(ASN1encoding_t enc, ASN1uint32_t tag, ReceiptsFrom_receiptList *val);
  15. static int ASN1CALL ASN1Enc_ReceiptRequest_receiptsTo(ASN1encoding_t enc, ASN1uint32_t tag, ReceiptRequest_receiptsTo *val);
  16. static int ASN1CALL ASN1Enc_IssuerAndSerialNumber(ASN1encoding_t enc, ASN1uint32_t tag, IssuerAndSerialNumber *val);
  17. static int ASN1CALL ASN1Enc_ReceiptsFrom(ASN1encoding_t enc, ASN1uint32_t tag, ReceiptsFrom *val);
  18. static int ASN1CALL ASN1Enc_Receipt(ASN1encoding_t enc, ASN1uint32_t tag, Receipt *val);
  19. static int ASN1CALL ASN1Enc_ContentHints(ASN1encoding_t enc, ASN1uint32_t tag, ContentHints *val);
  20. static int ASN1CALL ASN1Enc_ContentReference(ASN1encoding_t enc, ASN1uint32_t tag, ContentReference *val);
  21. static int ASN1CALL ASN1Enc_ESSPrivacyMark(ASN1encoding_t enc, ASN1uint32_t tag, ESSPrivacyMark *val);
  22. static int ASN1CALL ASN1Enc_SecurityCategories(ASN1encoding_t enc, ASN1uint32_t tag, SecurityCategories *val);
  23. static int ASN1CALL ASN1Enc_SecurityCategory(ASN1encoding_t enc, ASN1uint32_t tag, SecurityCategory *val);
  24. static int ASN1CALL ASN1Enc_EquivalentLabels(ASN1encoding_t enc, ASN1uint32_t tag, EquivalentLabels *val);
  25. static int ASN1CALL ASN1Enc_MLExpansionHistory(ASN1encoding_t enc, ASN1uint32_t tag, MLExpansionHistory *val);
  26. static int ASN1CALL ASN1Enc_EntityIdentifier(ASN1encoding_t enc, ASN1uint32_t tag, EntityIdentifier *val);
  27. static int ASN1CALL ASN1Enc_MLReceiptPolicy(ASN1encoding_t enc, ASN1uint32_t tag, MLReceiptPolicy *val);
  28. static int ASN1CALL ASN1Enc_SigningCertificate(ASN1encoding_t enc, ASN1uint32_t tag, SigningCertificate *val);
  29. static int ASN1CALL ASN1Enc_ReceiptRequest(ASN1encoding_t enc, ASN1uint32_t tag, ReceiptRequest *val);
  30. static int ASN1CALL ASN1Enc_ESSSecurityLabel(ASN1encoding_t enc, ASN1uint32_t tag, ESSSecurityLabel *val);
  31. static int ASN1CALL ASN1Enc_MLData(ASN1encoding_t enc, ASN1uint32_t tag, MLData *val);
  32. static int ASN1CALL ASN1Enc_ESSCertID(ASN1encoding_t enc, ASN1uint32_t tag, ESSCertID *val);
  33. static int ASN1CALL ASN1Enc_SMimeEncryptCerts(ASN1encoding_t enc, ASN1uint32_t tag, SMimeEncryptCerts *val);
  34. static int ASN1CALL ASN1Enc_SMIMECapabilities(ASN1encoding_t enc, ASN1uint32_t tag, SMIMECapabilities *val);
  35. static int ASN1CALL ASN1Enc_SMIMECapability(ASN1encoding_t enc, ASN1uint32_t tag, SMIMECapability *val);
  36. static int ASN1CALL ASN1Enc_OtherKeyAttribute(ASN1encoding_t enc, ASN1uint32_t tag, OtherKeyAttribute *val);
  37. static int ASN1CALL ASN1Enc_SMimeEncryptCert(ASN1encoding_t enc, ASN1uint32_t tag, SMimeEncryptCert *val);
  38. static int ASN1CALL ASN1Enc_RecipientKeyIdentifier(ASN1encoding_t enc, ASN1uint32_t tag, RecipientKeyIdentifier *val);
  39. static int ASN1CALL ASN1Enc_SMIMEEncryptionKeyPreference(ASN1encoding_t enc, ASN1uint32_t tag, SMIMEEncryptionKeyPreference *val);
  40. static int ASN1CALL ASN1Dec_SigningCertificate_policies(ASN1decoding_t dec, ASN1uint32_t tag, SigningCertificate_policies *val);
  41. static int ASN1CALL ASN1Dec_SigningCertificate_certs(ASN1decoding_t dec, ASN1uint32_t tag, SigningCertificate_certs *val);
  42. static int ASN1CALL ASN1Dec_MLReceiptPolicy_inAdditionTo(ASN1decoding_t dec, ASN1uint32_t tag, MLReceiptPolicy_inAdditionTo *val);
  43. static int ASN1CALL ASN1Dec_MLReceiptPolicy_insteadOf(ASN1decoding_t dec, ASN1uint32_t tag, MLReceiptPolicy_insteadOf *val);
  44. static int ASN1CALL ASN1Dec_ReceiptsFrom_receiptList(ASN1decoding_t dec, ASN1uint32_t tag, ReceiptsFrom_receiptList *val);
  45. static int ASN1CALL ASN1Dec_ReceiptRequest_receiptsTo(ASN1decoding_t dec, ASN1uint32_t tag, ReceiptRequest_receiptsTo *val);
  46. static int ASN1CALL ASN1Dec_IssuerAndSerialNumber(ASN1decoding_t dec, ASN1uint32_t tag, IssuerAndSerialNumber *val);
  47. static int ASN1CALL ASN1Dec_ReceiptsFrom(ASN1decoding_t dec, ASN1uint32_t tag, ReceiptsFrom *val);
  48. static int ASN1CALL ASN1Dec_Receipt(ASN1decoding_t dec, ASN1uint32_t tag, Receipt *val);
  49. static int ASN1CALL ASN1Dec_ContentHints(ASN1decoding_t dec, ASN1uint32_t tag, ContentHints *val);
  50. static int ASN1CALL ASN1Dec_ContentReference(ASN1decoding_t dec, ASN1uint32_t tag, ContentReference *val);
  51. static int ASN1CALL ASN1Dec_ESSPrivacyMark(ASN1decoding_t dec, ASN1uint32_t tag, ESSPrivacyMark *val);
  52. static int ASN1CALL ASN1Dec_SecurityCategories(ASN1decoding_t dec, ASN1uint32_t tag, SecurityCategories *val);
  53. static int ASN1CALL ASN1Dec_SecurityCategory(ASN1decoding_t dec, ASN1uint32_t tag, SecurityCategory *val);
  54. static int ASN1CALL ASN1Dec_EquivalentLabels(ASN1decoding_t dec, ASN1uint32_t tag, EquivalentLabels *val);
  55. static int ASN1CALL ASN1Dec_MLExpansionHistory(ASN1decoding_t dec, ASN1uint32_t tag, MLExpansionHistory *val);
  56. static int ASN1CALL ASN1Dec_EntityIdentifier(ASN1decoding_t dec, ASN1uint32_t tag, EntityIdentifier *val);
  57. static int ASN1CALL ASN1Dec_MLReceiptPolicy(ASN1decoding_t dec, ASN1uint32_t tag, MLReceiptPolicy *val);
  58. static int ASN1CALL ASN1Dec_SigningCertificate(ASN1decoding_t dec, ASN1uint32_t tag, SigningCertificate *val);
  59. static int ASN1CALL ASN1Dec_ReceiptRequest(ASN1decoding_t dec, ASN1uint32_t tag, ReceiptRequest *val);
  60. static int ASN1CALL ASN1Dec_ESSSecurityLabel(ASN1decoding_t dec, ASN1uint32_t tag, ESSSecurityLabel *val);
  61. static int ASN1CALL ASN1Dec_MLData(ASN1decoding_t dec, ASN1uint32_t tag, MLData *val);
  62. static int ASN1CALL ASN1Dec_ESSCertID(ASN1decoding_t dec, ASN1uint32_t tag, ESSCertID *val);
  63. static int ASN1CALL ASN1Dec_SMimeEncryptCerts(ASN1decoding_t dec, ASN1uint32_t tag, SMimeEncryptCerts *val);
  64. static int ASN1CALL ASN1Dec_SMIMECapabilities(ASN1decoding_t dec, ASN1uint32_t tag, SMIMECapabilities *val);
  65. static int ASN1CALL ASN1Dec_SMIMECapability(ASN1decoding_t dec, ASN1uint32_t tag, SMIMECapability *val);
  66. static int ASN1CALL ASN1Dec_OtherKeyAttribute(ASN1decoding_t dec, ASN1uint32_t tag, OtherKeyAttribute *val);
  67. static int ASN1CALL ASN1Dec_SMimeEncryptCert(ASN1decoding_t dec, ASN1uint32_t tag, SMimeEncryptCert *val);
  68. static int ASN1CALL ASN1Dec_RecipientKeyIdentifier(ASN1decoding_t dec, ASN1uint32_t tag, RecipientKeyIdentifier *val);
  69. static int ASN1CALL ASN1Dec_SMIMEEncryptionKeyPreference(ASN1decoding_t dec, ASN1uint32_t tag, SMIMEEncryptionKeyPreference *val);
  70. static void ASN1CALL ASN1Free_SigningCertificate_policies(SigningCertificate_policies *val);
  71. static void ASN1CALL ASN1Free_SigningCertificate_certs(SigningCertificate_certs *val);
  72. static void ASN1CALL ASN1Free_MLReceiptPolicy_inAdditionTo(MLReceiptPolicy_inAdditionTo *val);
  73. static void ASN1CALL ASN1Free_MLReceiptPolicy_insteadOf(MLReceiptPolicy_insteadOf *val);
  74. static void ASN1CALL ASN1Free_ReceiptsFrom_receiptList(ReceiptsFrom_receiptList *val);
  75. static void ASN1CALL ASN1Free_ReceiptRequest_receiptsTo(ReceiptRequest_receiptsTo *val);
  76. static void ASN1CALL ASN1Free_IssuerAndSerialNumber(IssuerAndSerialNumber *val);
  77. static void ASN1CALL ASN1Free_ReceiptsFrom(ReceiptsFrom *val);
  78. static void ASN1CALL ASN1Free_Receipt(Receipt *val);
  79. static void ASN1CALL ASN1Free_ContentHints(ContentHints *val);
  80. static void ASN1CALL ASN1Free_ContentReference(ContentReference *val);
  81. static void ASN1CALL ASN1Free_ESSPrivacyMark(ESSPrivacyMark *val);
  82. static void ASN1CALL ASN1Free_SecurityCategories(SecurityCategories *val);
  83. static void ASN1CALL ASN1Free_SecurityCategory(SecurityCategory *val);
  84. static void ASN1CALL ASN1Free_EquivalentLabels(EquivalentLabels *val);
  85. static void ASN1CALL ASN1Free_MLExpansionHistory(MLExpansionHistory *val);
  86. static void ASN1CALL ASN1Free_EntityIdentifier(EntityIdentifier *val);
  87. static void ASN1CALL ASN1Free_MLReceiptPolicy(MLReceiptPolicy *val);
  88. static void ASN1CALL ASN1Free_SigningCertificate(SigningCertificate *val);
  89. static void ASN1CALL ASN1Free_ReceiptRequest(ReceiptRequest *val);
  90. static void ASN1CALL ASN1Free_ESSSecurityLabel(ESSSecurityLabel *val);
  91. static void ASN1CALL ASN1Free_MLData(MLData *val);
  92. static void ASN1CALL ASN1Free_ESSCertID(ESSCertID *val);
  93. static void ASN1CALL ASN1Free_SMimeEncryptCerts(SMimeEncryptCerts *val);
  94. static void ASN1CALL ASN1Free_SMIMECapabilities(SMIMECapabilities *val);
  95. static void ASN1CALL ASN1Free_SMIMECapability(SMIMECapability *val);
  96. static void ASN1CALL ASN1Free_OtherKeyAttribute(OtherKeyAttribute *val);
  97. static void ASN1CALL ASN1Free_SMimeEncryptCert(SMimeEncryptCert *val);
  98. static void ASN1CALL ASN1Free_RecipientKeyIdentifier(RecipientKeyIdentifier *val);
  99. static void ASN1CALL ASN1Free_SMIMEEncryptionKeyPreference(SMIMEEncryptionKeyPreference *val);
  100. typedef ASN1BerEncFun_t ASN1EncFun_t;
  101. static const ASN1EncFun_t encfntab[10] = {
  102. (ASN1EncFun_t) ASN1Enc_Receipt,
  103. (ASN1EncFun_t) ASN1Enc_ContentHints,
  104. (ASN1EncFun_t) ASN1Enc_ContentReference,
  105. (ASN1EncFun_t) ASN1Enc_EquivalentLabels,
  106. (ASN1EncFun_t) ASN1Enc_MLExpansionHistory,
  107. (ASN1EncFun_t) ASN1Enc_SigningCertificate,
  108. (ASN1EncFun_t) ASN1Enc_SMimeEncryptCerts,
  109. (ASN1EncFun_t) ASN1Enc_ReceiptRequest,
  110. (ASN1EncFun_t) ASN1Enc_SMIMEEncryptionKeyPreference,
  111. (ASN1EncFun_t) ASN1Enc_ESSSecurityLabel,
  112. };
  113. typedef ASN1BerDecFun_t ASN1DecFun_t;
  114. static const ASN1DecFun_t decfntab[10] = {
  115. (ASN1DecFun_t) ASN1Dec_Receipt,
  116. (ASN1DecFun_t) ASN1Dec_ContentHints,
  117. (ASN1DecFun_t) ASN1Dec_ContentReference,
  118. (ASN1DecFun_t) ASN1Dec_EquivalentLabels,
  119. (ASN1DecFun_t) ASN1Dec_MLExpansionHistory,
  120. (ASN1DecFun_t) ASN1Dec_SigningCertificate,
  121. (ASN1DecFun_t) ASN1Dec_SMimeEncryptCerts,
  122. (ASN1DecFun_t) ASN1Dec_ReceiptRequest,
  123. (ASN1DecFun_t) ASN1Dec_SMIMEEncryptionKeyPreference,
  124. (ASN1DecFun_t) ASN1Dec_ESSSecurityLabel,
  125. };
  126. static const ASN1FreeFun_t freefntab[10] = {
  127. (ASN1FreeFun_t) ASN1Free_Receipt,
  128. (ASN1FreeFun_t) ASN1Free_ContentHints,
  129. (ASN1FreeFun_t) ASN1Free_ContentReference,
  130. (ASN1FreeFun_t) ASN1Free_EquivalentLabels,
  131. (ASN1FreeFun_t) ASN1Free_MLExpansionHistory,
  132. (ASN1FreeFun_t) ASN1Free_SigningCertificate,
  133. (ASN1FreeFun_t) ASN1Free_SMimeEncryptCerts,
  134. (ASN1FreeFun_t) ASN1Free_ReceiptRequest,
  135. (ASN1FreeFun_t) ASN1Free_SMIMEEncryptionKeyPreference,
  136. (ASN1FreeFun_t) ASN1Free_ESSSecurityLabel,
  137. };
  138. static const ULONG sizetab[10] = {
  139. SIZE_ESS_Module_PDU_0,
  140. SIZE_ESS_Module_PDU_1,
  141. SIZE_ESS_Module_PDU_2,
  142. SIZE_ESS_Module_PDU_3,
  143. SIZE_ESS_Module_PDU_4,
  144. SIZE_ESS_Module_PDU_5,
  145. SIZE_ESS_Module_PDU_6,
  146. SIZE_ESS_Module_PDU_7,
  147. SIZE_ESS_Module_PDU_8,
  148. SIZE_ESS_Module_PDU_9,
  149. };
  150. /* forward declarations of values: */
  151. extern ASN1uint32_t id_aa_receiptRequest_elems[9];
  152. extern ASN1uint32_t id_aa_contentIdentifier_elems[9];
  153. extern ASN1uint32_t id_ct_receipt_elems[9];
  154. extern ASN1uint32_t id_aa_contentHint_elems[9];
  155. extern ASN1uint32_t id_aa_msgSigDigest_elems[9];
  156. extern ASN1uint32_t id_aa_contentReference_elems[9];
  157. extern ASN1uint32_t id_aa_securityLabel_elems[9];
  158. extern ASN1uint32_t id_aa_equivalentLabels_elems[9];
  159. extern ASN1uint32_t id_aa_mlExpandHistory_elems[9];
  160. extern ASN1uint32_t id_aa_signingCertificate_elems[9];
  161. /* definitions of value components: */
  162. static const struct ASN1objectidentifier_s id_aa_receiptRequest_list[9] = {
  163. { (ASN1objectidentifier_t) &(id_aa_receiptRequest_list[1]), 1 },
  164. { (ASN1objectidentifier_t) &(id_aa_receiptRequest_list[2]), 2 },
  165. { (ASN1objectidentifier_t) &(id_aa_receiptRequest_list[3]), 840 },
  166. { (ASN1objectidentifier_t) &(id_aa_receiptRequest_list[4]), 113549 },
  167. { (ASN1objectidentifier_t) &(id_aa_receiptRequest_list[5]), 1 },
  168. { (ASN1objectidentifier_t) &(id_aa_receiptRequest_list[6]), 9 },
  169. { (ASN1objectidentifier_t) &(id_aa_receiptRequest_list[7]), 16 },
  170. { (ASN1objectidentifier_t) &(id_aa_receiptRequest_list[8]), 2 },
  171. { NULL, 1 }
  172. };
  173. static const struct ASN1objectidentifier_s id_aa_contentIdentifier_list[9] = {
  174. { (ASN1objectidentifier_t) &(id_aa_contentIdentifier_list[1]), 1 },
  175. { (ASN1objectidentifier_t) &(id_aa_contentIdentifier_list[2]), 2 },
  176. { (ASN1objectidentifier_t) &(id_aa_contentIdentifier_list[3]), 840 },
  177. { (ASN1objectidentifier_t) &(id_aa_contentIdentifier_list[4]), 113549 },
  178. { (ASN1objectidentifier_t) &(id_aa_contentIdentifier_list[5]), 1 },
  179. { (ASN1objectidentifier_t) &(id_aa_contentIdentifier_list[6]), 9 },
  180. { (ASN1objectidentifier_t) &(id_aa_contentIdentifier_list[7]), 16 },
  181. { (ASN1objectidentifier_t) &(id_aa_contentIdentifier_list[8]), 2 },
  182. { NULL, 7 }
  183. };
  184. static const struct ASN1objectidentifier_s id_ct_receipt_list[9] = {
  185. { (ASN1objectidentifier_t) &(id_ct_receipt_list[1]), 1 },
  186. { (ASN1objectidentifier_t) &(id_ct_receipt_list[2]), 2 },
  187. { (ASN1objectidentifier_t) &(id_ct_receipt_list[3]), 840 },
  188. { (ASN1objectidentifier_t) &(id_ct_receipt_list[4]), 113549 },
  189. { (ASN1objectidentifier_t) &(id_ct_receipt_list[5]), 1 },
  190. { (ASN1objectidentifier_t) &(id_ct_receipt_list[6]), 9 },
  191. { (ASN1objectidentifier_t) &(id_ct_receipt_list[7]), 16 },
  192. { (ASN1objectidentifier_t) &(id_ct_receipt_list[8]), 1 },
  193. { NULL, 1 }
  194. };
  195. static const struct ASN1objectidentifier_s id_aa_contentHint_list[9] = {
  196. { (ASN1objectidentifier_t) &(id_aa_contentHint_list[1]), 1 },
  197. { (ASN1objectidentifier_t) &(id_aa_contentHint_list[2]), 2 },
  198. { (ASN1objectidentifier_t) &(id_aa_contentHint_list[3]), 840 },
  199. { (ASN1objectidentifier_t) &(id_aa_contentHint_list[4]), 113549 },
  200. { (ASN1objectidentifier_t) &(id_aa_contentHint_list[5]), 1 },
  201. { (ASN1objectidentifier_t) &(id_aa_contentHint_list[6]), 9 },
  202. { (ASN1objectidentifier_t) &(id_aa_contentHint_list[7]), 16 },
  203. { (ASN1objectidentifier_t) &(id_aa_contentHint_list[8]), 2 },
  204. { NULL, 4 }
  205. };
  206. static const struct ASN1objectidentifier_s id_aa_msgSigDigest_list[9] = {
  207. { (ASN1objectidentifier_t) &(id_aa_msgSigDigest_list[1]), 1 },
  208. { (ASN1objectidentifier_t) &(id_aa_msgSigDigest_list[2]), 2 },
  209. { (ASN1objectidentifier_t) &(id_aa_msgSigDigest_list[3]), 840 },
  210. { (ASN1objectidentifier_t) &(id_aa_msgSigDigest_list[4]), 113549 },
  211. { (ASN1objectidentifier_t) &(id_aa_msgSigDigest_list[5]), 1 },
  212. { (ASN1objectidentifier_t) &(id_aa_msgSigDigest_list[6]), 9 },
  213. { (ASN1objectidentifier_t) &(id_aa_msgSigDigest_list[7]), 16 },
  214. { (ASN1objectidentifier_t) &(id_aa_msgSigDigest_list[8]), 2 },
  215. { NULL, 5 }
  216. };
  217. static const struct ASN1objectidentifier_s id_aa_contentReference_list[9] = {
  218. { (ASN1objectidentifier_t) &(id_aa_contentReference_list[1]), 1 },
  219. { (ASN1objectidentifier_t) &(id_aa_contentReference_list[2]), 2 },
  220. { (ASN1objectidentifier_t) &(id_aa_contentReference_list[3]), 840 },
  221. { (ASN1objectidentifier_t) &(id_aa_contentReference_list[4]), 113549 },
  222. { (ASN1objectidentifier_t) &(id_aa_contentReference_list[5]), 1 },
  223. { (ASN1objectidentifier_t) &(id_aa_contentReference_list[6]), 9 },
  224. { (ASN1objectidentifier_t) &(id_aa_contentReference_list[7]), 16 },
  225. { (ASN1objectidentifier_t) &(id_aa_contentReference_list[8]), 2 },
  226. { NULL, 10 }
  227. };
  228. static const struct ASN1objectidentifier_s id_aa_securityLabel_list[9] = {
  229. { (ASN1objectidentifier_t) &(id_aa_securityLabel_list[1]), 1 },
  230. { (ASN1objectidentifier_t) &(id_aa_securityLabel_list[2]), 2 },
  231. { (ASN1objectidentifier_t) &(id_aa_securityLabel_list[3]), 840 },
  232. { (ASN1objectidentifier_t) &(id_aa_securityLabel_list[4]), 113549 },
  233. { (ASN1objectidentifier_t) &(id_aa_securityLabel_list[5]), 1 },
  234. { (ASN1objectidentifier_t) &(id_aa_securityLabel_list[6]), 9 },
  235. { (ASN1objectidentifier_t) &(id_aa_securityLabel_list[7]), 16 },
  236. { (ASN1objectidentifier_t) &(id_aa_securityLabel_list[8]), 2 },
  237. { NULL, 2 }
  238. };
  239. static const struct ASN1objectidentifier_s id_aa_equivalentLabels_list[9] = {
  240. { (ASN1objectidentifier_t) &(id_aa_equivalentLabels_list[1]), 1 },
  241. { (ASN1objectidentifier_t) &(id_aa_equivalentLabels_list[2]), 2 },
  242. { (ASN1objectidentifier_t) &(id_aa_equivalentLabels_list[3]), 840 },
  243. { (ASN1objectidentifier_t) &(id_aa_equivalentLabels_list[4]), 113549 },
  244. { (ASN1objectidentifier_t) &(id_aa_equivalentLabels_list[5]), 1 },
  245. { (ASN1objectidentifier_t) &(id_aa_equivalentLabels_list[6]), 9 },
  246. { (ASN1objectidentifier_t) &(id_aa_equivalentLabels_list[7]), 16 },
  247. { (ASN1objectidentifier_t) &(id_aa_equivalentLabels_list[8]), 2 },
  248. { NULL, 9 }
  249. };
  250. static const struct ASN1objectidentifier_s id_aa_mlExpandHistory_list[9] = {
  251. { (ASN1objectidentifier_t) &(id_aa_mlExpandHistory_list[1]), 1 },
  252. { (ASN1objectidentifier_t) &(id_aa_mlExpandHistory_list[2]), 2 },
  253. { (ASN1objectidentifier_t) &(id_aa_mlExpandHistory_list[3]), 840 },
  254. { (ASN1objectidentifier_t) &(id_aa_mlExpandHistory_list[4]), 113549 },
  255. { (ASN1objectidentifier_t) &(id_aa_mlExpandHistory_list[5]), 1 },
  256. { (ASN1objectidentifier_t) &(id_aa_mlExpandHistory_list[6]), 9 },
  257. { (ASN1objectidentifier_t) &(id_aa_mlExpandHistory_list[7]), 16 },
  258. { (ASN1objectidentifier_t) &(id_aa_mlExpandHistory_list[8]), 2 },
  259. { NULL, 3 }
  260. };
  261. static const struct ASN1objectidentifier_s id_aa_signingCertificate_list[9] = {
  262. { (ASN1objectidentifier_t) &(id_aa_signingCertificate_list[1]), 1 },
  263. { (ASN1objectidentifier_t) &(id_aa_signingCertificate_list[2]), 2 },
  264. { (ASN1objectidentifier_t) &(id_aa_signingCertificate_list[3]), 840 },
  265. { (ASN1objectidentifier_t) &(id_aa_signingCertificate_list[4]), 113549 },
  266. { (ASN1objectidentifier_t) &(id_aa_signingCertificate_list[5]), 1 },
  267. { (ASN1objectidentifier_t) &(id_aa_signingCertificate_list[6]), 9 },
  268. { (ASN1objectidentifier_t) &(id_aa_signingCertificate_list[7]), 16 },
  269. { (ASN1objectidentifier_t) &(id_aa_signingCertificate_list[8]), 2 },
  270. { NULL, 12 }
  271. };
  272. /* definitions of values: */
  273. ASN1int32_t ub_receiptsTo = 16;
  274. ASN1objectidentifier_t id_aa_receiptRequest = (ASN1objectidentifier_t) id_aa_receiptRequest_list;
  275. ASN1objectidentifier_t id_aa_contentIdentifier = (ASN1objectidentifier_t) id_aa_contentIdentifier_list;
  276. ASN1objectidentifier_t id_ct_receipt = (ASN1objectidentifier_t) id_ct_receipt_list;
  277. ASN1objectidentifier_t id_aa_contentHint = (ASN1objectidentifier_t) id_aa_contentHint_list;
  278. ASN1objectidentifier_t id_aa_msgSigDigest = (ASN1objectidentifier_t) id_aa_msgSigDigest_list;
  279. ASN1objectidentifier_t id_aa_contentReference = (ASN1objectidentifier_t) id_aa_contentReference_list;
  280. ASN1objectidentifier_t id_aa_securityLabel = (ASN1objectidentifier_t) id_aa_securityLabel_list;
  281. ASN1int32_t ub_integer_options = 256;
  282. ASN1int32_t ub_privacy_mark_length = 128;
  283. ASN1int32_t ub_security_categories = 64;
  284. ASN1objectidentifier_t id_aa_equivalentLabels = (ASN1objectidentifier_t) id_aa_equivalentLabels_list;
  285. ASN1objectidentifier_t id_aa_mlExpandHistory = (ASN1objectidentifier_t) id_aa_mlExpandHistory_list;
  286. ASN1int32_t ub_ml_expansion_history = 64;
  287. ASN1objectidentifier_t id_aa_signingCertificate = (ASN1objectidentifier_t) id_aa_signingCertificate_list;
  288. void ASN1CALL ESS_Module_Startup(void)
  289. {
  290. if (ESS_Module == NULL) {
  291. ESS_Module = ASN1_CreateModule(0x10000, ASN1_BER_RULE_DER, ASN1FLAGS_NOASSERT, 10, (const ASN1GenericFun_t *) encfntab, (const ASN1GenericFun_t *) decfntab, freefntab, sizetab, 0x737365);
  292. }
  293. }
  294. void ASN1CALL ESS_Module_Cleanup(void)
  295. {
  296. ASN1_CloseModule(ESS_Module);
  297. ESS_Module = NULL;
  298. }
  299. static int ASN1CALL ASN1Enc_SigningCertificate_policies(ASN1encoding_t enc, ASN1uint32_t tag, SigningCertificate_policies *val)
  300. {
  301. ASN1uint32_t nLenOff;
  302. ASN1uint32_t i;
  303. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  304. return 0;
  305. for (i = 0; i < (val)->count; i++) {
  306. if (!ASN1BEREncOpenType(enc, &((val)->value)[i]))
  307. return 0;
  308. }
  309. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  310. return 0;
  311. return 1;
  312. }
  313. static int ASN1CALL ASN1Dec_SigningCertificate_policies(ASN1decoding_t dec, ASN1uint32_t tag, SigningCertificate_policies *val)
  314. {
  315. ASN1decoding_t dd;
  316. ASN1octet_t *di;
  317. ASN1uint32_t t;
  318. ASN1uint32_t n;
  319. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  320. return 0;
  321. (val)->count = n = 0;
  322. (val)->value = NULL;
  323. while (ASN1BERDecNotEndOfContents(dd, di)) {
  324. if (!ASN1BERDecPeekTag(dd, &t))
  325. return 0;
  326. if ((val)->count >= n) {
  327. n = n ? (n << 1) : 16;
  328. PolicyInformation *value = (PolicyInformation *)ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value));
  329. if(value)
  330. val->value = value;
  331. else
  332. return 0;
  333. }
  334. if (!ASN1BERDecOpenType2(dd, &((val)->value)[(val)->count]))
  335. return 0;
  336. ((val)->count)++;
  337. }
  338. if (!ASN1BERDecEndOfContents(dec, dd, di))
  339. return 0;
  340. return 1;
  341. }
  342. static void ASN1CALL ASN1Free_SigningCertificate_policies(SigningCertificate_policies *val)
  343. {
  344. ASN1uint32_t i;
  345. for (i = 0; i < (val)->count; i++) {
  346. }
  347. if ((val)->count)
  348. ASN1Free((val)->value);
  349. }
  350. static int ASN1CALL ASN1Enc_SigningCertificate_certs(ASN1encoding_t enc, ASN1uint32_t tag, SigningCertificate_certs *val)
  351. {
  352. ASN1uint32_t nLenOff;
  353. ASN1uint32_t i;
  354. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  355. return 0;
  356. for (i = 0; i < (val)->count; i++) {
  357. if (!ASN1Enc_ESSCertID(enc, 0, &((val)->value)[i]))
  358. return 0;
  359. }
  360. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  361. return 0;
  362. return 1;
  363. }
  364. static int ASN1CALL ASN1Dec_SigningCertificate_certs(ASN1decoding_t dec, ASN1uint32_t tag, SigningCertificate_certs *val)
  365. {
  366. ASN1decoding_t dd;
  367. ASN1octet_t *di;
  368. ASN1uint32_t t;
  369. ASN1uint32_t n;
  370. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  371. return 0;
  372. (val)->count = n = 0;
  373. (val)->value = NULL;
  374. while (ASN1BERDecNotEndOfContents(dd, di)) {
  375. if (!ASN1BERDecPeekTag(dd, &t))
  376. return 0;
  377. if ((val)->count >= n) {
  378. n = n ? (n << 1) : 16;
  379. ESSCertID * value = (ESSCertID *)ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value));
  380. if (value)
  381. val->value = value;
  382. else
  383. return 0;
  384. }
  385. if (!ASN1Dec_ESSCertID(dd, 0, &((val)->value)[(val)->count]))
  386. return 0;
  387. ((val)->count)++;
  388. }
  389. if (!ASN1BERDecEndOfContents(dec, dd, di))
  390. return 0;
  391. return 1;
  392. }
  393. static void ASN1CALL ASN1Free_SigningCertificate_certs(SigningCertificate_certs *val)
  394. {
  395. ASN1uint32_t i;
  396. for (i = 0; i < (val)->count; i++) {
  397. ASN1Free_ESSCertID(&(val)->value[i]);
  398. }
  399. if ((val)->count)
  400. ASN1Free((val)->value);
  401. }
  402. static int ASN1CALL ASN1Enc_MLReceiptPolicy_inAdditionTo(ASN1encoding_t enc, ASN1uint32_t tag, MLReceiptPolicy_inAdditionTo *val)
  403. {
  404. ASN1uint32_t nLenOff;
  405. ASN1uint32_t i;
  406. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x80000002, &nLenOff))
  407. return 0;
  408. for (i = 0; i < (val)->count; i++) {
  409. if (!ASN1BEREncOpenType(enc, &((val)->value)[i]))
  410. return 0;
  411. }
  412. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  413. return 0;
  414. return 1;
  415. }
  416. static int ASN1CALL ASN1Dec_MLReceiptPolicy_inAdditionTo(ASN1decoding_t dec, ASN1uint32_t tag, MLReceiptPolicy_inAdditionTo *val)
  417. {
  418. ASN1decoding_t dd;
  419. ASN1octet_t *di;
  420. ASN1uint32_t t;
  421. ASN1uint32_t n;
  422. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x80000002, &dd, &di))
  423. return 0;
  424. (val)->count = n = 0;
  425. (val)->value = NULL;
  426. while (ASN1BERDecNotEndOfContents(dd, di)) {
  427. if (!ASN1BERDecPeekTag(dd, &t))
  428. return 0;
  429. if ((val)->count >= n) {
  430. n = n ? (n << 1) : 16;
  431. GeneralNames *value = (GeneralNames *)ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value));
  432. if (value)
  433. val->value = value;
  434. else
  435. return 0;
  436. }
  437. if (!ASN1BERDecOpenType2(dd, &((val)->value)[(val)->count]))
  438. return 0;
  439. ((val)->count)++;
  440. }
  441. if (!ASN1BERDecEndOfContents(dec, dd, di))
  442. return 0;
  443. return 1;
  444. }
  445. static void ASN1CALL ASN1Free_MLReceiptPolicy_inAdditionTo(MLReceiptPolicy_inAdditionTo *val)
  446. {
  447. ASN1uint32_t i;
  448. for (i = 0; i < (val)->count; i++) {
  449. }
  450. if ((val)->count)
  451. ASN1Free((val)->value);
  452. }
  453. static int ASN1CALL ASN1Enc_MLReceiptPolicy_insteadOf(ASN1encoding_t enc, ASN1uint32_t tag, MLReceiptPolicy_insteadOf *val)
  454. {
  455. ASN1uint32_t nLenOff;
  456. ASN1uint32_t i;
  457. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x80000001, &nLenOff))
  458. return 0;
  459. for (i = 0; i < (val)->count; i++) {
  460. if (!ASN1BEREncOpenType(enc, &((val)->value)[i]))
  461. return 0;
  462. }
  463. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  464. return 0;
  465. return 1;
  466. }
  467. static int ASN1CALL ASN1Dec_MLReceiptPolicy_insteadOf(ASN1decoding_t dec, ASN1uint32_t tag, MLReceiptPolicy_insteadOf *val)
  468. {
  469. ASN1decoding_t dd;
  470. ASN1octet_t *di;
  471. ASN1uint32_t t;
  472. ASN1uint32_t n;
  473. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x80000001, &dd, &di))
  474. return 0;
  475. (val)->count = n = 0;
  476. (val)->value = NULL;
  477. while (ASN1BERDecNotEndOfContents(dd, di)) {
  478. if (!ASN1BERDecPeekTag(dd, &t))
  479. return 0;
  480. if ((val)->count >= n) {
  481. n = n ? (n << 1) : 16;
  482. GeneralNames *value = (GeneralNames *)ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value));
  483. if(value)
  484. val->value = value;
  485. else
  486. return 0;
  487. }
  488. if (!ASN1BERDecOpenType2(dd, &((val)->value)[(val)->count]))
  489. return 0;
  490. ((val)->count)++;
  491. }
  492. if (!ASN1BERDecEndOfContents(dec, dd, di))
  493. return 0;
  494. return 1;
  495. }
  496. static void ASN1CALL ASN1Free_MLReceiptPolicy_insteadOf(MLReceiptPolicy_insteadOf *val)
  497. {
  498. ASN1uint32_t i;
  499. for (i = 0; i < (val)->count; i++) {
  500. }
  501. if ((val)->count)
  502. ASN1Free((val)->value);
  503. }
  504. static int ASN1CALL ASN1Enc_ReceiptsFrom_receiptList(ASN1encoding_t enc, ASN1uint32_t tag, ReceiptsFrom_receiptList *val)
  505. {
  506. ASN1uint32_t nLenOff;
  507. ASN1uint32_t i;
  508. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x80000001, &nLenOff))
  509. return 0;
  510. for (i = 0; i < (val)->count; i++) {
  511. if (!ASN1BEREncOpenType(enc, &((val)->value)[i]))
  512. return 0;
  513. }
  514. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  515. return 0;
  516. return 1;
  517. }
  518. static int ASN1CALL ASN1Dec_ReceiptsFrom_receiptList(ASN1decoding_t dec, ASN1uint32_t tag, ReceiptsFrom_receiptList *val)
  519. {
  520. ASN1decoding_t dd;
  521. ASN1octet_t *di;
  522. ASN1uint32_t t;
  523. ASN1uint32_t n;
  524. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x80000001, &dd, &di))
  525. return 0;
  526. (val)->count = n = 0;
  527. (val)->value = NULL;
  528. while (ASN1BERDecNotEndOfContents(dd, di)) {
  529. if (!ASN1BERDecPeekTag(dd, &t))
  530. return 0;
  531. if ((val)->count >= n) {
  532. n = n ? (n << 1) : 16;
  533. GeneralNames *value = (GeneralNames *)ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value));
  534. if(value)
  535. val->value = value;
  536. else
  537. return 0;
  538. }
  539. if (!ASN1BERDecOpenType2(dd, &((val)->value)[(val)->count]))
  540. return 0;
  541. ((val)->count)++;
  542. }
  543. if (!ASN1BERDecEndOfContents(dec, dd, di))
  544. return 0;
  545. return 1;
  546. }
  547. static void ASN1CALL ASN1Free_ReceiptsFrom_receiptList(ReceiptsFrom_receiptList *val)
  548. {
  549. ASN1uint32_t i;
  550. for (i = 0; i < (val)->count; i++) {
  551. }
  552. if ((val)->count)
  553. ASN1Free((val)->value);
  554. }
  555. static int ASN1CALL ASN1Enc_ReceiptRequest_receiptsTo(ASN1encoding_t enc, ASN1uint32_t tag, ReceiptRequest_receiptsTo *val)
  556. {
  557. ASN1uint32_t nLenOff;
  558. ASN1uint32_t i;
  559. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  560. return 0;
  561. for (i = 0; i < (val)->count; i++) {
  562. if (!ASN1BEREncOpenType(enc, &((val)->value)[i]))
  563. return 0;
  564. }
  565. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  566. return 0;
  567. return 1;
  568. }
  569. static int ASN1CALL ASN1Dec_ReceiptRequest_receiptsTo(ASN1decoding_t dec, ASN1uint32_t tag, ReceiptRequest_receiptsTo *val)
  570. {
  571. ASN1decoding_t dd;
  572. ASN1octet_t *di;
  573. ASN1uint32_t t;
  574. ASN1uint32_t n;
  575. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  576. return 0;
  577. (val)->count = n = 0;
  578. (val)->value = NULL;
  579. while (ASN1BERDecNotEndOfContents(dd, di)) {
  580. if (!ASN1BERDecPeekTag(dd, &t))
  581. return 0;
  582. if ((val)->count >= n) {
  583. n = n ? (n << 1) : 16;
  584. GeneralNames * value = (GeneralNames *)ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value));
  585. if(value)
  586. val->value = value;
  587. else
  588. return 0;
  589. }
  590. if (!ASN1BERDecOpenType2(dd, &((val)->value)[(val)->count]))
  591. return 0;
  592. ((val)->count)++;
  593. }
  594. if (!ASN1BERDecEndOfContents(dec, dd, di))
  595. return 0;
  596. return 1;
  597. }
  598. static void ASN1CALL ASN1Free_ReceiptRequest_receiptsTo(ReceiptRequest_receiptsTo *val)
  599. {
  600. ASN1uint32_t i;
  601. for (i = 0; i < (val)->count; i++) {
  602. }
  603. if ((val)->count)
  604. ASN1Free((val)->value);
  605. }
  606. static int ASN1CALL ASN1Enc_IssuerAndSerialNumber(ASN1encoding_t enc, ASN1uint32_t tag, IssuerAndSerialNumber *val)
  607. {
  608. ASN1uint32_t nLenOff;
  609. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  610. return 0;
  611. if (!ASN1BEREncOpenType(enc, &(val)->issuer))
  612. return 0;
  613. if (!ASN1BEREncSX(enc, 0x2, &(val)->serialNumber))
  614. return 0;
  615. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  616. return 0;
  617. return 1;
  618. }
  619. static int ASN1CALL ASN1Dec_IssuerAndSerialNumber(ASN1decoding_t dec, ASN1uint32_t tag, IssuerAndSerialNumber *val)
  620. {
  621. ASN1decoding_t dd;
  622. ASN1octet_t *di;
  623. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  624. return 0;
  625. if (!ASN1BERDecOpenType2(dd, &(val)->issuer))
  626. return 0;
  627. if (!ASN1BERDecSXVal(dd, 0x2, &(val)->serialNumber))
  628. return 0;
  629. if (!ASN1BERDecEndOfContents(dec, dd, di))
  630. return 0;
  631. return 1;
  632. }
  633. static void ASN1CALL ASN1Free_IssuerAndSerialNumber(IssuerAndSerialNumber *val)
  634. {
  635. ASN1intx_free(&(val)->serialNumber);
  636. }
  637. static int ASN1CALL ASN1Enc_ReceiptsFrom(ASN1encoding_t enc, ASN1uint32_t tag, ReceiptsFrom *val)
  638. {
  639. switch ((val)->choice) {
  640. case 1:
  641. if (!ASN1BEREncS32(enc, 0x80000000, (val)->u.allOrFirstTier))
  642. return 0;
  643. break;
  644. case 2:
  645. if (!ASN1Enc_ReceiptsFrom_receiptList(enc, 0, &(val)->u.receiptList))
  646. return 0;
  647. break;
  648. }
  649. return 1;
  650. }
  651. static int ASN1CALL ASN1Dec_ReceiptsFrom(ASN1decoding_t dec, ASN1uint32_t tag, ReceiptsFrom *val)
  652. {
  653. ASN1uint32_t t;
  654. if (!ASN1BERDecPeekTag(dec, &t))
  655. return 0;
  656. switch (t) {
  657. case 0x80000000:
  658. (val)->choice = 1;
  659. if (!ASN1BERDecS32Val(dec, 0x80000000, &(val)->u.allOrFirstTier))
  660. return 0;
  661. break;
  662. case 0x80000001:
  663. (val)->choice = 2;
  664. if (!ASN1Dec_ReceiptsFrom_receiptList(dec, 0, &(val)->u.receiptList))
  665. return 0;
  666. break;
  667. default:
  668. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  669. return 0;
  670. }
  671. return 1;
  672. }
  673. static void ASN1CALL ASN1Free_ReceiptsFrom(ReceiptsFrom *val)
  674. {
  675. switch ((val)->choice) {
  676. case 2:
  677. ASN1Free_ReceiptsFrom_receiptList(&(val)->u.receiptList);
  678. break;
  679. }
  680. }
  681. static int ASN1CALL ASN1Enc_Receipt(ASN1encoding_t enc, ASN1uint32_t tag, Receipt *val)
  682. {
  683. ASN1uint32_t nLenOff;
  684. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  685. return 0;
  686. if (!ASN1BEREncS32(enc, 0x2, (val)->version))
  687. return 0;
  688. if (!ASN1BEREncObjectIdentifier2(enc, 0x6, &(val)->contentType))
  689. return 0;
  690. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->signedContentIdentifier).length, ((val)->signedContentIdentifier).value))
  691. return 0;
  692. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->originatorSignatureValue).length, ((val)->originatorSignatureValue).value))
  693. return 0;
  694. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  695. return 0;
  696. return 1;
  697. }
  698. static int ASN1CALL ASN1Dec_Receipt(ASN1decoding_t dec, ASN1uint32_t tag, Receipt *val)
  699. {
  700. ASN1decoding_t dd;
  701. ASN1octet_t *di;
  702. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  703. return 0;
  704. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->version))
  705. return 0;
  706. if (!ASN1BERDecObjectIdentifier2(dd, 0x6, &(val)->contentType))
  707. return 0;
  708. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->signedContentIdentifier))
  709. return 0;
  710. if (!ASN1BERDecOctetString2(dd, 0x4, &(val)->originatorSignatureValue))
  711. return 0;
  712. if (!ASN1BERDecEndOfContents(dec, dd, di))
  713. return 0;
  714. return 1;
  715. }
  716. static void ASN1CALL ASN1Free_Receipt(Receipt *val)
  717. {
  718. ASN1octetstring_free(&(val)->signedContentIdentifier);
  719. }
  720. static int ASN1CALL ASN1Enc_ContentHints(ASN1encoding_t enc, ASN1uint32_t tag, ContentHints *val)
  721. {
  722. ASN1uint32_t nLenOff;
  723. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  724. return 0;
  725. if ((val)->o[0] & 0x80) {
  726. if (!ASN1DEREncUTF8String(enc, 0xc, ((val)->contentDescription).length, ((val)->contentDescription).value))
  727. return 0;
  728. }
  729. if (!ASN1BEREncObjectIdentifier2(enc, 0x6, &(val)->contentType))
  730. return 0;
  731. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  732. return 0;
  733. return 1;
  734. }
  735. static int ASN1CALL ASN1Dec_ContentHints(ASN1decoding_t dec, ASN1uint32_t tag, ContentHints *val)
  736. {
  737. ASN1decoding_t dd;
  738. ASN1octet_t *di;
  739. ASN1uint32_t t;
  740. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  741. return 0;
  742. ZeroMemory((val)->o, 1);
  743. ASN1BERDecPeekTag(dd, &t);
  744. if (t == 0xc) {
  745. (val)->o[0] |= 0x80;
  746. if (!ASN1BERDecUTF8String(dd, 0xc, &(val)->contentDescription))
  747. return 0;
  748. }
  749. if (!ASN1BERDecObjectIdentifier2(dd, 0x6, &(val)->contentType))
  750. return 0;
  751. if (!ASN1BERDecEndOfContents(dec, dd, di))
  752. return 0;
  753. return 1;
  754. }
  755. static void ASN1CALL ASN1Free_ContentHints(ContentHints *val)
  756. {
  757. if ((val)->o[0] & 0x80) {
  758. ASN1utf8string_free(&(val)->contentDescription);
  759. }
  760. }
  761. static int ASN1CALL ASN1Enc_ContentReference(ASN1encoding_t enc, ASN1uint32_t tag, ContentReference *val)
  762. {
  763. ASN1uint32_t nLenOff;
  764. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  765. return 0;
  766. if (!ASN1BEREncObjectIdentifier2(enc, 0x6, &(val)->contentType))
  767. return 0;
  768. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->signedContentIdentifier).length, ((val)->signedContentIdentifier).value))
  769. return 0;
  770. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->originatorSignatureValue).length, ((val)->originatorSignatureValue).value))
  771. return 0;
  772. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  773. return 0;
  774. return 1;
  775. }
  776. static int ASN1CALL ASN1Dec_ContentReference(ASN1decoding_t dec, ASN1uint32_t tag, ContentReference *val)
  777. {
  778. ASN1decoding_t dd;
  779. ASN1octet_t *di;
  780. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  781. return 0;
  782. if (!ASN1BERDecObjectIdentifier2(dd, 0x6, &(val)->contentType))
  783. return 0;
  784. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->signedContentIdentifier))
  785. return 0;
  786. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->originatorSignatureValue))
  787. return 0;
  788. if (!ASN1BERDecEndOfContents(dec, dd, di))
  789. return 0;
  790. return 1;
  791. }
  792. static void ASN1CALL ASN1Free_ContentReference(ContentReference *val)
  793. {
  794. ASN1octetstring_free(&(val)->signedContentIdentifier);
  795. ASN1octetstring_free(&(val)->originatorSignatureValue);
  796. }
  797. static int ASN1CALL ASN1Enc_ESSPrivacyMark(ASN1encoding_t enc, ASN1uint32_t tag, ESSPrivacyMark *val)
  798. {
  799. ASN1uint32_t t;
  800. switch ((val)->choice) {
  801. case 1:
  802. if (!ASN1DEREncUTF8String(enc, 0xc, ((val)->u.utf8String).length, ((val)->u.utf8String).value))
  803. return 0;
  804. break;
  805. case 2:
  806. t = lstrlenA((val)->u.pString);
  807. if (!ASN1DEREncCharString(enc, 0x13, t, (val)->u.pString))
  808. return 0;
  809. break;
  810. }
  811. return 1;
  812. }
  813. static int ASN1CALL ASN1Dec_ESSPrivacyMark(ASN1decoding_t dec, ASN1uint32_t tag, ESSPrivacyMark *val)
  814. {
  815. ASN1uint32_t t;
  816. if (!ASN1BERDecPeekTag(dec, &t))
  817. return 0;
  818. switch (t) {
  819. case 0xc:
  820. (val)->choice = 1;
  821. if (!ASN1BERDecUTF8String(dec, 0xc, &(val)->u.utf8String))
  822. return 0;
  823. break;
  824. case 0x13:
  825. (val)->choice = 2;
  826. if (!ASN1BERDecZeroCharString(dec, 0x13, &(val)->u.pString))
  827. return 0;
  828. break;
  829. default:
  830. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  831. return 0;
  832. }
  833. return 1;
  834. }
  835. static void ASN1CALL ASN1Free_ESSPrivacyMark(ESSPrivacyMark *val)
  836. {
  837. switch ((val)->choice) {
  838. case 1:
  839. ASN1utf8string_free(&(val)->u.utf8String);
  840. break;
  841. case 2:
  842. ASN1ztcharstring_free((val)->u.pString);
  843. break;
  844. }
  845. }
  846. static int ASN1CALL ASN1Enc_SecurityCategories(ASN1encoding_t enc, ASN1uint32_t tag, SecurityCategories *val)
  847. {
  848. ASN1uint32_t nLenOff;
  849. void *pBlk;
  850. ASN1uint32_t i;
  851. ASN1encoding_t enc2;
  852. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x11, &nLenOff))
  853. return 0;
  854. if (!ASN1DEREncBeginBlk(enc, ASN1_DER_SET_OF_BLOCK, &pBlk))
  855. return 0;
  856. for (i = 0; i < (val)->count; i++) {
  857. if (!ASN1DEREncNewBlkElement(pBlk, &enc2))
  858. return 0;
  859. if (!ASN1Enc_SecurityCategory(enc2, 0, &((val)->value)[i]))
  860. return 0;
  861. if (!ASN1DEREncFlushBlkElement(pBlk))
  862. return 0;
  863. }
  864. if (!ASN1DEREncEndBlk(pBlk))
  865. return 0;
  866. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  867. return 0;
  868. return 1;
  869. }
  870. static int ASN1CALL ASN1Dec_SecurityCategories(ASN1decoding_t dec, ASN1uint32_t tag, SecurityCategories *val)
  871. {
  872. ASN1decoding_t dd;
  873. ASN1octet_t *di;
  874. ASN1uint32_t t;
  875. ASN1uint32_t n;
  876. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x11, &dd, &di))
  877. return 0;
  878. (val)->count = n = 0;
  879. (val)->value = NULL;
  880. while (ASN1BERDecNotEndOfContents(dd, di)) {
  881. if (!ASN1BERDecPeekTag(dd, &t))
  882. return 0;
  883. if ((val)->count >= n) {
  884. n = n ? (n << 1) : 16;
  885. SecurityCategory *value = (SecurityCategory *)ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value));
  886. if(value)
  887. val->value = value;
  888. else
  889. return 0;
  890. }
  891. if (!ASN1Dec_SecurityCategory(dd, 0, &((val)->value)[(val)->count]))
  892. return 0;
  893. ((val)->count)++;
  894. }
  895. if (!ASN1BERDecEndOfContents(dec, dd, di))
  896. return 0;
  897. return 1;
  898. }
  899. static void ASN1CALL ASN1Free_SecurityCategories(SecurityCategories *val)
  900. {
  901. ASN1uint32_t i;
  902. for (i = 0; i < (val)->count; i++) {
  903. ASN1Free_SecurityCategory(&(val)->value[i]);
  904. }
  905. if ((val)->count)
  906. ASN1Free((val)->value);
  907. }
  908. static int ASN1CALL ASN1Enc_SecurityCategory(ASN1encoding_t enc, ASN1uint32_t tag, SecurityCategory *val)
  909. {
  910. ASN1uint32_t nLenOff;
  911. ASN1uint32_t nLenOff0;
  912. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  913. return 0;
  914. if (!ASN1BEREncObjectIdentifier2(enc, 0x80000000, &(val)->type))
  915. return 0;
  916. if (!ASN1BEREncExplicitTag(enc, 0x80000001, &nLenOff0))
  917. return 0;
  918. if (!ASN1BEREncOpenType(enc, &(val)->value))
  919. return 0;
  920. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  921. return 0;
  922. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  923. return 0;
  924. return 1;
  925. }
  926. static int ASN1CALL ASN1Dec_SecurityCategory(ASN1decoding_t dec, ASN1uint32_t tag, SecurityCategory *val)
  927. {
  928. ASN1decoding_t dd;
  929. ASN1octet_t *di;
  930. ASN1decoding_t dd0;
  931. ASN1octet_t *di0;
  932. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  933. return 0;
  934. if (!ASN1BERDecObjectIdentifier2(dd, 0x80000000, &(val)->type))
  935. return 0;
  936. if (!ASN1BERDecExplicitTag(dd, 0x80000001, &dd0, &di0))
  937. return 0;
  938. if (!ASN1BERDecOpenType2(dd0, &(val)->value))
  939. return 0;
  940. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  941. return 0;
  942. if (!ASN1BERDecEndOfContents(dec, dd, di))
  943. return 0;
  944. return 1;
  945. }
  946. static void ASN1CALL ASN1Free_SecurityCategory(SecurityCategory *val)
  947. {
  948. }
  949. static int ASN1CALL ASN1Enc_EquivalentLabels(ASN1encoding_t enc, ASN1uint32_t tag, EquivalentLabels *val)
  950. {
  951. ASN1uint32_t nLenOff;
  952. ASN1uint32_t i;
  953. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  954. return 0;
  955. for (i = 0; i < (val)->count; i++) {
  956. if (!ASN1Enc_ESSSecurityLabel(enc, 0, &((val)->value)[i]))
  957. return 0;
  958. }
  959. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  960. return 0;
  961. return 1;
  962. }
  963. static int ASN1CALL ASN1Dec_EquivalentLabels(ASN1decoding_t dec, ASN1uint32_t tag, EquivalentLabels *val)
  964. {
  965. ASN1decoding_t dd;
  966. ASN1octet_t *di;
  967. ASN1uint32_t t;
  968. ASN1uint32_t n;
  969. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  970. return 0;
  971. (val)->count = n = 0;
  972. (val)->value = NULL;
  973. while (ASN1BERDecNotEndOfContents(dd, di)) {
  974. if (!ASN1BERDecPeekTag(dd, &t))
  975. return 0;
  976. if ((val)->count >= n) {
  977. n = n ? (n << 1) : 16;
  978. ESSSecurityLabel *value = (ESSSecurityLabel *)ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value));
  979. if(value)
  980. val->value = value;
  981. else
  982. return 0;
  983. }
  984. if (!ASN1Dec_ESSSecurityLabel(dd, 0, &((val)->value)[(val)->count]))
  985. return 0;
  986. ((val)->count)++;
  987. }
  988. if (!ASN1BERDecEndOfContents(dec, dd, di))
  989. return 0;
  990. return 1;
  991. }
  992. static void ASN1CALL ASN1Free_EquivalentLabels(EquivalentLabels *val)
  993. {
  994. ASN1uint32_t i;
  995. for (i = 0; i < (val)->count; i++) {
  996. ASN1Free_ESSSecurityLabel(&(val)->value[i]);
  997. }
  998. if ((val)->count)
  999. ASN1Free((val)->value);
  1000. }
  1001. static int ASN1CALL ASN1Enc_MLExpansionHistory(ASN1encoding_t enc, ASN1uint32_t tag, MLExpansionHistory *val)
  1002. {
  1003. ASN1uint32_t nLenOff;
  1004. ASN1uint32_t i;
  1005. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1006. return 0;
  1007. for (i = 0; i < (val)->count; i++) {
  1008. if (!ASN1Enc_MLData(enc, 0, &((val)->value)[i]))
  1009. return 0;
  1010. }
  1011. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1012. return 0;
  1013. return 1;
  1014. }
  1015. static int ASN1CALL ASN1Dec_MLExpansionHistory(ASN1decoding_t dec, ASN1uint32_t tag, MLExpansionHistory *val)
  1016. {
  1017. ASN1decoding_t dd;
  1018. ASN1octet_t *di;
  1019. ASN1uint32_t t;
  1020. ASN1uint32_t n;
  1021. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1022. return 0;
  1023. (val)->count = n = 0;
  1024. (val)->value = NULL;
  1025. while (ASN1BERDecNotEndOfContents(dd, di)) {
  1026. if (!ASN1BERDecPeekTag(dd, &t))
  1027. return 0;
  1028. if ((val)->count >= n) {
  1029. n = n ? (n << 1) : 16;
  1030. MLData *value = (MLData *)ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value));
  1031. if(value)
  1032. val->value = value;
  1033. else
  1034. return 0;
  1035. }
  1036. if (!ASN1Dec_MLData(dd, 0, &((val)->value)[(val)->count]))
  1037. return 0;
  1038. ((val)->count)++;
  1039. }
  1040. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1041. return 0;
  1042. return 1;
  1043. }
  1044. static void ASN1CALL ASN1Free_MLExpansionHistory(MLExpansionHistory *val)
  1045. {
  1046. ASN1uint32_t i;
  1047. for (i = 0; i < (val)->count; i++) {
  1048. ASN1Free_MLData(&(val)->value[i]);
  1049. }
  1050. if ((val)->count)
  1051. ASN1Free((val)->value);
  1052. }
  1053. static int ASN1CALL ASN1Enc_EntityIdentifier(ASN1encoding_t enc, ASN1uint32_t tag, EntityIdentifier *val)
  1054. {
  1055. switch ((val)->choice) {
  1056. case 1:
  1057. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->u.subjectKeyIdentifier).length, ((val)->u.subjectKeyIdentifier).value))
  1058. return 0;
  1059. break;
  1060. case 2:
  1061. if (!ASN1Enc_IssuerAndSerialNumber(enc, 0, &(val)->u.issuerAndSerialNumber))
  1062. return 0;
  1063. break;
  1064. }
  1065. return 1;
  1066. }
  1067. static int ASN1CALL ASN1Dec_EntityIdentifier(ASN1decoding_t dec, ASN1uint32_t tag, EntityIdentifier *val)
  1068. {
  1069. ASN1uint32_t t;
  1070. if (!ASN1BERDecPeekTag(dec, &t))
  1071. return 0;
  1072. switch (t) {
  1073. case 0x4:
  1074. (val)->choice = 1;
  1075. if (!ASN1BERDecOctetString2(dec, 0x4, &(val)->u.subjectKeyIdentifier))
  1076. return 0;
  1077. break;
  1078. case 0x10:
  1079. (val)->choice = 2;
  1080. if (!ASN1Dec_IssuerAndSerialNumber(dec, 0, &(val)->u.issuerAndSerialNumber))
  1081. return 0;
  1082. break;
  1083. default:
  1084. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  1085. return 0;
  1086. }
  1087. return 1;
  1088. }
  1089. static void ASN1CALL ASN1Free_EntityIdentifier(EntityIdentifier *val)
  1090. {
  1091. switch ((val)->choice) {
  1092. case 1:
  1093. break;
  1094. case 2:
  1095. ASN1Free_IssuerAndSerialNumber(&(val)->u.issuerAndSerialNumber);
  1096. break;
  1097. }
  1098. }
  1099. static int ASN1CALL ASN1Enc_MLReceiptPolicy(ASN1encoding_t enc, ASN1uint32_t tag, MLReceiptPolicy *val)
  1100. {
  1101. switch ((val)->choice) {
  1102. case 1:
  1103. if (!ASN1BEREncNull(enc, 0x80000000))
  1104. return 0;
  1105. break;
  1106. case 2:
  1107. if (!ASN1Enc_MLReceiptPolicy_insteadOf(enc, 0, &(val)->u.insteadOf))
  1108. return 0;
  1109. break;
  1110. case 3:
  1111. if (!ASN1Enc_MLReceiptPolicy_inAdditionTo(enc, 0, &(val)->u.inAdditionTo))
  1112. return 0;
  1113. break;
  1114. }
  1115. return 1;
  1116. }
  1117. static int ASN1CALL ASN1Dec_MLReceiptPolicy(ASN1decoding_t dec, ASN1uint32_t tag, MLReceiptPolicy *val)
  1118. {
  1119. ASN1uint32_t t;
  1120. if (!ASN1BERDecPeekTag(dec, &t))
  1121. return 0;
  1122. switch (t) {
  1123. case 0x80000000:
  1124. (val)->choice = 1;
  1125. if (!ASN1BERDecNull(dec, 0x80000000))
  1126. return 0;
  1127. break;
  1128. case 0x80000001:
  1129. (val)->choice = 2;
  1130. if (!ASN1Dec_MLReceiptPolicy_insteadOf(dec, 0, &(val)->u.insteadOf))
  1131. return 0;
  1132. break;
  1133. case 0x80000002:
  1134. (val)->choice = 3;
  1135. if (!ASN1Dec_MLReceiptPolicy_inAdditionTo(dec, 0, &(val)->u.inAdditionTo))
  1136. return 0;
  1137. break;
  1138. default:
  1139. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  1140. return 0;
  1141. }
  1142. return 1;
  1143. }
  1144. static void ASN1CALL ASN1Free_MLReceiptPolicy(MLReceiptPolicy *val)
  1145. {
  1146. switch ((val)->choice) {
  1147. case 2:
  1148. ASN1Free_MLReceiptPolicy_insteadOf(&(val)->u.insteadOf);
  1149. break;
  1150. case 3:
  1151. ASN1Free_MLReceiptPolicy_inAdditionTo(&(val)->u.inAdditionTo);
  1152. break;
  1153. }
  1154. }
  1155. static int ASN1CALL ASN1Enc_SigningCertificate(ASN1encoding_t enc, ASN1uint32_t tag, SigningCertificate *val)
  1156. {
  1157. ASN1uint32_t nLenOff;
  1158. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1159. return 0;
  1160. if (!ASN1Enc_SigningCertificate_certs(enc, 0, &(val)->certs))
  1161. return 0;
  1162. if ((val)->o[0] & 0x80) {
  1163. if (!ASN1Enc_SigningCertificate_policies(enc, 0, &(val)->policies))
  1164. return 0;
  1165. }
  1166. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1167. return 0;
  1168. return 1;
  1169. }
  1170. static int ASN1CALL ASN1Dec_SigningCertificate(ASN1decoding_t dec, ASN1uint32_t tag, SigningCertificate *val)
  1171. {
  1172. ASN1decoding_t dd;
  1173. ASN1octet_t *di;
  1174. ASN1uint32_t t;
  1175. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1176. return 0;
  1177. ZeroMemory((val)->o, 1);
  1178. if (!ASN1Dec_SigningCertificate_certs(dd, 0, &(val)->certs))
  1179. return 0;
  1180. ASN1BERDecPeekTag(dd, &t);
  1181. if (t == 0x10) {
  1182. (val)->o[0] |= 0x80;
  1183. if (!ASN1Dec_SigningCertificate_policies(dd, 0, &(val)->policies))
  1184. return 0;
  1185. }
  1186. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1187. return 0;
  1188. return 1;
  1189. }
  1190. static void ASN1CALL ASN1Free_SigningCertificate(SigningCertificate *val)
  1191. {
  1192. ASN1Free_SigningCertificate_certs(&(val)->certs);
  1193. if ((val)->o[0] & 0x80) {
  1194. ASN1Free_SigningCertificate_policies(&(val)->policies);
  1195. }
  1196. }
  1197. static int ASN1CALL ASN1Enc_ESSCertID(ASN1encoding_t enc, ASN1uint32_t tag, ESSCertID *val)
  1198. {
  1199. ASN1uint32_t nLenOff;
  1200. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1201. return 0;
  1202. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->certHash).length, ((val)->certHash).value))
  1203. return 0;
  1204. if ((val)->o[0] & 0x80) {
  1205. if (!ASN1Enc_IssuerAndSerialNumber(enc, 0, &(val)->issuerSerial))
  1206. return 0;
  1207. }
  1208. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1209. return 0;
  1210. return 1;
  1211. }
  1212. static int ASN1CALL ASN1Dec_ESSCertID(ASN1decoding_t dec, ASN1uint32_t tag, ESSCertID *val)
  1213. {
  1214. ASN1decoding_t dd;
  1215. ASN1octet_t *di;
  1216. ASN1uint32_t t;
  1217. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1218. return 0;
  1219. ZeroMemory((val)->o, 1);
  1220. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->certHash))
  1221. return 0;
  1222. ASN1BERDecPeekTag(dd, &t);
  1223. if (t == 0x10) {
  1224. (val)->o[0] |= 0x80;
  1225. if (!ASN1Dec_IssuerAndSerialNumber(dd, 0, &(val)->issuerSerial))
  1226. return 0;
  1227. }
  1228. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1229. return 0;
  1230. return 1;
  1231. }
  1232. static void ASN1CALL ASN1Free_ESSCertID(ESSCertID *val)
  1233. {
  1234. if (val) {
  1235. ASN1octetstring_free(&(val)->certHash);
  1236. if ((val)->o[0] & 0x80) {
  1237. ASN1Free_IssuerAndSerialNumber(&(val)->issuerSerial);
  1238. }
  1239. }
  1240. }
  1241. static int ASN1CALL ASN1Enc_SMimeEncryptCerts(ASN1encoding_t enc, ASN1uint32_t tag, SMimeEncryptCerts *val)
  1242. {
  1243. ASN1uint32_t nLenOff;
  1244. ASN1uint32_t i;
  1245. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1246. return 0;
  1247. for (i = 0; i < (val)->count; i++) {
  1248. if (!ASN1Enc_SMimeEncryptCert(enc, 0, &((val)->value)[i]))
  1249. return 0;
  1250. }
  1251. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1252. return 0;
  1253. return 1;
  1254. }
  1255. static int ASN1CALL ASN1Dec_SMimeEncryptCerts(ASN1decoding_t dec, ASN1uint32_t tag, SMimeEncryptCerts *val)
  1256. {
  1257. ASN1decoding_t dd;
  1258. ASN1octet_t *di;
  1259. ASN1uint32_t t;
  1260. ASN1uint32_t n;
  1261. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1262. return 0;
  1263. (val)->count = n = 0;
  1264. (val)->value = NULL;
  1265. while (ASN1BERDecNotEndOfContents(dd, di)) {
  1266. if (!ASN1BERDecPeekTag(dd, &t))
  1267. return 0;
  1268. if ((val)->count >= n) {
  1269. n = n ? (n << 1) : 16;
  1270. SMimeEncryptCert *value = (SMimeEncryptCert *)ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value));
  1271. if(value)
  1272. val->value = value;
  1273. else
  1274. return 0;
  1275. }
  1276. if (!ASN1Dec_SMimeEncryptCert(dd, 0, &((val)->value)[(val)->count]))
  1277. return 0;
  1278. ((val)->count)++;
  1279. }
  1280. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1281. return 0;
  1282. return 1;
  1283. }
  1284. static void ASN1CALL ASN1Free_SMimeEncryptCerts(SMimeEncryptCerts *val)
  1285. {
  1286. ASN1uint32_t i;
  1287. if (val) {
  1288. ASN1Free_SMimeEncryptCert(&(val)->value[0]);
  1289. for (i = 1; i < (val)->count; i++) {
  1290. ASN1Free_SMimeEncryptCert(&(val)->value[i]);
  1291. }
  1292. ASN1Free((val)->value);
  1293. }
  1294. }
  1295. static int ASN1CALL ASN1Enc_SMIMECapabilities(ASN1encoding_t enc, ASN1uint32_t tag, SMIMECapabilities *val)
  1296. {
  1297. ASN1uint32_t nLenOff;
  1298. ASN1uint32_t i;
  1299. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1300. return 0;
  1301. for (i = 0; i < (val)->count; i++) {
  1302. if (!ASN1Enc_SMIMECapability(enc, 0, &((val)->value)[i]))
  1303. return 0;
  1304. }
  1305. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1306. return 0;
  1307. return 1;
  1308. }
  1309. static int ASN1CALL ASN1Dec_SMIMECapabilities(ASN1decoding_t dec, ASN1uint32_t tag, SMIMECapabilities *val)
  1310. {
  1311. ASN1decoding_t dd;
  1312. ASN1octet_t *di;
  1313. ASN1uint32_t t;
  1314. ASN1uint32_t n;
  1315. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1316. return 0;
  1317. (val)->count = n = 0;
  1318. (val)->value = NULL;
  1319. while (ASN1BERDecNotEndOfContents(dd, di)) {
  1320. if (!ASN1BERDecPeekTag(dd, &t))
  1321. return 0;
  1322. if ((val)->count >= n) {
  1323. n = n ? (n << 1) : 16;
  1324. SMIMECapability *value = (SMIMECapability *)ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value));
  1325. if(value)
  1326. val->value = value;
  1327. else
  1328. return 0;
  1329. }
  1330. if (!ASN1Dec_SMIMECapability(dd, 0, &((val)->value)[(val)->count]))
  1331. return 0;
  1332. ((val)->count)++;
  1333. }
  1334. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1335. return 0;
  1336. return 1;
  1337. }
  1338. static void ASN1CALL ASN1Free_SMIMECapabilities(SMIMECapabilities *val)
  1339. {
  1340. ASN1uint32_t i;
  1341. if (val) {
  1342. ASN1Free_SMIMECapability(&(val)->value[0]);
  1343. for (i = 1; i < (val)->count; i++) {
  1344. ASN1Free_SMIMECapability(&(val)->value[i]);
  1345. }
  1346. ASN1Free((val)->value);
  1347. }
  1348. }
  1349. static int ASN1CALL ASN1Enc_SMIMECapability(ASN1encoding_t enc, ASN1uint32_t tag, SMIMECapability *val)
  1350. {
  1351. ASN1uint32_t nLenOff;
  1352. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1353. return 0;
  1354. if (!ASN1BEREncObjectIdentifier2(enc, 0x6, &(val)->capabilityID))
  1355. return 0;
  1356. if ((val)->o[0] & 0x80) {
  1357. if (!ASN1BEREncOpenType(enc, &(val)->parameters))
  1358. return 0;
  1359. }
  1360. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1361. return 0;
  1362. return 1;
  1363. }
  1364. static int ASN1CALL ASN1Dec_SMIMECapability(ASN1decoding_t dec, ASN1uint32_t tag, SMIMECapability *val)
  1365. {
  1366. ASN1decoding_t dd;
  1367. ASN1octet_t *di;
  1368. ASN1uint32_t t;
  1369. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1370. return 0;
  1371. ZeroMemory((val)->o, 1);
  1372. if (!ASN1BERDecObjectIdentifier2(dd, 0x6, &(val)->capabilityID))
  1373. return 0;
  1374. if (ASN1BERDecPeekTag(dd, &t)) {
  1375. (val)->o[0] |= 0x80;
  1376. if (!ASN1BERDecOpenType2(dd, &(val)->parameters))
  1377. return 0;
  1378. }
  1379. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1380. return 0;
  1381. return 1;
  1382. }
  1383. static void ASN1CALL ASN1Free_SMIMECapability(SMIMECapability *val)
  1384. {
  1385. if ((val)->o[0] & 0x80) {
  1386. // ASN1open_free(&(val)->parameters);
  1387. }
  1388. }
  1389. static int ASN1CALL ASN1Enc_OtherKeyAttribute(ASN1encoding_t enc, ASN1uint32_t tag, OtherKeyAttribute *val)
  1390. {
  1391. ASN1uint32_t nLenOff;
  1392. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1393. return 0;
  1394. if (!ASN1BEREncObjectIdentifier2(enc, 0x6, &(val)->keyAttrId))
  1395. return 0;
  1396. if ((val)->o[0] & 0x80) {
  1397. if (!ASN1BEREncOpenType(enc, &(val)->keyAttr))
  1398. return 0;
  1399. }
  1400. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1401. return 0;
  1402. return 1;
  1403. }
  1404. static int ASN1CALL ASN1Dec_OtherKeyAttribute(ASN1decoding_t dec, ASN1uint32_t tag, OtherKeyAttribute *val)
  1405. {
  1406. ASN1decoding_t dd;
  1407. ASN1octet_t *di;
  1408. ASN1uint32_t t;
  1409. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1410. return 0;
  1411. ZeroMemory((val)->o, 1);
  1412. if (!ASN1BERDecObjectIdentifier2(dd, 0x6, &(val)->keyAttrId))
  1413. return 0;
  1414. if (ASN1BERDecPeekTag(dd, &t)) {
  1415. (val)->o[0] |= 0x80;
  1416. if (!ASN1BERDecOpenType2(dd, &(val)->keyAttr))
  1417. return 0;
  1418. }
  1419. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1420. return 0;
  1421. return 1;
  1422. }
  1423. static void ASN1CALL ASN1Free_OtherKeyAttribute(OtherKeyAttribute *val)
  1424. {
  1425. if ((val)->o[0] & 0x80) {
  1426. // ASN1open_free(&(val)->keyAttr);
  1427. }
  1428. }
  1429. static int ASN1CALL ASN1Enc_ReceiptRequest(ASN1encoding_t enc, ASN1uint32_t tag, ReceiptRequest *val)
  1430. {
  1431. ASN1uint32_t nLenOff;
  1432. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1433. return 0;
  1434. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->signedContentIdentifier).length, ((val)->signedContentIdentifier).value))
  1435. return 0;
  1436. if (!ASN1Enc_ReceiptsFrom(enc, 0, &(val)->receiptsFrom))
  1437. return 0;
  1438. if (!ASN1Enc_ReceiptRequest_receiptsTo(enc, 0, &(val)->receiptsTo))
  1439. return 0;
  1440. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1441. return 0;
  1442. return 1;
  1443. }
  1444. static int ASN1CALL ASN1Dec_ReceiptRequest(ASN1decoding_t dec, ASN1uint32_t tag, ReceiptRequest *val)
  1445. {
  1446. ASN1decoding_t dd;
  1447. ASN1octet_t *di;
  1448. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1449. return 0;
  1450. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->signedContentIdentifier))
  1451. return 0;
  1452. if (!ASN1Dec_ReceiptsFrom(dd, 0, &(val)->receiptsFrom))
  1453. return 0;
  1454. if (!ASN1Dec_ReceiptRequest_receiptsTo(dd, 0, &(val)->receiptsTo))
  1455. return 0;
  1456. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1457. return 0;
  1458. return 1;
  1459. }
  1460. static void ASN1CALL ASN1Free_ReceiptRequest(ReceiptRequest *val)
  1461. {
  1462. ASN1octetstring_free(&(val)->signedContentIdentifier);
  1463. ASN1Free_ReceiptsFrom(&(val)->receiptsFrom);
  1464. ASN1Free_ReceiptRequest_receiptsTo(&(val)->receiptsTo);
  1465. }
  1466. static int ASN1CALL ASN1Enc_ESSSecurityLabel(ASN1encoding_t enc, ASN1uint32_t tag, ESSSecurityLabel *val)
  1467. {
  1468. ASN1uint32_t nLenOff;
  1469. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x11, &nLenOff))
  1470. return 0;
  1471. if ((val)->o[0] & 0x80) {
  1472. if (!ASN1BEREncU32(enc, 0x2, (val)->security_classification))
  1473. return 0;
  1474. }
  1475. if (!ASN1BEREncObjectIdentifier2(enc, 0x6, &(val)->security_policy_identifier))
  1476. return 0;
  1477. if ((val)->o[0] & 0x40) {
  1478. if (!ASN1Enc_ESSPrivacyMark(enc, 0, &(val)->privacy_mark))
  1479. return 0;
  1480. }
  1481. if ((val)->o[0] & 0x20) {
  1482. if (!ASN1Enc_SecurityCategories(enc, 0, &(val)->security_categories))
  1483. return 0;
  1484. }
  1485. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1486. return 0;
  1487. return 1;
  1488. }
  1489. static int ASN1CALL ASN1Dec_ESSSecurityLabel(ASN1decoding_t dec, ASN1uint32_t tag, ESSSecurityLabel *val)
  1490. {
  1491. ASN1decoding_t dd;
  1492. ASN1octet_t *di;
  1493. ASN1uint32_t t;
  1494. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x11, &dd, &di))
  1495. return 0;
  1496. ZeroMemory((val)->o, 1);
  1497. while (ASN1BERDecNotEndOfContents(dd, di)) {
  1498. if (!ASN1BERDecPeekTag(dd, &t))
  1499. return 0;
  1500. switch (t) {
  1501. case 0x2:
  1502. (val)->o[0] |= 0x80;
  1503. if (!ASN1BERDecU16Val(dd, 0x2, &(val)->security_classification))
  1504. return 0;
  1505. break;
  1506. case 0x6:
  1507. if (!ASN1BERDecObjectIdentifier2(dd, 0x6, &(val)->security_policy_identifier))
  1508. return 0;
  1509. break;
  1510. case 0x13:
  1511. case 0x0c:
  1512. (val)->o[0] |= 0x40;
  1513. if (!ASN1Dec_ESSPrivacyMark(dd, 0, &(val)->privacy_mark))
  1514. return 0;
  1515. break;
  1516. case 0x11:
  1517. (val)->o[0] |= 0x20;
  1518. if (!ASN1Dec_SecurityCategories(dd, 0, &(val)->security_categories))
  1519. return 0;
  1520. break;
  1521. default:
  1522. ASN1DecSetError(dd, ASN1_ERR_CORRUPT);
  1523. return 0;
  1524. }
  1525. }
  1526. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1527. return 0;
  1528. return 1;
  1529. }
  1530. static void ASN1CALL ASN1Free_ESSSecurityLabel(ESSSecurityLabel *val)
  1531. {
  1532. if ((val)->o[0] & 0x40) {
  1533. ASN1Free_ESSPrivacyMark(&(val)->privacy_mark);
  1534. }
  1535. if ((val)->o[0] & 0x20) {
  1536. ASN1Free_SecurityCategories(&(val)->security_categories);
  1537. }
  1538. }
  1539. static int ASN1CALL ASN1Enc_MLData(ASN1encoding_t enc, ASN1uint32_t tag, MLData *val)
  1540. {
  1541. ASN1uint32_t nLenOff;
  1542. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1543. return 0;
  1544. if (!ASN1Enc_EntityIdentifier(enc, 0, &(val)->mailListIdentifier))
  1545. return 0;
  1546. if (!ASN1DEREncGeneralizedTime(enc, 0x18, &(val)->expansionTime))
  1547. return 0;
  1548. if ((val)->o[0] & 0x80) {
  1549. if (!ASN1Enc_MLReceiptPolicy(enc, 0, &(val)->mlReceiptPolicy))
  1550. return 0;
  1551. }
  1552. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1553. return 0;
  1554. return 1;
  1555. }
  1556. static int ASN1CALL ASN1Dec_MLData(ASN1decoding_t dec, ASN1uint32_t tag, MLData *val)
  1557. {
  1558. ASN1decoding_t dd;
  1559. ASN1octet_t *di;
  1560. ASN1uint32_t t;
  1561. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1562. return 0;
  1563. ZeroMemory((val)->o, 1);
  1564. if (!ASN1Dec_EntityIdentifier(dd, 0, &(val)->mailListIdentifier))
  1565. return 0;
  1566. if (!ASN1BERDecGeneralizedTime(dd, 0x18, &(val)->expansionTime))
  1567. return 0;
  1568. ASN1BERDecPeekTag(dd, &t);
  1569. if (t == 0x80000000 || t == 0x80000001 || t == 0x80000002) {
  1570. (val)->o[0] |= 0x80;
  1571. if (!ASN1Dec_MLReceiptPolicy(dd, 0, &(val)->mlReceiptPolicy))
  1572. return 0;
  1573. }
  1574. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1575. return 0;
  1576. return 1;
  1577. }
  1578. static void ASN1CALL ASN1Free_MLData(MLData *val)
  1579. {
  1580. ASN1Free_EntityIdentifier(&(val)->mailListIdentifier);
  1581. if ((val)->o[0] & 0x80) {
  1582. ASN1Free_MLReceiptPolicy(&(val)->mlReceiptPolicy);
  1583. }
  1584. }
  1585. static int ASN1CALL ASN1Enc_SMimeEncryptCert(ASN1encoding_t enc, ASN1uint32_t tag, SMimeEncryptCert *val)
  1586. {
  1587. ASN1uint32_t nLenOff;
  1588. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1589. return 0;
  1590. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->hash).length, ((val)->hash).value))
  1591. return 0;
  1592. if (!ASN1Enc_SMIMECapabilities(enc, 0, &(val)->capabilities))
  1593. return 0;
  1594. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1595. return 0;
  1596. return 1;
  1597. }
  1598. static int ASN1CALL ASN1Dec_SMimeEncryptCert(ASN1decoding_t dec, ASN1uint32_t tag, SMimeEncryptCert *val)
  1599. {
  1600. ASN1decoding_t dd;
  1601. ASN1octet_t *di;
  1602. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1603. return 0;
  1604. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->hash))
  1605. return 0;
  1606. if (!ASN1Dec_SMIMECapabilities(dd, 0, &(val)->capabilities))
  1607. return 0;
  1608. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1609. return 0;
  1610. return 1;
  1611. }
  1612. static void ASN1CALL ASN1Free_SMimeEncryptCert(SMimeEncryptCert *val)
  1613. {
  1614. if (val) {
  1615. ASN1octetstring_free(&(val)->hash);
  1616. ASN1Free_SMIMECapabilities(&(val)->capabilities);
  1617. }
  1618. }
  1619. static int ASN1CALL ASN1Enc_RecipientKeyIdentifier(ASN1encoding_t enc, ASN1uint32_t tag, RecipientKeyIdentifier *val)
  1620. {
  1621. ASN1uint32_t nLenOff;
  1622. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1623. return 0;
  1624. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->subjectKeyIdentifier).length, ((val)->subjectKeyIdentifier).value))
  1625. return 0;
  1626. if ((val)->o[0] & 0x80) {
  1627. if (!ASN1DEREncGeneralizedTime(enc, 0x18, &(val)->date))
  1628. return 0;
  1629. }
  1630. if ((val)->o[0] & 0x40) {
  1631. if (!ASN1Enc_OtherKeyAttribute(enc, 0, &(val)->other))
  1632. return 0;
  1633. }
  1634. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1635. return 0;
  1636. return 1;
  1637. }
  1638. static int ASN1CALL ASN1Dec_RecipientKeyIdentifier(ASN1decoding_t dec, ASN1uint32_t tag, RecipientKeyIdentifier *val)
  1639. {
  1640. ASN1decoding_t dd;
  1641. ASN1octet_t *di;
  1642. ASN1uint32_t t;
  1643. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1644. return 0;
  1645. ZeroMemory((val)->o, 1);
  1646. if (!ASN1BERDecOctetString(dd, 0x4, &(val)->subjectKeyIdentifier))
  1647. return 0;
  1648. ASN1BERDecPeekTag(dd, &t);
  1649. if (t == 0x18) {
  1650. (val)->o[0] |= 0x80;
  1651. if (!ASN1BERDecGeneralizedTime(dd, 0x18, &(val)->date))
  1652. return 0;
  1653. }
  1654. ASN1BERDecPeekTag(dd, &t);
  1655. if (t == 0x10) {
  1656. (val)->o[0] |= 0x40;
  1657. if (!ASN1Dec_OtherKeyAttribute(dd, 0, &(val)->other))
  1658. return 0;
  1659. }
  1660. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1661. return 0;
  1662. return 1;
  1663. }
  1664. static void ASN1CALL ASN1Free_RecipientKeyIdentifier(RecipientKeyIdentifier *val)
  1665. {
  1666. if (val) {
  1667. ASN1octetstring_free(&(val)->subjectKeyIdentifier);
  1668. if ((val)->o[0] & 0x80) {
  1669. }
  1670. if ((val)->o[0] & 0x40) {
  1671. ASN1Free_OtherKeyAttribute(&(val)->other);
  1672. }
  1673. }
  1674. }
  1675. static int ASN1CALL ASN1Enc_SMIMEEncryptionKeyPreference(ASN1encoding_t enc, ASN1uint32_t tag, SMIMEEncryptionKeyPreference *val)
  1676. {
  1677. switch ((val)->choice) {
  1678. case 1:
  1679. if (!ASN1Enc_IssuerAndSerialNumber(enc, 0x80000000, &(val)->u.issuerAndSerialNumber))
  1680. return 0;
  1681. break;
  1682. case 2:
  1683. if (!ASN1Enc_RecipientKeyIdentifier(enc, 0x80000001, &(val)->u.recipientKeyId))
  1684. return 0;
  1685. break;
  1686. case 3:
  1687. if (!ASN1DEREncOctetString(enc, 0x80000002, ((val)->u.subjectAltKeyIdentifier).length, ((val)->u.subjectAltKeyIdentifier).value))
  1688. return 0;
  1689. break;
  1690. }
  1691. return 1;
  1692. }
  1693. static int ASN1CALL ASN1Dec_SMIMEEncryptionKeyPreference(ASN1decoding_t dec, ASN1uint32_t tag, SMIMEEncryptionKeyPreference *val)
  1694. {
  1695. ASN1uint32_t t;
  1696. if (!ASN1BERDecPeekTag(dec, &t))
  1697. return 0;
  1698. switch (t) {
  1699. case 0x80000000:
  1700. (val)->choice = 1;
  1701. if (!ASN1Dec_IssuerAndSerialNumber(dec, 0x80000000, &(val)->u.issuerAndSerialNumber))
  1702. return 0;
  1703. break;
  1704. case 0x80000001:
  1705. (val)->choice = 2;
  1706. if (!ASN1Dec_RecipientKeyIdentifier(dec, 0x80000001, &(val)->u.recipientKeyId))
  1707. return 0;
  1708. break;
  1709. case 0x80000002:
  1710. (val)->choice = 3;
  1711. if (!ASN1BERDecOctetString(dec, 0x80000002, &(val)->u.subjectAltKeyIdentifier))
  1712. return 0;
  1713. break;
  1714. default:
  1715. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  1716. return 0;
  1717. }
  1718. return 1;
  1719. }
  1720. static void ASN1CALL ASN1Free_SMIMEEncryptionKeyPreference(SMIMEEncryptionKeyPreference *val)
  1721. {
  1722. if (val) {
  1723. switch ((val)->choice) {
  1724. case 1:
  1725. ASN1Free_IssuerAndSerialNumber(&(val)->u.issuerAndSerialNumber);
  1726. break;
  1727. case 2:
  1728. ASN1Free_RecipientKeyIdentifier(&(val)->u.recipientKeyId);
  1729. break;
  1730. case 3:
  1731. ASN1octetstring_free(&(val)->u.subjectAltKeyIdentifier);
  1732. break;
  1733. }
  1734. }
  1735. }