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.

6641 lines
208 KiB

  1. /* Copyright (C) Microsoft Corporation, 1996-1999. All rights reserved. */
  2. /* ASN.1 definitions for X509 v3 certificates */
  3. #pragma warning(push,3)
  4. #include <windows.h>
  5. #include "x509.h"
  6. #pragma warning (pop)
  7. // unreferenced inline function has been removed
  8. #pragma warning (disable: 4514)
  9. // unreferenced formal parameter
  10. #pragma warning (disable: 4100)
  11. // assignment within conditional expression
  12. #pragma warning (disable: 4706)
  13. ASN1module_t X509_Module = NULL;
  14. static int ASN1CALL ASN1Enc_EncodedObjectID(ASN1encoding_t enc, ASN1uint32_t tag, EncodedObjectID *val);
  15. static int ASN1CALL ASN1Enc_Bits(ASN1encoding_t enc, ASN1uint32_t tag, Bits *val);
  16. static int ASN1CALL ASN1Enc_IntegerType(ASN1encoding_t enc, ASN1uint32_t tag, IntegerType *val);
  17. static int ASN1CALL ASN1Enc_HugeIntegerType(ASN1encoding_t enc, ASN1uint32_t tag, HugeIntegerType *val);
  18. static int ASN1CALL ASN1Enc_OctetStringType(ASN1encoding_t enc, ASN1uint32_t tag, OctetStringType *val);
  19. static int ASN1CALL ASN1Enc_EnumeratedType(ASN1encoding_t enc, ASN1uint32_t tag, EnumeratedType *val);
  20. static int ASN1CALL ASN1Enc_UtcTime(ASN1encoding_t enc, ASN1uint32_t tag, UtcTime *val);
  21. static int ASN1CALL ASN1Enc_NoticeReference_noticeNumbers(ASN1encoding_t enc, ASN1uint32_t tag, NoticeReference_noticeNumbers *val);
  22. static int ASN1CALL ASN1Enc_AnyString(ASN1encoding_t enc, ASN1uint32_t tag, AnyString *val);
  23. static int ASN1CALL ASN1Enc_AlgorithmIdentifier(ASN1encoding_t enc, ASN1uint32_t tag, AlgorithmIdentifier *val);
  24. static int ASN1CALL ASN1Enc_Name(ASN1encoding_t enc, ASN1uint32_t tag, Name *val);
  25. static int ASN1CALL ASN1Enc_RelativeDistinguishedName(ASN1encoding_t enc, ASN1uint32_t tag, RelativeDistinguishedName *val);
  26. static int ASN1CALL ASN1Enc_AttributeTypeValue(ASN1encoding_t enc, ASN1uint32_t tag, AttributeTypeValue *val);
  27. static int ASN1CALL ASN1Enc_AttributeSetValue(ASN1encoding_t enc, ASN1uint32_t tag, AttributeSetValue *val);
  28. static int ASN1CALL ASN1Enc_Attributes(ASN1encoding_t enc, ASN1uint32_t tag, Attributes *val);
  29. static int ASN1CALL ASN1Enc_RSAPublicKey(ASN1encoding_t enc, ASN1uint32_t tag, RSAPublicKey *val);
  30. static int ASN1CALL ASN1Enc_DSSParameters(ASN1encoding_t enc, ASN1uint32_t tag, DSSParameters *val);
  31. static int ASN1CALL ASN1Enc_DSSSignature(ASN1encoding_t enc, ASN1uint32_t tag, DSSSignature *val);
  32. static int ASN1CALL ASN1Enc_DHParameters(ASN1encoding_t enc, ASN1uint32_t tag, DHParameters *val);
  33. static int ASN1CALL ASN1Enc_X942DhValidationParams(ASN1encoding_t enc, ASN1uint32_t tag, X942DhValidationParams *val);
  34. static int ASN1CALL ASN1Enc_X942DhKeySpecificInfo(ASN1encoding_t enc, ASN1uint32_t tag, X942DhKeySpecificInfo *val);
  35. static int ASN1CALL ASN1Enc_RC2CBCParameters(ASN1encoding_t enc, ASN1uint32_t tag, RC2CBCParameters *val);
  36. static int ASN1CALL ASN1Enc_SMIMECapability(ASN1encoding_t enc, ASN1uint32_t tag, SMIMECapability *val);
  37. static int ASN1CALL ASN1Enc_SMIMECapabilities(ASN1encoding_t enc, ASN1uint32_t tag, SMIMECapabilities *val);
  38. static int ASN1CALL ASN1Enc_SubjectPublicKeyInfo(ASN1encoding_t enc, ASN1uint32_t tag, SubjectPublicKeyInfo *val);
  39. static int ASN1CALL ASN1Enc_ChoiceOfTime(ASN1encoding_t enc, ASN1uint32_t tag, ChoiceOfTime *val);
  40. static int ASN1CALL ASN1Enc_Validity(ASN1encoding_t enc, ASN1uint32_t tag, Validity *val);
  41. static int ASN1CALL ASN1Enc_Extensions(ASN1encoding_t enc, ASN1uint32_t tag, Extensions *val);
  42. static int ASN1CALL ASN1Enc_Extension(ASN1encoding_t enc, ASN1uint32_t tag, Extension *val);
  43. static int ASN1CALL ASN1Enc_SignedContent(ASN1encoding_t enc, ASN1uint32_t tag, SignedContent *val);
  44. static int ASN1CALL ASN1Enc_RevokedCertificates(ASN1encoding_t enc, ASN1uint32_t tag, RevokedCertificates *val);
  45. static int ASN1CALL ASN1Enc_CRLEntry(ASN1encoding_t enc, ASN1uint32_t tag, CRLEntry *val);
  46. static int ASN1CALL ASN1Enc_CertificationRequestInfo(ASN1encoding_t enc, ASN1uint32_t tag, CertificationRequestInfo *val);
  47. static int ASN1CALL ASN1Enc_CertificationRequestInfoDecode(ASN1encoding_t enc, ASN1uint32_t tag, CertificationRequestInfoDecode *val);
  48. static int ASN1CALL ASN1Enc_KeygenRequestInfo(ASN1encoding_t enc, ASN1uint32_t tag, KeygenRequestInfo *val);
  49. static int ASN1CALL ASN1Enc_AuthorityKeyId(ASN1encoding_t enc, ASN1uint32_t tag, AuthorityKeyId *val);
  50. static int ASN1CALL ASN1Enc_PrivateKeyValidity(ASN1encoding_t enc, ASN1uint32_t tag, PrivateKeyValidity *val);
  51. static int ASN1CALL ASN1Enc_CertPolicySet(ASN1encoding_t enc, ASN1uint32_t tag, CertPolicySet *val);
  52. static int ASN1CALL ASN1Enc_CertPolicyId(ASN1encoding_t enc, ASN1uint32_t tag, CertPolicyId *val);
  53. static int ASN1CALL ASN1Enc_AltNames(ASN1encoding_t enc, ASN1uint32_t tag, AltNames *val);
  54. static int ASN1CALL ASN1Enc_GeneralNames(ASN1encoding_t enc, ASN1uint32_t tag, GeneralNames *val);
  55. static int ASN1CALL ASN1Enc_OtherName(ASN1encoding_t enc, ASN1uint32_t tag, OtherName *val);
  56. static int ASN1CALL ASN1Enc_EDIPartyName(ASN1encoding_t enc, ASN1uint32_t tag, EDIPartyName *val);
  57. static int ASN1CALL ASN1Enc_SubtreesConstraint(ASN1encoding_t enc, ASN1uint32_t tag, SubtreesConstraint *val);
  58. static int ASN1CALL ASN1Enc_BasicConstraints2(ASN1encoding_t enc, ASN1uint32_t tag, BasicConstraints2 *val);
  59. static int ASN1CALL ASN1Enc_CertificatePolicies(ASN1encoding_t enc, ASN1uint32_t tag, CertificatePolicies *val);
  60. static int ASN1CALL ASN1Enc_PolicyQualifiers(ASN1encoding_t enc, ASN1uint32_t tag, PolicyQualifiers *val);
  61. static int ASN1CALL ASN1Enc_PolicyQualifierInfo(ASN1encoding_t enc, ASN1uint32_t tag, PolicyQualifierInfo *val);
  62. static int ASN1CALL ASN1Enc_NoticeReference(ASN1encoding_t enc, ASN1uint32_t tag, NoticeReference *val);
  63. static int ASN1CALL ASN1Enc_DisplayText(ASN1encoding_t enc, ASN1uint32_t tag, DisplayText *val);
  64. static int ASN1CALL ASN1Enc_CertificatePolicies95(ASN1encoding_t enc, ASN1uint32_t tag, CertificatePolicies95 *val);
  65. static int ASN1CALL ASN1Enc_CpsURLs(ASN1encoding_t enc, ASN1uint32_t tag, CpsURLs *val);
  66. static int ASN1CALL ASN1Enc_AuthorityKeyId2(ASN1encoding_t enc, ASN1uint32_t tag, AuthorityKeyId2 *val);
  67. static int ASN1CALL ASN1Enc_AuthorityInfoAccess(ASN1encoding_t enc, ASN1uint32_t tag, AuthorityInfoAccess *val);
  68. static int ASN1CALL ASN1Enc_CRLDistributionPoints(ASN1encoding_t enc, ASN1uint32_t tag, CRLDistributionPoints *val);
  69. static int ASN1CALL ASN1Enc_DistributionPointName(ASN1encoding_t enc, ASN1uint32_t tag, DistributionPointName *val);
  70. static int ASN1CALL ASN1Enc_ContentInfo(ASN1encoding_t enc, ASN1uint32_t tag, ContentInfo *val);
  71. static int ASN1CALL ASN1Enc_SeqOfAny(ASN1encoding_t enc, ASN1uint32_t tag, SeqOfAny *val);
  72. static int ASN1CALL ASN1Enc_TimeStampRequest(ASN1encoding_t enc, ASN1uint32_t tag, TimeStampRequest *val);
  73. static int ASN1CALL ASN1Enc_ContentInfoOTS(ASN1encoding_t enc, ASN1uint32_t tag, ContentInfoOTS *val);
  74. static int ASN1CALL ASN1Enc_TimeStampRequestOTS(ASN1encoding_t enc, ASN1uint32_t tag, TimeStampRequestOTS *val);
  75. static int ASN1CALL ASN1Enc_EnhancedKeyUsage(ASN1encoding_t enc, ASN1uint32_t tag, EnhancedKeyUsage *val);
  76. static int ASN1CALL ASN1Enc_SubjectUsage(ASN1encoding_t enc, ASN1uint32_t tag, SubjectUsage *val);
  77. static int ASN1CALL ASN1Enc_TrustedSubjects(ASN1encoding_t enc, ASN1uint32_t tag, TrustedSubjects *val);
  78. static int ASN1CALL ASN1Enc_TrustedSubject(ASN1encoding_t enc, ASN1uint32_t tag, TrustedSubject *val);
  79. static int ASN1CALL ASN1Enc_EnrollmentNameValuePair(ASN1encoding_t enc, ASN1uint32_t tag, EnrollmentNameValuePair *val);
  80. static int ASN1CALL ASN1Enc_CSPProvider(ASN1encoding_t enc, ASN1uint32_t tag, CSPProvider *val);
  81. static int ASN1CALL ASN1Enc_CertificatePair(ASN1encoding_t enc, ASN1uint32_t tag, CertificatePair *val);
  82. static int ASN1CALL ASN1Enc_GeneralSubtrees(ASN1encoding_t enc, ASN1uint32_t tag, GeneralSubtrees *val);
  83. static int ASN1CALL ASN1Enc_IssuingDistributionPoint(ASN1encoding_t enc, ASN1uint32_t tag, IssuingDistributionPoint *val);
  84. static int ASN1CALL ASN1Enc_CrossCertDistPointNames(ASN1encoding_t enc, ASN1uint32_t tag, CrossCertDistPointNames *val);
  85. static int ASN1CALL ASN1Enc_PolicyMappings(ASN1encoding_t enc, ASN1uint32_t tag, PolicyMappings *val);
  86. static int ASN1CALL ASN1Enc_PolicyMapping(ASN1encoding_t enc, ASN1uint32_t tag, PolicyMapping *val);
  87. static int ASN1CALL ASN1Enc_PolicyConstraints(ASN1encoding_t enc, ASN1uint32_t tag, PolicyConstraints *val);
  88. static int ASN1CALL ASN1Enc_ControlSequence(ASN1encoding_t enc, ASN1uint32_t tag, ControlSequence *val);
  89. static int ASN1CALL ASN1Enc_ReqSequence(ASN1encoding_t enc, ASN1uint32_t tag, ReqSequence *val);
  90. static int ASN1CALL ASN1Enc_CmsSequence(ASN1encoding_t enc, ASN1uint32_t tag, CmsSequence *val);
  91. static int ASN1CALL ASN1Enc_OtherMsgSequence(ASN1encoding_t enc, ASN1uint32_t tag, OtherMsgSequence *val);
  92. static int ASN1CALL ASN1Enc_BodyPartIDSequence(ASN1encoding_t enc, ASN1uint32_t tag, BodyPartIDSequence *val);
  93. static int ASN1CALL ASN1Enc_TaggedAttribute(ASN1encoding_t enc, ASN1uint32_t tag, TaggedAttribute *val);
  94. static int ASN1CALL ASN1Enc_TaggedCertificationRequest(ASN1encoding_t enc, ASN1uint32_t tag, TaggedCertificationRequest *val);
  95. static int ASN1CALL ASN1Enc_TaggedContentInfo(ASN1encoding_t enc, ASN1uint32_t tag, TaggedContentInfo *val);
  96. static int ASN1CALL ASN1Enc_TaggedOtherMsg(ASN1encoding_t enc, ASN1uint32_t tag, TaggedOtherMsg *val);
  97. static int ASN1CALL ASN1Enc_PendInfo(ASN1encoding_t enc, ASN1uint32_t tag, PendInfo *val);
  98. static int ASN1CALL ASN1Enc_CmcAddExtensions(ASN1encoding_t enc, ASN1uint32_t tag, CmcAddExtensions *val);
  99. static int ASN1CALL ASN1Enc_CmcAddAttributes(ASN1encoding_t enc, ASN1uint32_t tag, CmcAddAttributes *val);
  100. static int ASN1CALL ASN1Enc_CertificateTemplate(ASN1encoding_t enc, ASN1uint32_t tag, CertificateTemplate *val);
  101. static int ASN1CALL ASN1Enc_CmcStatusInfo_otherInfo(ASN1encoding_t enc, ASN1uint32_t tag, CmcStatusInfo_otherInfo *val);
  102. static int ASN1CALL ASN1Enc_CpsURLs_Seq(ASN1encoding_t enc, ASN1uint32_t tag, CpsURLs_Seq *val);
  103. static int ASN1CALL ASN1Enc_Attribute(ASN1encoding_t enc, ASN1uint32_t tag, Attribute *val);
  104. static int ASN1CALL ASN1Enc_X942DhParameters(ASN1encoding_t enc, ASN1uint32_t tag, X942DhParameters *val);
  105. static int ASN1CALL ASN1Enc_X942DhOtherInfo(ASN1encoding_t enc, ASN1uint32_t tag, X942DhOtherInfo *val);
  106. static int ASN1CALL ASN1Enc_CertificateToBeSigned(ASN1encoding_t enc, ASN1uint32_t tag, CertificateToBeSigned *val);
  107. static int ASN1CALL ASN1Enc_CertificateRevocationListToBeSigned(ASN1encoding_t enc, ASN1uint32_t tag, CertificateRevocationListToBeSigned *val);
  108. static int ASN1CALL ASN1Enc_KeyAttributes(ASN1encoding_t enc, ASN1uint32_t tag, KeyAttributes *val);
  109. static int ASN1CALL ASN1Enc_KeyUsageRestriction(ASN1encoding_t enc, ASN1uint32_t tag, KeyUsageRestriction *val);
  110. static int ASN1CALL ASN1Enc_GeneralName(ASN1encoding_t enc, ASN1uint32_t tag, GeneralName *val);
  111. static int ASN1CALL ASN1Enc_BasicConstraints(ASN1encoding_t enc, ASN1uint32_t tag, BasicConstraints *val);
  112. static int ASN1CALL ASN1Enc_PolicyInformation(ASN1encoding_t enc, ASN1uint32_t tag, PolicyInformation *val);
  113. static int ASN1CALL ASN1Enc_UserNotice(ASN1encoding_t enc, ASN1uint32_t tag, UserNotice *val);
  114. static int ASN1CALL ASN1Enc_VerisignQualifier1(ASN1encoding_t enc, ASN1uint32_t tag, VerisignQualifier1 *val);
  115. static int ASN1CALL ASN1Enc_AccessDescription(ASN1encoding_t enc, ASN1uint32_t tag, AccessDescription *val);
  116. static int ASN1CALL ASN1Enc_DistributionPoint(ASN1encoding_t enc, ASN1uint32_t tag, DistributionPoint *val);
  117. static int ASN1CALL ASN1Enc_ContentInfoSeqOfAny(ASN1encoding_t enc, ASN1uint32_t tag, ContentInfoSeqOfAny *val);
  118. static int ASN1CALL ASN1Enc_CertificateTrustList(ASN1encoding_t enc, ASN1uint32_t tag, CertificateTrustList *val);
  119. static int ASN1CALL ASN1Enc_NameConstraints(ASN1encoding_t enc, ASN1uint32_t tag, NameConstraints *val);
  120. static int ASN1CALL ASN1Enc_GeneralSubtree(ASN1encoding_t enc, ASN1uint32_t tag, GeneralSubtree *val);
  121. static int ASN1CALL ASN1Enc_CrossCertDistPoints(ASN1encoding_t enc, ASN1uint32_t tag, CrossCertDistPoints *val);
  122. static int ASN1CALL ASN1Enc_CmcData(ASN1encoding_t enc, ASN1uint32_t tag, CmcData *val);
  123. static int ASN1CALL ASN1Enc_CmcResponseBody(ASN1encoding_t enc, ASN1uint32_t tag, CmcResponseBody *val);
  124. static int ASN1CALL ASN1Enc_TaggedRequest(ASN1encoding_t enc, ASN1uint32_t tag, TaggedRequest *val);
  125. static int ASN1CALL ASN1Enc_CmcStatusInfo(ASN1encoding_t enc, ASN1uint32_t tag, CmcStatusInfo *val);
  126. static int ASN1CALL ASN1Dec_EncodedObjectID(ASN1decoding_t dec, ASN1uint32_t tag, EncodedObjectID *val);
  127. static int ASN1CALL ASN1Dec_Bits(ASN1decoding_t dec, ASN1uint32_t tag, Bits *val);
  128. static int ASN1CALL ASN1Dec_IntegerType(ASN1decoding_t dec, ASN1uint32_t tag, IntegerType *val);
  129. static int ASN1CALL ASN1Dec_HugeIntegerType(ASN1decoding_t dec, ASN1uint32_t tag, HugeIntegerType *val);
  130. static int ASN1CALL ASN1Dec_OctetStringType(ASN1decoding_t dec, ASN1uint32_t tag, OctetStringType *val);
  131. static int ASN1CALL ASN1Dec_EnumeratedType(ASN1decoding_t dec, ASN1uint32_t tag, EnumeratedType *val);
  132. static int ASN1CALL ASN1Dec_UtcTime(ASN1decoding_t dec, ASN1uint32_t tag, UtcTime *val);
  133. static int ASN1CALL ASN1Dec_NoticeReference_noticeNumbers(ASN1decoding_t dec, ASN1uint32_t tag, NoticeReference_noticeNumbers *val);
  134. static int ASN1CALL ASN1Dec_AnyString(ASN1decoding_t dec, ASN1uint32_t tag, AnyString *val);
  135. static int ASN1CALL ASN1Dec_AlgorithmIdentifier(ASN1decoding_t dec, ASN1uint32_t tag, AlgorithmIdentifier *val);
  136. static int ASN1CALL ASN1Dec_Name(ASN1decoding_t dec, ASN1uint32_t tag, Name *val);
  137. static int ASN1CALL ASN1Dec_RelativeDistinguishedName(ASN1decoding_t dec, ASN1uint32_t tag, RelativeDistinguishedName *val);
  138. static int ASN1CALL ASN1Dec_AttributeTypeValue(ASN1decoding_t dec, ASN1uint32_t tag, AttributeTypeValue *val);
  139. static int ASN1CALL ASN1Dec_AttributeSetValue(ASN1decoding_t dec, ASN1uint32_t tag, AttributeSetValue *val);
  140. static int ASN1CALL ASN1Dec_Attributes(ASN1decoding_t dec, ASN1uint32_t tag, Attributes *val);
  141. static int ASN1CALL ASN1Dec_RSAPublicKey(ASN1decoding_t dec, ASN1uint32_t tag, RSAPublicKey *val);
  142. static int ASN1CALL ASN1Dec_DSSParameters(ASN1decoding_t dec, ASN1uint32_t tag, DSSParameters *val);
  143. static int ASN1CALL ASN1Dec_DSSSignature(ASN1decoding_t dec, ASN1uint32_t tag, DSSSignature *val);
  144. static int ASN1CALL ASN1Dec_DHParameters(ASN1decoding_t dec, ASN1uint32_t tag, DHParameters *val);
  145. static int ASN1CALL ASN1Dec_X942DhValidationParams(ASN1decoding_t dec, ASN1uint32_t tag, X942DhValidationParams *val);
  146. static int ASN1CALL ASN1Dec_X942DhKeySpecificInfo(ASN1decoding_t dec, ASN1uint32_t tag, X942DhKeySpecificInfo *val);
  147. static int ASN1CALL ASN1Dec_RC2CBCParameters(ASN1decoding_t dec, ASN1uint32_t tag, RC2CBCParameters *val);
  148. static int ASN1CALL ASN1Dec_SMIMECapability(ASN1decoding_t dec, ASN1uint32_t tag, SMIMECapability *val);
  149. static int ASN1CALL ASN1Dec_SMIMECapabilities(ASN1decoding_t dec, ASN1uint32_t tag, SMIMECapabilities *val);
  150. static int ASN1CALL ASN1Dec_SubjectPublicKeyInfo(ASN1decoding_t dec, ASN1uint32_t tag, SubjectPublicKeyInfo *val);
  151. static int ASN1CALL ASN1Dec_ChoiceOfTime(ASN1decoding_t dec, ASN1uint32_t tag, ChoiceOfTime *val);
  152. static int ASN1CALL ASN1Dec_Validity(ASN1decoding_t dec, ASN1uint32_t tag, Validity *val);
  153. static int ASN1CALL ASN1Dec_Extensions(ASN1decoding_t dec, ASN1uint32_t tag, Extensions *val);
  154. static int ASN1CALL ASN1Dec_Extension(ASN1decoding_t dec, ASN1uint32_t tag, Extension *val);
  155. static int ASN1CALL ASN1Dec_SignedContent(ASN1decoding_t dec, ASN1uint32_t tag, SignedContent *val);
  156. static int ASN1CALL ASN1Dec_RevokedCertificates(ASN1decoding_t dec, ASN1uint32_t tag, RevokedCertificates *val);
  157. static int ASN1CALL ASN1Dec_CRLEntry(ASN1decoding_t dec, ASN1uint32_t tag, CRLEntry *val);
  158. static int ASN1CALL ASN1Dec_CertificationRequestInfo(ASN1decoding_t dec, ASN1uint32_t tag, CertificationRequestInfo *val);
  159. static int ASN1CALL ASN1Dec_CertificationRequestInfoDecode(ASN1decoding_t dec, ASN1uint32_t tag, CertificationRequestInfoDecode *val);
  160. static int ASN1CALL ASN1Dec_KeygenRequestInfo(ASN1decoding_t dec, ASN1uint32_t tag, KeygenRequestInfo *val);
  161. static int ASN1CALL ASN1Dec_AuthorityKeyId(ASN1decoding_t dec, ASN1uint32_t tag, AuthorityKeyId *val);
  162. static int ASN1CALL ASN1Dec_PrivateKeyValidity(ASN1decoding_t dec, ASN1uint32_t tag, PrivateKeyValidity *val);
  163. static int ASN1CALL ASN1Dec_CertPolicySet(ASN1decoding_t dec, ASN1uint32_t tag, CertPolicySet *val);
  164. static int ASN1CALL ASN1Dec_CertPolicyId(ASN1decoding_t dec, ASN1uint32_t tag, CertPolicyId *val);
  165. static int ASN1CALL ASN1Dec_AltNames(ASN1decoding_t dec, ASN1uint32_t tag, AltNames *val);
  166. static int ASN1CALL ASN1Dec_GeneralNames(ASN1decoding_t dec, ASN1uint32_t tag, GeneralNames *val);
  167. static int ASN1CALL ASN1Dec_OtherName(ASN1decoding_t dec, ASN1uint32_t tag, OtherName *val);
  168. static int ASN1CALL ASN1Dec_EDIPartyName(ASN1decoding_t dec, ASN1uint32_t tag, EDIPartyName *val);
  169. static int ASN1CALL ASN1Dec_SubtreesConstraint(ASN1decoding_t dec, ASN1uint32_t tag, SubtreesConstraint *val);
  170. static int ASN1CALL ASN1Dec_BasicConstraints2(ASN1decoding_t dec, ASN1uint32_t tag, BasicConstraints2 *val);
  171. static int ASN1CALL ASN1Dec_CertificatePolicies(ASN1decoding_t dec, ASN1uint32_t tag, CertificatePolicies *val);
  172. static int ASN1CALL ASN1Dec_PolicyQualifiers(ASN1decoding_t dec, ASN1uint32_t tag, PolicyQualifiers *val);
  173. static int ASN1CALL ASN1Dec_PolicyQualifierInfo(ASN1decoding_t dec, ASN1uint32_t tag, PolicyQualifierInfo *val);
  174. static int ASN1CALL ASN1Dec_NoticeReference(ASN1decoding_t dec, ASN1uint32_t tag, NoticeReference *val);
  175. static int ASN1CALL ASN1Dec_DisplayText(ASN1decoding_t dec, ASN1uint32_t tag, DisplayText *val);
  176. static int ASN1CALL ASN1Dec_CertificatePolicies95(ASN1decoding_t dec, ASN1uint32_t tag, CertificatePolicies95 *val);
  177. static int ASN1CALL ASN1Dec_CpsURLs(ASN1decoding_t dec, ASN1uint32_t tag, CpsURLs *val);
  178. static int ASN1CALL ASN1Dec_AuthorityKeyId2(ASN1decoding_t dec, ASN1uint32_t tag, AuthorityKeyId2 *val);
  179. static int ASN1CALL ASN1Dec_AuthorityInfoAccess(ASN1decoding_t dec, ASN1uint32_t tag, AuthorityInfoAccess *val);
  180. static int ASN1CALL ASN1Dec_CRLDistributionPoints(ASN1decoding_t dec, ASN1uint32_t tag, CRLDistributionPoints *val);
  181. static int ASN1CALL ASN1Dec_DistributionPointName(ASN1decoding_t dec, ASN1uint32_t tag, DistributionPointName *val);
  182. static int ASN1CALL ASN1Dec_ContentInfo(ASN1decoding_t dec, ASN1uint32_t tag, ContentInfo *val);
  183. static int ASN1CALL ASN1Dec_SeqOfAny(ASN1decoding_t dec, ASN1uint32_t tag, SeqOfAny *val);
  184. static int ASN1CALL ASN1Dec_TimeStampRequest(ASN1decoding_t dec, ASN1uint32_t tag, TimeStampRequest *val);
  185. static int ASN1CALL ASN1Dec_ContentInfoOTS(ASN1decoding_t dec, ASN1uint32_t tag, ContentInfoOTS *val);
  186. static int ASN1CALL ASN1Dec_TimeStampRequestOTS(ASN1decoding_t dec, ASN1uint32_t tag, TimeStampRequestOTS *val);
  187. static int ASN1CALL ASN1Dec_EnhancedKeyUsage(ASN1decoding_t dec, ASN1uint32_t tag, EnhancedKeyUsage *val);
  188. static int ASN1CALL ASN1Dec_SubjectUsage(ASN1decoding_t dec, ASN1uint32_t tag, SubjectUsage *val);
  189. static int ASN1CALL ASN1Dec_TrustedSubjects(ASN1decoding_t dec, ASN1uint32_t tag, TrustedSubjects *val);
  190. static int ASN1CALL ASN1Dec_TrustedSubject(ASN1decoding_t dec, ASN1uint32_t tag, TrustedSubject *val);
  191. static int ASN1CALL ASN1Dec_EnrollmentNameValuePair(ASN1decoding_t dec, ASN1uint32_t tag, EnrollmentNameValuePair *val);
  192. static int ASN1CALL ASN1Dec_CSPProvider(ASN1decoding_t dec, ASN1uint32_t tag, CSPProvider *val);
  193. static int ASN1CALL ASN1Dec_CertificatePair(ASN1decoding_t dec, ASN1uint32_t tag, CertificatePair *val);
  194. static int ASN1CALL ASN1Dec_GeneralSubtrees(ASN1decoding_t dec, ASN1uint32_t tag, GeneralSubtrees *val);
  195. static int ASN1CALL ASN1Dec_IssuingDistributionPoint(ASN1decoding_t dec, ASN1uint32_t tag, IssuingDistributionPoint *val);
  196. static int ASN1CALL ASN1Dec_CrossCertDistPointNames(ASN1decoding_t dec, ASN1uint32_t tag, CrossCertDistPointNames *val);
  197. static int ASN1CALL ASN1Dec_PolicyMappings(ASN1decoding_t dec, ASN1uint32_t tag, PolicyMappings *val);
  198. static int ASN1CALL ASN1Dec_PolicyMapping(ASN1decoding_t dec, ASN1uint32_t tag, PolicyMapping *val);
  199. static int ASN1CALL ASN1Dec_PolicyConstraints(ASN1decoding_t dec, ASN1uint32_t tag, PolicyConstraints *val);
  200. static int ASN1CALL ASN1Dec_ControlSequence(ASN1decoding_t dec, ASN1uint32_t tag, ControlSequence *val);
  201. static int ASN1CALL ASN1Dec_ReqSequence(ASN1decoding_t dec, ASN1uint32_t tag, ReqSequence *val);
  202. static int ASN1CALL ASN1Dec_CmsSequence(ASN1decoding_t dec, ASN1uint32_t tag, CmsSequence *val);
  203. static int ASN1CALL ASN1Dec_OtherMsgSequence(ASN1decoding_t dec, ASN1uint32_t tag, OtherMsgSequence *val);
  204. static int ASN1CALL ASN1Dec_BodyPartIDSequence(ASN1decoding_t dec, ASN1uint32_t tag, BodyPartIDSequence *val);
  205. static int ASN1CALL ASN1Dec_TaggedAttribute(ASN1decoding_t dec, ASN1uint32_t tag, TaggedAttribute *val);
  206. static int ASN1CALL ASN1Dec_TaggedCertificationRequest(ASN1decoding_t dec, ASN1uint32_t tag, TaggedCertificationRequest *val);
  207. static int ASN1CALL ASN1Dec_TaggedContentInfo(ASN1decoding_t dec, ASN1uint32_t tag, TaggedContentInfo *val);
  208. static int ASN1CALL ASN1Dec_TaggedOtherMsg(ASN1decoding_t dec, ASN1uint32_t tag, TaggedOtherMsg *val);
  209. static int ASN1CALL ASN1Dec_PendInfo(ASN1decoding_t dec, ASN1uint32_t tag, PendInfo *val);
  210. static int ASN1CALL ASN1Dec_CmcAddExtensions(ASN1decoding_t dec, ASN1uint32_t tag, CmcAddExtensions *val);
  211. static int ASN1CALL ASN1Dec_CmcAddAttributes(ASN1decoding_t dec, ASN1uint32_t tag, CmcAddAttributes *val);
  212. static int ASN1CALL ASN1Dec_CertificateTemplate(ASN1decoding_t dec, ASN1uint32_t tag, CertificateTemplate *val);
  213. static int ASN1CALL ASN1Dec_CmcStatusInfo_otherInfo(ASN1decoding_t dec, ASN1uint32_t tag, CmcStatusInfo_otherInfo *val);
  214. static int ASN1CALL ASN1Dec_CpsURLs_Seq(ASN1decoding_t dec, ASN1uint32_t tag, CpsURLs_Seq *val);
  215. static int ASN1CALL ASN1Dec_Attribute(ASN1decoding_t dec, ASN1uint32_t tag, Attribute *val);
  216. static int ASN1CALL ASN1Dec_X942DhParameters(ASN1decoding_t dec, ASN1uint32_t tag, X942DhParameters *val);
  217. static int ASN1CALL ASN1Dec_X942DhOtherInfo(ASN1decoding_t dec, ASN1uint32_t tag, X942DhOtherInfo *val);
  218. static int ASN1CALL ASN1Dec_CertificateToBeSigned(ASN1decoding_t dec, ASN1uint32_t tag, CertificateToBeSigned *val);
  219. static int ASN1CALL ASN1Dec_CertificateRevocationListToBeSigned(ASN1decoding_t dec, ASN1uint32_t tag, CertificateRevocationListToBeSigned *val);
  220. static int ASN1CALL ASN1Dec_KeyAttributes(ASN1decoding_t dec, ASN1uint32_t tag, KeyAttributes *val);
  221. static int ASN1CALL ASN1Dec_KeyUsageRestriction(ASN1decoding_t dec, ASN1uint32_t tag, KeyUsageRestriction *val);
  222. static int ASN1CALL ASN1Dec_GeneralName(ASN1decoding_t dec, ASN1uint32_t tag, GeneralName *val);
  223. static int ASN1CALL ASN1Dec_BasicConstraints(ASN1decoding_t dec, ASN1uint32_t tag, BasicConstraints *val);
  224. static int ASN1CALL ASN1Dec_PolicyInformation(ASN1decoding_t dec, ASN1uint32_t tag, PolicyInformation *val);
  225. static int ASN1CALL ASN1Dec_UserNotice(ASN1decoding_t dec, ASN1uint32_t tag, UserNotice *val);
  226. static int ASN1CALL ASN1Dec_VerisignQualifier1(ASN1decoding_t dec, ASN1uint32_t tag, VerisignQualifier1 *val);
  227. static int ASN1CALL ASN1Dec_AccessDescription(ASN1decoding_t dec, ASN1uint32_t tag, AccessDescription *val);
  228. static int ASN1CALL ASN1Dec_DistributionPoint(ASN1decoding_t dec, ASN1uint32_t tag, DistributionPoint *val);
  229. static int ASN1CALL ASN1Dec_ContentInfoSeqOfAny(ASN1decoding_t dec, ASN1uint32_t tag, ContentInfoSeqOfAny *val);
  230. static int ASN1CALL ASN1Dec_CertificateTrustList(ASN1decoding_t dec, ASN1uint32_t tag, CertificateTrustList *val);
  231. static int ASN1CALL ASN1Dec_NameConstraints(ASN1decoding_t dec, ASN1uint32_t tag, NameConstraints *val);
  232. static int ASN1CALL ASN1Dec_GeneralSubtree(ASN1decoding_t dec, ASN1uint32_t tag, GeneralSubtree *val);
  233. static int ASN1CALL ASN1Dec_CrossCertDistPoints(ASN1decoding_t dec, ASN1uint32_t tag, CrossCertDistPoints *val);
  234. static int ASN1CALL ASN1Dec_CmcData(ASN1decoding_t dec, ASN1uint32_t tag, CmcData *val);
  235. static int ASN1CALL ASN1Dec_CmcResponseBody(ASN1decoding_t dec, ASN1uint32_t tag, CmcResponseBody *val);
  236. static int ASN1CALL ASN1Dec_TaggedRequest(ASN1decoding_t dec, ASN1uint32_t tag, TaggedRequest *val);
  237. static int ASN1CALL ASN1Dec_CmcStatusInfo(ASN1decoding_t dec, ASN1uint32_t tag, CmcStatusInfo *val);
  238. static void ASN1CALL ASN1Free_EncodedObjectID(EncodedObjectID *val);
  239. static void ASN1CALL ASN1Free_Bits(Bits *val);
  240. static void ASN1CALL ASN1Free_HugeIntegerType(HugeIntegerType *val);
  241. static void ASN1CALL ASN1Free_OctetStringType(OctetStringType *val);
  242. static void ASN1CALL ASN1Free_UtcTime(UtcTime *val);
  243. static void ASN1CALL ASN1Free_NoticeReference_noticeNumbers(NoticeReference_noticeNumbers *val);
  244. static void ASN1CALL ASN1Free_AnyString(AnyString *val);
  245. static void ASN1CALL ASN1Free_AlgorithmIdentifier(AlgorithmIdentifier *val);
  246. static void ASN1CALL ASN1Free_Name(Name *val);
  247. static void ASN1CALL ASN1Free_RelativeDistinguishedName(RelativeDistinguishedName *val);
  248. static void ASN1CALL ASN1Free_AttributeTypeValue(AttributeTypeValue *val);
  249. static void ASN1CALL ASN1Free_AttributeSetValue(AttributeSetValue *val);
  250. static void ASN1CALL ASN1Free_Attributes(Attributes *val);
  251. static void ASN1CALL ASN1Free_RSAPublicKey(RSAPublicKey *val);
  252. static void ASN1CALL ASN1Free_DSSParameters(DSSParameters *val);
  253. static void ASN1CALL ASN1Free_DSSSignature(DSSSignature *val);
  254. static void ASN1CALL ASN1Free_DHParameters(DHParameters *val);
  255. static void ASN1CALL ASN1Free_X942DhValidationParams(X942DhValidationParams *val);
  256. static void ASN1CALL ASN1Free_X942DhKeySpecificInfo(X942DhKeySpecificInfo *val);
  257. static void ASN1CALL ASN1Free_RC2CBCParameters(RC2CBCParameters *val);
  258. static void ASN1CALL ASN1Free_SMIMECapability(SMIMECapability *val);
  259. static void ASN1CALL ASN1Free_SMIMECapabilities(SMIMECapabilities *val);
  260. static void ASN1CALL ASN1Free_SubjectPublicKeyInfo(SubjectPublicKeyInfo *val);
  261. static void ASN1CALL ASN1Free_ChoiceOfTime(ChoiceOfTime *val);
  262. static void ASN1CALL ASN1Free_Validity(Validity *val);
  263. static void ASN1CALL ASN1Free_Extensions(Extensions *val);
  264. static void ASN1CALL ASN1Free_Extension(Extension *val);
  265. static void ASN1CALL ASN1Free_SignedContent(SignedContent *val);
  266. static void ASN1CALL ASN1Free_RevokedCertificates(RevokedCertificates *val);
  267. static void ASN1CALL ASN1Free_CRLEntry(CRLEntry *val);
  268. static void ASN1CALL ASN1Free_CertificationRequestInfo(CertificationRequestInfo *val);
  269. static void ASN1CALL ASN1Free_CertificationRequestInfoDecode(CertificationRequestInfoDecode *val);
  270. static void ASN1CALL ASN1Free_KeygenRequestInfo(KeygenRequestInfo *val);
  271. static void ASN1CALL ASN1Free_AuthorityKeyId(AuthorityKeyId *val);
  272. static void ASN1CALL ASN1Free_PrivateKeyValidity(PrivateKeyValidity *val);
  273. static void ASN1CALL ASN1Free_CertPolicySet(CertPolicySet *val);
  274. static void ASN1CALL ASN1Free_CertPolicyId(CertPolicyId *val);
  275. static void ASN1CALL ASN1Free_AltNames(AltNames *val);
  276. static void ASN1CALL ASN1Free_GeneralNames(GeneralNames *val);
  277. static void ASN1CALL ASN1Free_OtherName(OtherName *val);
  278. static void ASN1CALL ASN1Free_EDIPartyName(EDIPartyName *val);
  279. static void ASN1CALL ASN1Free_SubtreesConstraint(SubtreesConstraint *val);
  280. static void ASN1CALL ASN1Free_CertificatePolicies(CertificatePolicies *val);
  281. static void ASN1CALL ASN1Free_PolicyQualifiers(PolicyQualifiers *val);
  282. static void ASN1CALL ASN1Free_PolicyQualifierInfo(PolicyQualifierInfo *val);
  283. static void ASN1CALL ASN1Free_NoticeReference(NoticeReference *val);
  284. static void ASN1CALL ASN1Free_DisplayText(DisplayText *val);
  285. static void ASN1CALL ASN1Free_CertificatePolicies95(CertificatePolicies95 *val);
  286. static void ASN1CALL ASN1Free_CpsURLs(CpsURLs *val);
  287. static void ASN1CALL ASN1Free_AuthorityKeyId2(AuthorityKeyId2 *val);
  288. static void ASN1CALL ASN1Free_AuthorityInfoAccess(AuthorityInfoAccess *val);
  289. static void ASN1CALL ASN1Free_CRLDistributionPoints(CRLDistributionPoints *val);
  290. static void ASN1CALL ASN1Free_DistributionPointName(DistributionPointName *val);
  291. static void ASN1CALL ASN1Free_ContentInfo(ContentInfo *val);
  292. static void ASN1CALL ASN1Free_SeqOfAny(SeqOfAny *val);
  293. static void ASN1CALL ASN1Free_TimeStampRequest(TimeStampRequest *val);
  294. static void ASN1CALL ASN1Free_ContentInfoOTS(ContentInfoOTS *val);
  295. static void ASN1CALL ASN1Free_TimeStampRequestOTS(TimeStampRequestOTS *val);
  296. static void ASN1CALL ASN1Free_EnhancedKeyUsage(EnhancedKeyUsage *val);
  297. static void ASN1CALL ASN1Free_SubjectUsage(SubjectUsage *val);
  298. static void ASN1CALL ASN1Free_TrustedSubjects(TrustedSubjects *val);
  299. static void ASN1CALL ASN1Free_TrustedSubject(TrustedSubject *val);
  300. static void ASN1CALL ASN1Free_EnrollmentNameValuePair(EnrollmentNameValuePair *val);
  301. static void ASN1CALL ASN1Free_CSPProvider(CSPProvider *val);
  302. static void ASN1CALL ASN1Free_CertificatePair(CertificatePair *val);
  303. static void ASN1CALL ASN1Free_GeneralSubtrees(GeneralSubtrees *val);
  304. static void ASN1CALL ASN1Free_IssuingDistributionPoint(IssuingDistributionPoint *val);
  305. static void ASN1CALL ASN1Free_CrossCertDistPointNames(CrossCertDistPointNames *val);
  306. static void ASN1CALL ASN1Free_PolicyMappings(PolicyMappings *val);
  307. static void ASN1CALL ASN1Free_PolicyMapping(PolicyMapping *val);
  308. static void ASN1CALL ASN1Free_ControlSequence(ControlSequence *val);
  309. static void ASN1CALL ASN1Free_ReqSequence(ReqSequence *val);
  310. static void ASN1CALL ASN1Free_CmsSequence(CmsSequence *val);
  311. static void ASN1CALL ASN1Free_OtherMsgSequence(OtherMsgSequence *val);
  312. static void ASN1CALL ASN1Free_BodyPartIDSequence(BodyPartIDSequence *val);
  313. static void ASN1CALL ASN1Free_TaggedAttribute(TaggedAttribute *val);
  314. static void ASN1CALL ASN1Free_TaggedCertificationRequest(TaggedCertificationRequest *val);
  315. static void ASN1CALL ASN1Free_TaggedContentInfo(TaggedContentInfo *val);
  316. static void ASN1CALL ASN1Free_TaggedOtherMsg(TaggedOtherMsg *val);
  317. static void ASN1CALL ASN1Free_PendInfo(PendInfo *val);
  318. static void ASN1CALL ASN1Free_CmcAddExtensions(CmcAddExtensions *val);
  319. static void ASN1CALL ASN1Free_CmcAddAttributes(CmcAddAttributes *val);
  320. static void ASN1CALL ASN1Free_CertificateTemplate(CertificateTemplate *val);
  321. static void ASN1CALL ASN1Free_CmcStatusInfo_otherInfo(CmcStatusInfo_otherInfo *val);
  322. static void ASN1CALL ASN1Free_CpsURLs_Seq(CpsURLs_Seq *val);
  323. static void ASN1CALL ASN1Free_Attribute(Attribute *val);
  324. static void ASN1CALL ASN1Free_X942DhParameters(X942DhParameters *val);
  325. static void ASN1CALL ASN1Free_X942DhOtherInfo(X942DhOtherInfo *val);
  326. static void ASN1CALL ASN1Free_CertificateToBeSigned(CertificateToBeSigned *val);
  327. static void ASN1CALL ASN1Free_CertificateRevocationListToBeSigned(CertificateRevocationListToBeSigned *val);
  328. static void ASN1CALL ASN1Free_KeyAttributes(KeyAttributes *val);
  329. static void ASN1CALL ASN1Free_KeyUsageRestriction(KeyUsageRestriction *val);
  330. static void ASN1CALL ASN1Free_GeneralName(GeneralName *val);
  331. static void ASN1CALL ASN1Free_BasicConstraints(BasicConstraints *val);
  332. static void ASN1CALL ASN1Free_PolicyInformation(PolicyInformation *val);
  333. static void ASN1CALL ASN1Free_UserNotice(UserNotice *val);
  334. static void ASN1CALL ASN1Free_VerisignQualifier1(VerisignQualifier1 *val);
  335. static void ASN1CALL ASN1Free_AccessDescription(AccessDescription *val);
  336. static void ASN1CALL ASN1Free_DistributionPoint(DistributionPoint *val);
  337. static void ASN1CALL ASN1Free_ContentInfoSeqOfAny(ContentInfoSeqOfAny *val);
  338. static void ASN1CALL ASN1Free_CertificateTrustList(CertificateTrustList *val);
  339. static void ASN1CALL ASN1Free_NameConstraints(NameConstraints *val);
  340. static void ASN1CALL ASN1Free_GeneralSubtree(GeneralSubtree *val);
  341. static void ASN1CALL ASN1Free_CrossCertDistPoints(CrossCertDistPoints *val);
  342. static void ASN1CALL ASN1Free_CmcData(CmcData *val);
  343. static void ASN1CALL ASN1Free_CmcResponseBody(CmcResponseBody *val);
  344. static void ASN1CALL ASN1Free_TaggedRequest(TaggedRequest *val);
  345. static void ASN1CALL ASN1Free_CmcStatusInfo(CmcStatusInfo *val);
  346. typedef ASN1BerEncFun_t ASN1EncFun_t;
  347. static const ASN1EncFun_t encfntab[64] = {
  348. (ASN1EncFun_t) ASN1Enc_EncodedObjectID,
  349. (ASN1EncFun_t) ASN1Enc_Bits,
  350. (ASN1EncFun_t) ASN1Enc_IntegerType,
  351. (ASN1EncFun_t) ASN1Enc_HugeIntegerType,
  352. (ASN1EncFun_t) ASN1Enc_OctetStringType,
  353. (ASN1EncFun_t) ASN1Enc_EnumeratedType,
  354. (ASN1EncFun_t) ASN1Enc_UtcTime,
  355. (ASN1EncFun_t) ASN1Enc_AnyString,
  356. (ASN1EncFun_t) ASN1Enc_Name,
  357. (ASN1EncFun_t) ASN1Enc_Attributes,
  358. (ASN1EncFun_t) ASN1Enc_RSAPublicKey,
  359. (ASN1EncFun_t) ASN1Enc_DSSParameters,
  360. (ASN1EncFun_t) ASN1Enc_DSSSignature,
  361. (ASN1EncFun_t) ASN1Enc_DHParameters,
  362. (ASN1EncFun_t) ASN1Enc_RC2CBCParameters,
  363. (ASN1EncFun_t) ASN1Enc_SMIMECapabilities,
  364. (ASN1EncFun_t) ASN1Enc_SubjectPublicKeyInfo,
  365. (ASN1EncFun_t) ASN1Enc_ChoiceOfTime,
  366. (ASN1EncFun_t) ASN1Enc_Extensions,
  367. (ASN1EncFun_t) ASN1Enc_SignedContent,
  368. (ASN1EncFun_t) ASN1Enc_CertificationRequestInfo,
  369. (ASN1EncFun_t) ASN1Enc_CertificationRequestInfoDecode,
  370. (ASN1EncFun_t) ASN1Enc_KeygenRequestInfo,
  371. (ASN1EncFun_t) ASN1Enc_AuthorityKeyId,
  372. (ASN1EncFun_t) ASN1Enc_AltNames,
  373. (ASN1EncFun_t) ASN1Enc_EDIPartyName,
  374. (ASN1EncFun_t) ASN1Enc_BasicConstraints2,
  375. (ASN1EncFun_t) ASN1Enc_CertificatePolicies,
  376. (ASN1EncFun_t) ASN1Enc_CertificatePolicies95,
  377. (ASN1EncFun_t) ASN1Enc_AuthorityKeyId2,
  378. (ASN1EncFun_t) ASN1Enc_AuthorityInfoAccess,
  379. (ASN1EncFun_t) ASN1Enc_CRLDistributionPoints,
  380. (ASN1EncFun_t) ASN1Enc_ContentInfo,
  381. (ASN1EncFun_t) ASN1Enc_SeqOfAny,
  382. (ASN1EncFun_t) ASN1Enc_TimeStampRequest,
  383. (ASN1EncFun_t) ASN1Enc_ContentInfoOTS,
  384. (ASN1EncFun_t) ASN1Enc_TimeStampRequestOTS,
  385. (ASN1EncFun_t) ASN1Enc_EnhancedKeyUsage,
  386. (ASN1EncFun_t) ASN1Enc_EnrollmentNameValuePair,
  387. (ASN1EncFun_t) ASN1Enc_CSPProvider,
  388. (ASN1EncFun_t) ASN1Enc_CertificatePair,
  389. (ASN1EncFun_t) ASN1Enc_IssuingDistributionPoint,
  390. (ASN1EncFun_t) ASN1Enc_PolicyMappings,
  391. (ASN1EncFun_t) ASN1Enc_PolicyConstraints,
  392. (ASN1EncFun_t) ASN1Enc_CmcAddExtensions,
  393. (ASN1EncFun_t) ASN1Enc_CmcAddAttributes,
  394. (ASN1EncFun_t) ASN1Enc_CertificateTemplate,
  395. (ASN1EncFun_t) ASN1Enc_Attribute,
  396. (ASN1EncFun_t) ASN1Enc_X942DhParameters,
  397. (ASN1EncFun_t) ASN1Enc_X942DhOtherInfo,
  398. (ASN1EncFun_t) ASN1Enc_CertificateToBeSigned,
  399. (ASN1EncFun_t) ASN1Enc_CertificateRevocationListToBeSigned,
  400. (ASN1EncFun_t) ASN1Enc_KeyAttributes,
  401. (ASN1EncFun_t) ASN1Enc_KeyUsageRestriction,
  402. (ASN1EncFun_t) ASN1Enc_BasicConstraints,
  403. (ASN1EncFun_t) ASN1Enc_UserNotice,
  404. (ASN1EncFun_t) ASN1Enc_VerisignQualifier1,
  405. (ASN1EncFun_t) ASN1Enc_ContentInfoSeqOfAny,
  406. (ASN1EncFun_t) ASN1Enc_CertificateTrustList,
  407. (ASN1EncFun_t) ASN1Enc_NameConstraints,
  408. (ASN1EncFun_t) ASN1Enc_CrossCertDistPoints,
  409. (ASN1EncFun_t) ASN1Enc_CmcData,
  410. (ASN1EncFun_t) ASN1Enc_CmcResponseBody,
  411. (ASN1EncFun_t) ASN1Enc_CmcStatusInfo,
  412. };
  413. typedef ASN1BerDecFun_t ASN1DecFun_t;
  414. static const ASN1DecFun_t decfntab[64] = {
  415. (ASN1DecFun_t) ASN1Dec_EncodedObjectID,
  416. (ASN1DecFun_t) ASN1Dec_Bits,
  417. (ASN1DecFun_t) ASN1Dec_IntegerType,
  418. (ASN1DecFun_t) ASN1Dec_HugeIntegerType,
  419. (ASN1DecFun_t) ASN1Dec_OctetStringType,
  420. (ASN1DecFun_t) ASN1Dec_EnumeratedType,
  421. (ASN1DecFun_t) ASN1Dec_UtcTime,
  422. (ASN1DecFun_t) ASN1Dec_AnyString,
  423. (ASN1DecFun_t) ASN1Dec_Name,
  424. (ASN1DecFun_t) ASN1Dec_Attributes,
  425. (ASN1DecFun_t) ASN1Dec_RSAPublicKey,
  426. (ASN1DecFun_t) ASN1Dec_DSSParameters,
  427. (ASN1DecFun_t) ASN1Dec_DSSSignature,
  428. (ASN1DecFun_t) ASN1Dec_DHParameters,
  429. (ASN1DecFun_t) ASN1Dec_RC2CBCParameters,
  430. (ASN1DecFun_t) ASN1Dec_SMIMECapabilities,
  431. (ASN1DecFun_t) ASN1Dec_SubjectPublicKeyInfo,
  432. (ASN1DecFun_t) ASN1Dec_ChoiceOfTime,
  433. (ASN1DecFun_t) ASN1Dec_Extensions,
  434. (ASN1DecFun_t) ASN1Dec_SignedContent,
  435. (ASN1DecFun_t) ASN1Dec_CertificationRequestInfo,
  436. (ASN1DecFun_t) ASN1Dec_CertificationRequestInfoDecode,
  437. (ASN1DecFun_t) ASN1Dec_KeygenRequestInfo,
  438. (ASN1DecFun_t) ASN1Dec_AuthorityKeyId,
  439. (ASN1DecFun_t) ASN1Dec_AltNames,
  440. (ASN1DecFun_t) ASN1Dec_EDIPartyName,
  441. (ASN1DecFun_t) ASN1Dec_BasicConstraints2,
  442. (ASN1DecFun_t) ASN1Dec_CertificatePolicies,
  443. (ASN1DecFun_t) ASN1Dec_CertificatePolicies95,
  444. (ASN1DecFun_t) ASN1Dec_AuthorityKeyId2,
  445. (ASN1DecFun_t) ASN1Dec_AuthorityInfoAccess,
  446. (ASN1DecFun_t) ASN1Dec_CRLDistributionPoints,
  447. (ASN1DecFun_t) ASN1Dec_ContentInfo,
  448. (ASN1DecFun_t) ASN1Dec_SeqOfAny,
  449. (ASN1DecFun_t) ASN1Dec_TimeStampRequest,
  450. (ASN1DecFun_t) ASN1Dec_ContentInfoOTS,
  451. (ASN1DecFun_t) ASN1Dec_TimeStampRequestOTS,
  452. (ASN1DecFun_t) ASN1Dec_EnhancedKeyUsage,
  453. (ASN1DecFun_t) ASN1Dec_EnrollmentNameValuePair,
  454. (ASN1DecFun_t) ASN1Dec_CSPProvider,
  455. (ASN1DecFun_t) ASN1Dec_CertificatePair,
  456. (ASN1DecFun_t) ASN1Dec_IssuingDistributionPoint,
  457. (ASN1DecFun_t) ASN1Dec_PolicyMappings,
  458. (ASN1DecFun_t) ASN1Dec_PolicyConstraints,
  459. (ASN1DecFun_t) ASN1Dec_CmcAddExtensions,
  460. (ASN1DecFun_t) ASN1Dec_CmcAddAttributes,
  461. (ASN1DecFun_t) ASN1Dec_CertificateTemplate,
  462. (ASN1DecFun_t) ASN1Dec_Attribute,
  463. (ASN1DecFun_t) ASN1Dec_X942DhParameters,
  464. (ASN1DecFun_t) ASN1Dec_X942DhOtherInfo,
  465. (ASN1DecFun_t) ASN1Dec_CertificateToBeSigned,
  466. (ASN1DecFun_t) ASN1Dec_CertificateRevocationListToBeSigned,
  467. (ASN1DecFun_t) ASN1Dec_KeyAttributes,
  468. (ASN1DecFun_t) ASN1Dec_KeyUsageRestriction,
  469. (ASN1DecFun_t) ASN1Dec_BasicConstraints,
  470. (ASN1DecFun_t) ASN1Dec_UserNotice,
  471. (ASN1DecFun_t) ASN1Dec_VerisignQualifier1,
  472. (ASN1DecFun_t) ASN1Dec_ContentInfoSeqOfAny,
  473. (ASN1DecFun_t) ASN1Dec_CertificateTrustList,
  474. (ASN1DecFun_t) ASN1Dec_NameConstraints,
  475. (ASN1DecFun_t) ASN1Dec_CrossCertDistPoints,
  476. (ASN1DecFun_t) ASN1Dec_CmcData,
  477. (ASN1DecFun_t) ASN1Dec_CmcResponseBody,
  478. (ASN1DecFun_t) ASN1Dec_CmcStatusInfo,
  479. };
  480. static const ASN1FreeFun_t freefntab[64] = {
  481. (ASN1FreeFun_t) ASN1Free_EncodedObjectID,
  482. (ASN1FreeFun_t) ASN1Free_Bits,
  483. (ASN1FreeFun_t) NULL,
  484. (ASN1FreeFun_t) ASN1Free_HugeIntegerType,
  485. (ASN1FreeFun_t) ASN1Free_OctetStringType,
  486. (ASN1FreeFun_t) NULL,
  487. (ASN1FreeFun_t) ASN1Free_UtcTime,
  488. (ASN1FreeFun_t) ASN1Free_AnyString,
  489. (ASN1FreeFun_t) ASN1Free_Name,
  490. (ASN1FreeFun_t) ASN1Free_Attributes,
  491. (ASN1FreeFun_t) ASN1Free_RSAPublicKey,
  492. (ASN1FreeFun_t) ASN1Free_DSSParameters,
  493. (ASN1FreeFun_t) ASN1Free_DSSSignature,
  494. (ASN1FreeFun_t) ASN1Free_DHParameters,
  495. (ASN1FreeFun_t) ASN1Free_RC2CBCParameters,
  496. (ASN1FreeFun_t) ASN1Free_SMIMECapabilities,
  497. (ASN1FreeFun_t) ASN1Free_SubjectPublicKeyInfo,
  498. (ASN1FreeFun_t) ASN1Free_ChoiceOfTime,
  499. (ASN1FreeFun_t) ASN1Free_Extensions,
  500. (ASN1FreeFun_t) ASN1Free_SignedContent,
  501. (ASN1FreeFun_t) ASN1Free_CertificationRequestInfo,
  502. (ASN1FreeFun_t) ASN1Free_CertificationRequestInfoDecode,
  503. (ASN1FreeFun_t) ASN1Free_KeygenRequestInfo,
  504. (ASN1FreeFun_t) ASN1Free_AuthorityKeyId,
  505. (ASN1FreeFun_t) ASN1Free_AltNames,
  506. (ASN1FreeFun_t) ASN1Free_EDIPartyName,
  507. (ASN1FreeFun_t) NULL,
  508. (ASN1FreeFun_t) ASN1Free_CertificatePolicies,
  509. (ASN1FreeFun_t) ASN1Free_CertificatePolicies95,
  510. (ASN1FreeFun_t) ASN1Free_AuthorityKeyId2,
  511. (ASN1FreeFun_t) ASN1Free_AuthorityInfoAccess,
  512. (ASN1FreeFun_t) ASN1Free_CRLDistributionPoints,
  513. (ASN1FreeFun_t) ASN1Free_ContentInfo,
  514. (ASN1FreeFun_t) ASN1Free_SeqOfAny,
  515. (ASN1FreeFun_t) ASN1Free_TimeStampRequest,
  516. (ASN1FreeFun_t) ASN1Free_ContentInfoOTS,
  517. (ASN1FreeFun_t) ASN1Free_TimeStampRequestOTS,
  518. (ASN1FreeFun_t) ASN1Free_EnhancedKeyUsage,
  519. (ASN1FreeFun_t) ASN1Free_EnrollmentNameValuePair,
  520. (ASN1FreeFun_t) ASN1Free_CSPProvider,
  521. (ASN1FreeFun_t) ASN1Free_CertificatePair,
  522. (ASN1FreeFun_t) ASN1Free_IssuingDistributionPoint,
  523. (ASN1FreeFun_t) ASN1Free_PolicyMappings,
  524. (ASN1FreeFun_t) NULL,
  525. (ASN1FreeFun_t) ASN1Free_CmcAddExtensions,
  526. (ASN1FreeFun_t) ASN1Free_CmcAddAttributes,
  527. (ASN1FreeFun_t) ASN1Free_CertificateTemplate,
  528. (ASN1FreeFun_t) ASN1Free_Attribute,
  529. (ASN1FreeFun_t) ASN1Free_X942DhParameters,
  530. (ASN1FreeFun_t) ASN1Free_X942DhOtherInfo,
  531. (ASN1FreeFun_t) ASN1Free_CertificateToBeSigned,
  532. (ASN1FreeFun_t) ASN1Free_CertificateRevocationListToBeSigned,
  533. (ASN1FreeFun_t) ASN1Free_KeyAttributes,
  534. (ASN1FreeFun_t) ASN1Free_KeyUsageRestriction,
  535. (ASN1FreeFun_t) ASN1Free_BasicConstraints,
  536. (ASN1FreeFun_t) ASN1Free_UserNotice,
  537. (ASN1FreeFun_t) ASN1Free_VerisignQualifier1,
  538. (ASN1FreeFun_t) ASN1Free_ContentInfoSeqOfAny,
  539. (ASN1FreeFun_t) ASN1Free_CertificateTrustList,
  540. (ASN1FreeFun_t) ASN1Free_NameConstraints,
  541. (ASN1FreeFun_t) ASN1Free_CrossCertDistPoints,
  542. (ASN1FreeFun_t) ASN1Free_CmcData,
  543. (ASN1FreeFun_t) ASN1Free_CmcResponseBody,
  544. (ASN1FreeFun_t) ASN1Free_CmcStatusInfo,
  545. };
  546. static const ULONG sizetab[64] = {
  547. SIZE_X509_Module_PDU_0,
  548. SIZE_X509_Module_PDU_1,
  549. SIZE_X509_Module_PDU_2,
  550. SIZE_X509_Module_PDU_3,
  551. SIZE_X509_Module_PDU_4,
  552. SIZE_X509_Module_PDU_5,
  553. SIZE_X509_Module_PDU_6,
  554. SIZE_X509_Module_PDU_7,
  555. SIZE_X509_Module_PDU_8,
  556. SIZE_X509_Module_PDU_9,
  557. SIZE_X509_Module_PDU_10,
  558. SIZE_X509_Module_PDU_11,
  559. SIZE_X509_Module_PDU_12,
  560. SIZE_X509_Module_PDU_13,
  561. SIZE_X509_Module_PDU_14,
  562. SIZE_X509_Module_PDU_15,
  563. SIZE_X509_Module_PDU_16,
  564. SIZE_X509_Module_PDU_17,
  565. SIZE_X509_Module_PDU_18,
  566. SIZE_X509_Module_PDU_19,
  567. SIZE_X509_Module_PDU_20,
  568. SIZE_X509_Module_PDU_21,
  569. SIZE_X509_Module_PDU_22,
  570. SIZE_X509_Module_PDU_23,
  571. SIZE_X509_Module_PDU_24,
  572. SIZE_X509_Module_PDU_25,
  573. SIZE_X509_Module_PDU_26,
  574. SIZE_X509_Module_PDU_27,
  575. SIZE_X509_Module_PDU_28,
  576. SIZE_X509_Module_PDU_29,
  577. SIZE_X509_Module_PDU_30,
  578. SIZE_X509_Module_PDU_31,
  579. SIZE_X509_Module_PDU_32,
  580. SIZE_X509_Module_PDU_33,
  581. SIZE_X509_Module_PDU_34,
  582. SIZE_X509_Module_PDU_35,
  583. SIZE_X509_Module_PDU_36,
  584. SIZE_X509_Module_PDU_37,
  585. SIZE_X509_Module_PDU_38,
  586. SIZE_X509_Module_PDU_39,
  587. SIZE_X509_Module_PDU_40,
  588. SIZE_X509_Module_PDU_41,
  589. SIZE_X509_Module_PDU_42,
  590. SIZE_X509_Module_PDU_43,
  591. SIZE_X509_Module_PDU_44,
  592. SIZE_X509_Module_PDU_45,
  593. SIZE_X509_Module_PDU_46,
  594. SIZE_X509_Module_PDU_47,
  595. SIZE_X509_Module_PDU_48,
  596. SIZE_X509_Module_PDU_49,
  597. SIZE_X509_Module_PDU_50,
  598. SIZE_X509_Module_PDU_51,
  599. SIZE_X509_Module_PDU_52,
  600. SIZE_X509_Module_PDU_53,
  601. SIZE_X509_Module_PDU_54,
  602. SIZE_X509_Module_PDU_55,
  603. SIZE_X509_Module_PDU_56,
  604. SIZE_X509_Module_PDU_57,
  605. SIZE_X509_Module_PDU_58,
  606. SIZE_X509_Module_PDU_59,
  607. SIZE_X509_Module_PDU_60,
  608. SIZE_X509_Module_PDU_61,
  609. SIZE_X509_Module_PDU_62,
  610. SIZE_X509_Module_PDU_63,
  611. };
  612. /* forward declarations of values: */
  613. /* definitions of value components: */
  614. /* definitions of values: */
  615. ASN1bool_t IssuingDistributionPoint_indirectCRL_default = 0;
  616. ASN1bool_t IssuingDistributionPoint_onlyContainsCACerts_default = 0;
  617. ASN1bool_t IssuingDistributionPoint_onlyContainsUserCerts_default = 0;
  618. BaseDistance GeneralSubtree_minimum_default = 0;
  619. CTLVersion CertificateTrustList_version_default = 0;
  620. ASN1bool_t BasicConstraints2_cA_default = 0;
  621. ASN1bool_t Extension_critical_default = 0;
  622. CertificateVersion CertificateToBeSigned_version_default = 0;
  623. void ASN1CALL X509_Module_Startup(void)
  624. {
  625. X509_Module = ASN1_CreateModule(0x10000, ASN1_BER_RULE_DER, ASN1FLAGS_NOASSERT, 64, (const ASN1GenericFun_t *) encfntab, (const ASN1GenericFun_t *) decfntab, freefntab, sizetab, 0x39303578);
  626. }
  627. void ASN1CALL X509_Module_Cleanup(void)
  628. {
  629. ASN1_CloseModule(X509_Module);
  630. X509_Module = NULL;
  631. }
  632. static int ASN1CALL ASN1Enc_EncodedObjectID(ASN1encoding_t enc, ASN1uint32_t tag, EncodedObjectID *val)
  633. {
  634. if (!ASN1BEREncEoid(enc, tag ? tag : 0x6, val))
  635. return 0;
  636. return 1;
  637. }
  638. static int ASN1CALL ASN1Dec_EncodedObjectID(ASN1decoding_t dec, ASN1uint32_t tag, EncodedObjectID *val)
  639. {
  640. if (!ASN1BERDecEoid(dec, tag ? tag : 0x6, val))
  641. return 0;
  642. return 1;
  643. }
  644. static void ASN1CALL ASN1Free_EncodedObjectID(EncodedObjectID *val)
  645. {
  646. if (val) {
  647. ASN1BEREoid_free(val);
  648. }
  649. }
  650. static int ASN1CALL ASN1Enc_Bits(ASN1encoding_t enc, ASN1uint32_t tag, Bits *val)
  651. {
  652. if (!ASN1DEREncBitString(enc, tag ? tag : 0x3, (val)->length, (val)->value))
  653. return 0;
  654. return 1;
  655. }
  656. static int ASN1CALL ASN1Dec_Bits(ASN1decoding_t dec, ASN1uint32_t tag, Bits *val)
  657. {
  658. if (!ASN1BERDecBitString2(dec, tag ? tag : 0x3, val))
  659. return 0;
  660. return 1;
  661. }
  662. static void ASN1CALL ASN1Free_Bits(Bits *val)
  663. {
  664. if (val) {
  665. }
  666. }
  667. static int ASN1CALL ASN1Enc_IntegerType(ASN1encoding_t enc, ASN1uint32_t tag, IntegerType *val)
  668. {
  669. if (!ASN1BEREncS32(enc, tag ? tag : 0x2, *val))
  670. return 0;
  671. return 1;
  672. }
  673. static int ASN1CALL ASN1Dec_IntegerType(ASN1decoding_t dec, ASN1uint32_t tag, IntegerType *val)
  674. {
  675. if (!ASN1BERDecS32Val(dec, tag ? tag : 0x2, val))
  676. return 0;
  677. return 1;
  678. }
  679. static int ASN1CALL ASN1Enc_HugeIntegerType(ASN1encoding_t enc, ASN1uint32_t tag, HugeIntegerType *val)
  680. {
  681. if (!ASN1BEREncSX(enc, tag ? tag : 0x2, val))
  682. return 0;
  683. return 1;
  684. }
  685. static int ASN1CALL ASN1Dec_HugeIntegerType(ASN1decoding_t dec, ASN1uint32_t tag, HugeIntegerType *val)
  686. {
  687. if (!ASN1BERDecSXVal(dec, tag ? tag : 0x2, val))
  688. return 0;
  689. return 1;
  690. }
  691. static void ASN1CALL ASN1Free_HugeIntegerType(HugeIntegerType *val)
  692. {
  693. if (val) {
  694. ASN1intx_free(val);
  695. }
  696. }
  697. static int ASN1CALL ASN1Enc_OctetStringType(ASN1encoding_t enc, ASN1uint32_t tag, OctetStringType *val)
  698. {
  699. if (!ASN1DEREncOctetString(enc, tag ? tag : 0x4, (val)->length, (val)->value))
  700. return 0;
  701. return 1;
  702. }
  703. static int ASN1CALL ASN1Dec_OctetStringType(ASN1decoding_t dec, ASN1uint32_t tag, OctetStringType *val)
  704. {
  705. if (!ASN1BERDecOctetString2(dec, tag ? tag : 0x4, val))
  706. return 0;
  707. return 1;
  708. }
  709. static void ASN1CALL ASN1Free_OctetStringType(OctetStringType *val)
  710. {
  711. if (val) {
  712. }
  713. }
  714. static int ASN1CALL ASN1Enc_EnumeratedType(ASN1encoding_t enc, ASN1uint32_t tag, EnumeratedType *val)
  715. {
  716. if (!ASN1BEREncU32(enc, tag ? tag : 0xa, *val))
  717. return 0;
  718. return 1;
  719. }
  720. static int ASN1CALL ASN1Dec_EnumeratedType(ASN1decoding_t dec, ASN1uint32_t tag, EnumeratedType *val)
  721. {
  722. if (!ASN1BERDecU32Val(dec, tag ? tag : 0xa, (ASN1uint32_t *) val))
  723. return 0;
  724. return 1;
  725. }
  726. static int ASN1CALL ASN1Enc_UtcTime(ASN1encoding_t enc, ASN1uint32_t tag, UtcTime *val)
  727. {
  728. if (!ASN1DEREncUTCTime(enc, tag ? tag : 0x17, val))
  729. return 0;
  730. return 1;
  731. }
  732. static int ASN1CALL ASN1Dec_UtcTime(ASN1decoding_t dec, ASN1uint32_t tag, UtcTime *val)
  733. {
  734. if (!ASN1BERDecUTCTime(dec, tag ? tag : 0x17, val))
  735. return 0;
  736. return 1;
  737. }
  738. static void ASN1CALL ASN1Free_UtcTime(UtcTime *val)
  739. {
  740. if (val) {
  741. }
  742. }
  743. static int ASN1CALL ASN1Enc_NoticeReference_noticeNumbers(ASN1encoding_t enc, ASN1uint32_t tag, NoticeReference_noticeNumbers *val)
  744. {
  745. ASN1uint32_t nLenOff;
  746. ASN1uint32_t i;
  747. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  748. return 0;
  749. for (i = 0; i < (val)->count; i++) {
  750. if (!ASN1BEREncS32(enc, 0x2, ((val)->value)[i]))
  751. return 0;
  752. }
  753. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  754. return 0;
  755. return 1;
  756. }
  757. static int ASN1CALL ASN1Dec_NoticeReference_noticeNumbers(ASN1decoding_t dec, ASN1uint32_t tag, NoticeReference_noticeNumbers *val)
  758. {
  759. ASN1decoding_t dd;
  760. ASN1octet_t *di;
  761. ASN1uint32_t t;
  762. ASN1uint32_t n;
  763. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  764. return 0;
  765. (val)->count = n = 0;
  766. (val)->value = NULL;
  767. while (ASN1BERDecNotEndOfContents(dd, di)) {
  768. if (!ASN1BERDecPeekTag(dd, &t))
  769. return 0;
  770. if ((val)->count >= n) {
  771. void *pvASN1DecRealloc;
  772. n = n ? (n << 1) : 16;
  773. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  774. return 0;
  775. (val)->value = (NoticeReference_noticeNumbers_Seq *) pvASN1DecRealloc;
  776. }
  777. if (!ASN1BERDecS32Val(dd, 0x2, &((val)->value)[(val)->count]))
  778. return 0;
  779. ((val)->count)++;
  780. }
  781. if (!ASN1BERDecEndOfContents(dec, dd, di))
  782. return 0;
  783. return 1;
  784. }
  785. static void ASN1CALL ASN1Free_NoticeReference_noticeNumbers(NoticeReference_noticeNumbers *val)
  786. {
  787. if (val) {
  788. ASN1Free((val)->value);
  789. }
  790. }
  791. static int ASN1CALL ASN1Enc_AnyString(ASN1encoding_t enc, ASN1uint32_t tag, AnyString *val)
  792. {
  793. switch ((val)->choice) {
  794. case 1:
  795. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->u.octetString).length, ((val)->u.octetString).value))
  796. return 0;
  797. break;
  798. case 2:
  799. if (!ASN1DEREncUTF8String(enc, 0xc, ((val)->u.utf8String).length, ((val)->u.utf8String).value))
  800. return 0;
  801. break;
  802. case 3:
  803. if (!ASN1DEREncCharString(enc, 0x12, ((val)->u.numericString).length, ((val)->u.numericString).value))
  804. return 0;
  805. break;
  806. case 4:
  807. if (!ASN1DEREncCharString(enc, 0x13, ((val)->u.printableString).length, ((val)->u.printableString).value))
  808. return 0;
  809. break;
  810. case 5:
  811. if (!ASN1DEREncMultibyteString(enc, 0x14, &(val)->u.teletexString))
  812. return 0;
  813. break;
  814. case 6:
  815. if (!ASN1DEREncMultibyteString(enc, 0x15, &(val)->u.videotexString))
  816. return 0;
  817. break;
  818. case 7:
  819. if (!ASN1DEREncCharString(enc, 0x16, ((val)->u.ia5String).length, ((val)->u.ia5String).value))
  820. return 0;
  821. break;
  822. case 8:
  823. if (!ASN1DEREncCharString(enc, 0x19, ((val)->u.graphicString).length, ((val)->u.graphicString).value))
  824. return 0;
  825. break;
  826. case 9:
  827. if (!ASN1DEREncCharString(enc, 0x1a, ((val)->u.visibleString).length, ((val)->u.visibleString).value))
  828. return 0;
  829. break;
  830. case 10:
  831. if (!ASN1DEREncCharString(enc, 0x1b, ((val)->u.generalString).length, ((val)->u.generalString).value))
  832. return 0;
  833. break;
  834. case 11:
  835. if (!ASN1DEREncChar32String(enc, 0x1c, ((val)->u.universalString).length, ((val)->u.universalString).value))
  836. return 0;
  837. break;
  838. case 12:
  839. if (!ASN1DEREncChar16String(enc, 0x1e, ((val)->u.bmpString).length, ((val)->u.bmpString).value))
  840. return 0;
  841. break;
  842. default:
  843. /* impossible */
  844. ASN1EncSetError(enc, ASN1_ERR_CHOICE);
  845. return 0;
  846. }
  847. return 1;
  848. }
  849. static int ASN1CALL ASN1Dec_AnyString(ASN1decoding_t dec, ASN1uint32_t tag, AnyString *val)
  850. {
  851. ASN1uint32_t t;
  852. if (!ASN1BERDecPeekTag(dec, &t))
  853. return 0;
  854. switch (t) {
  855. case 0x4:
  856. (val)->choice = 1;
  857. if (!ASN1BERDecOctetString2(dec, 0x4, &(val)->u.octetString))
  858. return 0;
  859. break;
  860. case 0xc:
  861. (val)->choice = 2;
  862. if (!ASN1BERDecUTF8String(dec, 0xc, &(val)->u.utf8String))
  863. return 0;
  864. break;
  865. case 0x12:
  866. (val)->choice = 3;
  867. if (!ASN1BERDecCharString(dec, 0x12, &(val)->u.numericString))
  868. return 0;
  869. break;
  870. case 0x13:
  871. (val)->choice = 4;
  872. if (!ASN1BERDecCharString(dec, 0x13, &(val)->u.printableString))
  873. return 0;
  874. break;
  875. case 0x14:
  876. (val)->choice = 5;
  877. if (!ASN1BERDecMultibyteString(dec, 0x14, &(val)->u.teletexString))
  878. return 0;
  879. break;
  880. case 0x15:
  881. (val)->choice = 6;
  882. if (!ASN1BERDecMultibyteString(dec, 0x15, &(val)->u.videotexString))
  883. return 0;
  884. break;
  885. case 0x16:
  886. (val)->choice = 7;
  887. if (!ASN1BERDecCharString(dec, 0x16, &(val)->u.ia5String))
  888. return 0;
  889. break;
  890. case 0x19:
  891. (val)->choice = 8;
  892. if (!ASN1BERDecCharString(dec, 0x19, &(val)->u.graphicString))
  893. return 0;
  894. break;
  895. case 0x1a:
  896. (val)->choice = 9;
  897. if (!ASN1BERDecCharString(dec, 0x1a, &(val)->u.visibleString))
  898. return 0;
  899. break;
  900. case 0x1b:
  901. (val)->choice = 10;
  902. if (!ASN1BERDecCharString(dec, 0x1b, &(val)->u.generalString))
  903. return 0;
  904. break;
  905. case 0x1c:
  906. (val)->choice = 11;
  907. if (!ASN1BERDecChar32String(dec, 0x1c, &(val)->u.universalString))
  908. return 0;
  909. break;
  910. case 0x1e:
  911. (val)->choice = 12;
  912. if (!ASN1BERDecChar16String(dec, 0x1e, &(val)->u.bmpString))
  913. return 0;
  914. break;
  915. default:
  916. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  917. return 0;
  918. }
  919. return 1;
  920. }
  921. static void ASN1CALL ASN1Free_AnyString(AnyString *val)
  922. {
  923. if (val) {
  924. switch ((val)->choice) {
  925. case 1:
  926. break;
  927. case 2:
  928. ASN1utf8string_free(&(val)->u.utf8String);
  929. break;
  930. case 3:
  931. ASN1charstring_free(&(val)->u.numericString);
  932. break;
  933. case 4:
  934. ASN1charstring_free(&(val)->u.printableString);
  935. break;
  936. case 5:
  937. ASN1charstring_free(&(val)->u.teletexString);
  938. break;
  939. case 6:
  940. ASN1charstring_free(&(val)->u.videotexString);
  941. break;
  942. case 7:
  943. ASN1charstring_free(&(val)->u.ia5String);
  944. break;
  945. case 8:
  946. ASN1charstring_free(&(val)->u.graphicString);
  947. break;
  948. case 9:
  949. ASN1charstring_free(&(val)->u.visibleString);
  950. break;
  951. case 10:
  952. ASN1charstring_free(&(val)->u.generalString);
  953. break;
  954. case 11:
  955. ASN1char32string_free(&(val)->u.universalString);
  956. break;
  957. case 12:
  958. ASN1char16string_free(&(val)->u.bmpString);
  959. break;
  960. }
  961. }
  962. }
  963. static int ASN1CALL ASN1Enc_AlgorithmIdentifier(ASN1encoding_t enc, ASN1uint32_t tag, AlgorithmIdentifier *val)
  964. {
  965. ASN1uint32_t nLenOff;
  966. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  967. return 0;
  968. if (!ASN1BEREncEoid(enc, 0x6, &(val)->algorithm))
  969. return 0;
  970. if ((val)->o[0] & 0x80) {
  971. if (!ASN1BEREncOpenType(enc, &(val)->parameters))
  972. return 0;
  973. }
  974. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  975. return 0;
  976. return 1;
  977. }
  978. static int ASN1CALL ASN1Dec_AlgorithmIdentifier(ASN1decoding_t dec, ASN1uint32_t tag, AlgorithmIdentifier *val)
  979. {
  980. ASN1decoding_t dd;
  981. ASN1octet_t *di;
  982. ASN1uint32_t t;
  983. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  984. return 0;
  985. ZeroMemory((val)->o, 1);
  986. if (!ASN1BERDecEoid(dd, 0x6, &(val)->algorithm))
  987. return 0;
  988. if (ASN1BERDecPeekTag(dd, &t)) {
  989. (val)->o[0] |= 0x80;
  990. if (!ASN1BERDecOpenType2(dd, &(val)->parameters))
  991. return 0;
  992. }
  993. if (!ASN1BERDecEndOfContents(dec, dd, di))
  994. return 0;
  995. return 1;
  996. }
  997. static void ASN1CALL ASN1Free_AlgorithmIdentifier(AlgorithmIdentifier *val)
  998. {
  999. if (val) {
  1000. ASN1BEREoid_free(&(val)->algorithm);
  1001. if ((val)->o[0] & 0x80) {
  1002. }
  1003. }
  1004. }
  1005. static int ASN1CALL ASN1Enc_Name(ASN1encoding_t enc, ASN1uint32_t tag, Name *val)
  1006. {
  1007. ASN1uint32_t nLenOff;
  1008. ASN1uint32_t i;
  1009. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1010. return 0;
  1011. for (i = 0; i < (val)->count; i++) {
  1012. if (!ASN1Enc_RelativeDistinguishedName(enc, 0, &((val)->value)[i]))
  1013. return 0;
  1014. }
  1015. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1016. return 0;
  1017. return 1;
  1018. }
  1019. static int ASN1CALL ASN1Dec_Name(ASN1decoding_t dec, ASN1uint32_t tag, Name *val)
  1020. {
  1021. ASN1decoding_t dd;
  1022. ASN1octet_t *di;
  1023. ASN1uint32_t t;
  1024. ASN1uint32_t n;
  1025. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1026. return 0;
  1027. (val)->count = n = 0;
  1028. (val)->value = NULL;
  1029. while (ASN1BERDecNotEndOfContents(dd, di)) {
  1030. if (!ASN1BERDecPeekTag(dd, &t))
  1031. return 0;
  1032. if ((val)->count >= n) {
  1033. void *pvASN1DecRealloc;
  1034. n = n ? (n << 1) : 16;
  1035. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  1036. return 0;
  1037. (val)->value = (RelativeDistinguishedName *) pvASN1DecRealloc;
  1038. }
  1039. if (!ASN1Dec_RelativeDistinguishedName(dd, 0, &((val)->value)[(val)->count]))
  1040. return 0;
  1041. ((val)->count)++;
  1042. }
  1043. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1044. return 0;
  1045. return 1;
  1046. }
  1047. static void ASN1CALL ASN1Free_Name(Name *val)
  1048. {
  1049. ASN1uint32_t i;
  1050. if (val) {
  1051. ASN1Free_RelativeDistinguishedName(&(val)->value[0]);
  1052. for (i = 1; i < (val)->count; i++) {
  1053. ASN1Free_RelativeDistinguishedName(&(val)->value[i]);
  1054. }
  1055. ASN1Free((val)->value);
  1056. }
  1057. }
  1058. static int ASN1CALL ASN1Enc_RelativeDistinguishedName(ASN1encoding_t enc, ASN1uint32_t tag, RelativeDistinguishedName *val)
  1059. {
  1060. ASN1uint32_t nLenOff;
  1061. void *pBlk;
  1062. ASN1uint32_t i;
  1063. ASN1encoding_t enc2;
  1064. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x11, &nLenOff))
  1065. return 0;
  1066. if (!ASN1DEREncBeginBlk(enc, ASN1_DER_SET_OF_BLOCK, &pBlk))
  1067. return 0;
  1068. for (i = 0; i < (val)->count; i++) {
  1069. if (!ASN1DEREncNewBlkElement(pBlk, &enc2))
  1070. return 0;
  1071. if (!ASN1Enc_AttributeTypeValue(enc2, 0, &((val)->value)[i]))
  1072. return 0;
  1073. if (!ASN1DEREncFlushBlkElement(pBlk))
  1074. return 0;
  1075. }
  1076. if (!ASN1DEREncEndBlk(pBlk))
  1077. return 0;
  1078. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1079. return 0;
  1080. return 1;
  1081. }
  1082. static int ASN1CALL ASN1Dec_RelativeDistinguishedName(ASN1decoding_t dec, ASN1uint32_t tag, RelativeDistinguishedName *val)
  1083. {
  1084. ASN1decoding_t dd;
  1085. ASN1octet_t *di;
  1086. ASN1uint32_t t;
  1087. ASN1uint32_t n;
  1088. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x11, &dd, &di))
  1089. return 0;
  1090. (val)->count = n = 0;
  1091. (val)->value = NULL;
  1092. while (ASN1BERDecNotEndOfContents(dd, di)) {
  1093. if (!ASN1BERDecPeekTag(dd, &t))
  1094. return 0;
  1095. if ((val)->count >= n) {
  1096. void *pvASN1DecRealloc;
  1097. n = n ? (n << 1) : 16;
  1098. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  1099. return 0;
  1100. (val)->value = (AttributeTypeValue *) pvASN1DecRealloc;
  1101. }
  1102. if (!ASN1Dec_AttributeTypeValue(dd, 0, &((val)->value)[(val)->count]))
  1103. return 0;
  1104. ((val)->count)++;
  1105. }
  1106. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1107. return 0;
  1108. return 1;
  1109. }
  1110. static void ASN1CALL ASN1Free_RelativeDistinguishedName(RelativeDistinguishedName *val)
  1111. {
  1112. ASN1uint32_t i;
  1113. if (val) {
  1114. ASN1Free_AttributeTypeValue(&(val)->value[0]);
  1115. for (i = 1; i < (val)->count; i++) {
  1116. ASN1Free_AttributeTypeValue(&(val)->value[i]);
  1117. }
  1118. ASN1Free((val)->value);
  1119. }
  1120. }
  1121. static int ASN1CALL ASN1Enc_AttributeTypeValue(ASN1encoding_t enc, ASN1uint32_t tag, AttributeTypeValue *val)
  1122. {
  1123. ASN1uint32_t nLenOff;
  1124. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1125. return 0;
  1126. if (!ASN1BEREncEoid(enc, 0x6, &(val)->type))
  1127. return 0;
  1128. if (!ASN1BEREncOpenType(enc, &(val)->value))
  1129. return 0;
  1130. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1131. return 0;
  1132. return 1;
  1133. }
  1134. static int ASN1CALL ASN1Dec_AttributeTypeValue(ASN1decoding_t dec, ASN1uint32_t tag, AttributeTypeValue *val)
  1135. {
  1136. ASN1decoding_t dd;
  1137. ASN1octet_t *di;
  1138. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1139. return 0;
  1140. if (!ASN1BERDecEoid(dd, 0x6, &(val)->type))
  1141. return 0;
  1142. if (!ASN1BERDecOpenType2(dd, &(val)->value))
  1143. return 0;
  1144. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1145. return 0;
  1146. return 1;
  1147. }
  1148. static void ASN1CALL ASN1Free_AttributeTypeValue(AttributeTypeValue *val)
  1149. {
  1150. if (val) {
  1151. ASN1BEREoid_free(&(val)->type);
  1152. }
  1153. }
  1154. static int ASN1CALL ASN1Enc_AttributeSetValue(ASN1encoding_t enc, ASN1uint32_t tag, AttributeSetValue *val)
  1155. {
  1156. ASN1uint32_t nLenOff;
  1157. void *pBlk;
  1158. ASN1uint32_t i;
  1159. ASN1encoding_t enc2;
  1160. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x11, &nLenOff))
  1161. return 0;
  1162. if (!ASN1DEREncBeginBlk(enc, ASN1_DER_SET_OF_BLOCK, &pBlk))
  1163. return 0;
  1164. for (i = 0; i < (val)->count; i++) {
  1165. if (!ASN1DEREncNewBlkElement(pBlk, &enc2))
  1166. return 0;
  1167. if (!ASN1BEREncOpenType(enc2, &((val)->value)[i]))
  1168. return 0;
  1169. if (!ASN1DEREncFlushBlkElement(pBlk))
  1170. return 0;
  1171. }
  1172. if (!ASN1DEREncEndBlk(pBlk))
  1173. return 0;
  1174. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1175. return 0;
  1176. return 1;
  1177. }
  1178. static int ASN1CALL ASN1Dec_AttributeSetValue(ASN1decoding_t dec, ASN1uint32_t tag, AttributeSetValue *val)
  1179. {
  1180. ASN1decoding_t dd;
  1181. ASN1octet_t *di;
  1182. ASN1uint32_t t;
  1183. ASN1uint32_t n;
  1184. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x11, &dd, &di))
  1185. return 0;
  1186. (val)->count = n = 0;
  1187. (val)->value = NULL;
  1188. while (ASN1BERDecNotEndOfContents(dd, di)) {
  1189. if (!ASN1BERDecPeekTag(dd, &t))
  1190. return 0;
  1191. if ((val)->count >= n) {
  1192. void *pvASN1DecRealloc;
  1193. n = n ? (n << 1) : 16;
  1194. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  1195. return 0;
  1196. (val)->value = (NOCOPYANY *) pvASN1DecRealloc;
  1197. }
  1198. if (!ASN1BERDecOpenType2(dd, &((val)->value)[(val)->count]))
  1199. return 0;
  1200. ((val)->count)++;
  1201. }
  1202. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1203. return 0;
  1204. return 1;
  1205. }
  1206. static void ASN1CALL ASN1Free_AttributeSetValue(AttributeSetValue *val)
  1207. {
  1208. ASN1uint32_t i;
  1209. if (val) {
  1210. for (i = 1; i < (val)->count; i++) {
  1211. }
  1212. ASN1Free((val)->value);
  1213. }
  1214. }
  1215. static int ASN1CALL ASN1Enc_Attributes(ASN1encoding_t enc, ASN1uint32_t tag, Attributes *val)
  1216. {
  1217. ASN1uint32_t nLenOff;
  1218. void *pBlk;
  1219. ASN1uint32_t i;
  1220. ASN1encoding_t enc2;
  1221. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x11, &nLenOff))
  1222. return 0;
  1223. if (!ASN1DEREncBeginBlk(enc, ASN1_DER_SET_OF_BLOCK, &pBlk))
  1224. return 0;
  1225. for (i = 0; i < (val)->count; i++) {
  1226. if (!ASN1DEREncNewBlkElement(pBlk, &enc2))
  1227. return 0;
  1228. if (!ASN1Enc_Attribute(enc2, 0, &((val)->value)[i]))
  1229. return 0;
  1230. if (!ASN1DEREncFlushBlkElement(pBlk))
  1231. return 0;
  1232. }
  1233. if (!ASN1DEREncEndBlk(pBlk))
  1234. return 0;
  1235. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1236. return 0;
  1237. return 1;
  1238. }
  1239. static int ASN1CALL ASN1Dec_Attributes(ASN1decoding_t dec, ASN1uint32_t tag, Attributes *val)
  1240. {
  1241. ASN1decoding_t dd;
  1242. ASN1octet_t *di;
  1243. ASN1uint32_t t;
  1244. ASN1uint32_t n;
  1245. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x11, &dd, &di))
  1246. return 0;
  1247. (val)->count = n = 0;
  1248. (val)->value = NULL;
  1249. while (ASN1BERDecNotEndOfContents(dd, di)) {
  1250. if (!ASN1BERDecPeekTag(dd, &t))
  1251. return 0;
  1252. if ((val)->count >= n) {
  1253. void *pvASN1DecRealloc;
  1254. n = n ? (n << 1) : 16;
  1255. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  1256. return 0;
  1257. (val)->value = (Attribute *) pvASN1DecRealloc;
  1258. }
  1259. if (!ASN1Dec_Attribute(dd, 0, &((val)->value)[(val)->count]))
  1260. return 0;
  1261. ((val)->count)++;
  1262. }
  1263. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1264. return 0;
  1265. return 1;
  1266. }
  1267. static void ASN1CALL ASN1Free_Attributes(Attributes *val)
  1268. {
  1269. ASN1uint32_t i;
  1270. if (val) {
  1271. ASN1Free_Attribute(&(val)->value[0]);
  1272. for (i = 1; i < (val)->count; i++) {
  1273. ASN1Free_Attribute(&(val)->value[i]);
  1274. }
  1275. ASN1Free((val)->value);
  1276. }
  1277. }
  1278. static int ASN1CALL ASN1Enc_RSAPublicKey(ASN1encoding_t enc, ASN1uint32_t tag, RSAPublicKey *val)
  1279. {
  1280. ASN1uint32_t nLenOff;
  1281. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1282. return 0;
  1283. if (!ASN1BEREncSX(enc, 0x2, &(val)->modulus))
  1284. return 0;
  1285. if (!ASN1BEREncU32(enc, 0x2, (val)->publicExponent))
  1286. return 0;
  1287. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1288. return 0;
  1289. return 1;
  1290. }
  1291. static int ASN1CALL ASN1Dec_RSAPublicKey(ASN1decoding_t dec, ASN1uint32_t tag, RSAPublicKey *val)
  1292. {
  1293. ASN1decoding_t dd;
  1294. ASN1octet_t *di;
  1295. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1296. return 0;
  1297. if (!ASN1BERDecSXVal(dd, 0x2, &(val)->modulus))
  1298. return 0;
  1299. if (!ASN1BERDecU32Val(dd, 0x2, (ASN1uint32_t *) &(val)->publicExponent))
  1300. return 0;
  1301. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1302. return 0;
  1303. return 1;
  1304. }
  1305. static void ASN1CALL ASN1Free_RSAPublicKey(RSAPublicKey *val)
  1306. {
  1307. if (val) {
  1308. ASN1intx_free(&(val)->modulus);
  1309. }
  1310. }
  1311. static int ASN1CALL ASN1Enc_DSSParameters(ASN1encoding_t enc, ASN1uint32_t tag, DSSParameters *val)
  1312. {
  1313. ASN1uint32_t nLenOff;
  1314. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1315. return 0;
  1316. if (!ASN1BEREncSX(enc, 0x2, &(val)->p))
  1317. return 0;
  1318. if (!ASN1BEREncSX(enc, 0x2, &(val)->q))
  1319. return 0;
  1320. if (!ASN1BEREncSX(enc, 0x2, &(val)->g))
  1321. return 0;
  1322. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1323. return 0;
  1324. return 1;
  1325. }
  1326. static int ASN1CALL ASN1Dec_DSSParameters(ASN1decoding_t dec, ASN1uint32_t tag, DSSParameters *val)
  1327. {
  1328. ASN1decoding_t dd;
  1329. ASN1octet_t *di;
  1330. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1331. return 0;
  1332. if (!ASN1BERDecSXVal(dd, 0x2, &(val)->p))
  1333. return 0;
  1334. if (!ASN1BERDecSXVal(dd, 0x2, &(val)->q))
  1335. return 0;
  1336. if (!ASN1BERDecSXVal(dd, 0x2, &(val)->g))
  1337. return 0;
  1338. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1339. return 0;
  1340. return 1;
  1341. }
  1342. static void ASN1CALL ASN1Free_DSSParameters(DSSParameters *val)
  1343. {
  1344. if (val) {
  1345. ASN1intx_free(&(val)->p);
  1346. ASN1intx_free(&(val)->q);
  1347. ASN1intx_free(&(val)->g);
  1348. }
  1349. }
  1350. static int ASN1CALL ASN1Enc_DSSSignature(ASN1encoding_t enc, ASN1uint32_t tag, DSSSignature *val)
  1351. {
  1352. ASN1uint32_t nLenOff;
  1353. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1354. return 0;
  1355. if (!ASN1BEREncSX(enc, 0x2, &(val)->r))
  1356. return 0;
  1357. if (!ASN1BEREncSX(enc, 0x2, &(val)->s))
  1358. return 0;
  1359. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1360. return 0;
  1361. return 1;
  1362. }
  1363. static int ASN1CALL ASN1Dec_DSSSignature(ASN1decoding_t dec, ASN1uint32_t tag, DSSSignature *val)
  1364. {
  1365. ASN1decoding_t dd;
  1366. ASN1octet_t *di;
  1367. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1368. return 0;
  1369. if (!ASN1BERDecSXVal(dd, 0x2, &(val)->r))
  1370. return 0;
  1371. if (!ASN1BERDecSXVal(dd, 0x2, &(val)->s))
  1372. return 0;
  1373. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1374. return 0;
  1375. return 1;
  1376. }
  1377. static void ASN1CALL ASN1Free_DSSSignature(DSSSignature *val)
  1378. {
  1379. if (val) {
  1380. ASN1intx_free(&(val)->r);
  1381. ASN1intx_free(&(val)->s);
  1382. }
  1383. }
  1384. static int ASN1CALL ASN1Enc_DHParameters(ASN1encoding_t enc, ASN1uint32_t tag, DHParameters *val)
  1385. {
  1386. ASN1uint32_t nLenOff;
  1387. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1388. return 0;
  1389. if (!ASN1BEREncSX(enc, 0x2, &(val)->p))
  1390. return 0;
  1391. if (!ASN1BEREncSX(enc, 0x2, &(val)->g))
  1392. return 0;
  1393. if ((val)->o[0] & 0x80) {
  1394. if (!ASN1BEREncSX(enc, 0x2, &(val)->privateValueLength))
  1395. return 0;
  1396. }
  1397. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1398. return 0;
  1399. return 1;
  1400. }
  1401. static int ASN1CALL ASN1Dec_DHParameters(ASN1decoding_t dec, ASN1uint32_t tag, DHParameters *val)
  1402. {
  1403. ASN1decoding_t dd;
  1404. ASN1octet_t *di;
  1405. ASN1uint32_t t;
  1406. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1407. return 0;
  1408. ZeroMemory((val)->o, 1);
  1409. if (!ASN1BERDecSXVal(dd, 0x2, &(val)->p))
  1410. return 0;
  1411. if (!ASN1BERDecSXVal(dd, 0x2, &(val)->g))
  1412. return 0;
  1413. ASN1BERDecPeekTag(dd, &t);
  1414. if (t == 0x2) {
  1415. (val)->o[0] |= 0x80;
  1416. if (!ASN1BERDecSXVal(dd, 0x2, &(val)->privateValueLength))
  1417. return 0;
  1418. }
  1419. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1420. return 0;
  1421. return 1;
  1422. }
  1423. static void ASN1CALL ASN1Free_DHParameters(DHParameters *val)
  1424. {
  1425. if (val) {
  1426. ASN1intx_free(&(val)->p);
  1427. ASN1intx_free(&(val)->g);
  1428. if ((val)->o[0] & 0x80) {
  1429. ASN1intx_free(&(val)->privateValueLength);
  1430. }
  1431. }
  1432. }
  1433. static int ASN1CALL ASN1Enc_X942DhValidationParams(ASN1encoding_t enc, ASN1uint32_t tag, X942DhValidationParams *val)
  1434. {
  1435. ASN1uint32_t nLenOff;
  1436. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1437. return 0;
  1438. if (!ASN1DEREncBitString(enc, 0x3, ((val)->seed).length, ((val)->seed).value))
  1439. return 0;
  1440. if (!ASN1BEREncU32(enc, 0x2, (val)->pgenCounter))
  1441. return 0;
  1442. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1443. return 0;
  1444. return 1;
  1445. }
  1446. static int ASN1CALL ASN1Dec_X942DhValidationParams(ASN1decoding_t dec, ASN1uint32_t tag, X942DhValidationParams *val)
  1447. {
  1448. ASN1decoding_t dd;
  1449. ASN1octet_t *di;
  1450. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1451. return 0;
  1452. if (!ASN1BERDecBitString2(dd, 0x3, &(val)->seed))
  1453. return 0;
  1454. if (!ASN1BERDecU32Val(dd, 0x2, (ASN1uint32_t *) &(val)->pgenCounter))
  1455. return 0;
  1456. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1457. return 0;
  1458. return 1;
  1459. }
  1460. static void ASN1CALL ASN1Free_X942DhValidationParams(X942DhValidationParams *val)
  1461. {
  1462. if (val) {
  1463. }
  1464. }
  1465. static int ASN1CALL ASN1Enc_X942DhKeySpecificInfo(ASN1encoding_t enc, ASN1uint32_t tag, X942DhKeySpecificInfo *val)
  1466. {
  1467. ASN1uint32_t nLenOff;
  1468. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1469. return 0;
  1470. if (!ASN1BEREncEoid(enc, 0x6, &(val)->algorithm))
  1471. return 0;
  1472. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->counter).length, ((val)->counter).value))
  1473. return 0;
  1474. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1475. return 0;
  1476. return 1;
  1477. }
  1478. static int ASN1CALL ASN1Dec_X942DhKeySpecificInfo(ASN1decoding_t dec, ASN1uint32_t tag, X942DhKeySpecificInfo *val)
  1479. {
  1480. ASN1decoding_t dd;
  1481. ASN1octet_t *di;
  1482. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1483. return 0;
  1484. if (!ASN1BERDecEoid(dd, 0x6, &(val)->algorithm))
  1485. return 0;
  1486. if (!ASN1BERDecOctetString2(dd, 0x4, &(val)->counter))
  1487. return 0;
  1488. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1489. return 0;
  1490. return 1;
  1491. }
  1492. static void ASN1CALL ASN1Free_X942DhKeySpecificInfo(X942DhKeySpecificInfo *val)
  1493. {
  1494. if (val) {
  1495. ASN1BEREoid_free(&(val)->algorithm);
  1496. }
  1497. }
  1498. static int ASN1CALL ASN1Enc_RC2CBCParameters(ASN1encoding_t enc, ASN1uint32_t tag, RC2CBCParameters *val)
  1499. {
  1500. ASN1uint32_t nLenOff;
  1501. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1502. return 0;
  1503. if (!ASN1BEREncS32(enc, 0x2, (val)->version))
  1504. return 0;
  1505. if ((val)->o[0] & 0x80) {
  1506. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->iv).length, ((val)->iv).value))
  1507. return 0;
  1508. }
  1509. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1510. return 0;
  1511. return 1;
  1512. }
  1513. static int ASN1CALL ASN1Dec_RC2CBCParameters(ASN1decoding_t dec, ASN1uint32_t tag, RC2CBCParameters *val)
  1514. {
  1515. ASN1decoding_t dd;
  1516. ASN1octet_t *di;
  1517. ASN1uint32_t t;
  1518. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1519. return 0;
  1520. ZeroMemory((val)->o, 1);
  1521. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->version))
  1522. return 0;
  1523. ASN1BERDecPeekTag(dd, &t);
  1524. if (t == 0x4) {
  1525. (val)->o[0] |= 0x80;
  1526. if (!ASN1BERDecOctetString2(dd, 0x4, &(val)->iv))
  1527. return 0;
  1528. }
  1529. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1530. return 0;
  1531. return 1;
  1532. }
  1533. static void ASN1CALL ASN1Free_RC2CBCParameters(RC2CBCParameters *val)
  1534. {
  1535. if (val) {
  1536. if ((val)->o[0] & 0x80) {
  1537. }
  1538. }
  1539. }
  1540. static int ASN1CALL ASN1Enc_SMIMECapability(ASN1encoding_t enc, ASN1uint32_t tag, SMIMECapability *val)
  1541. {
  1542. ASN1uint32_t nLenOff;
  1543. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1544. return 0;
  1545. if (!ASN1BEREncEoid(enc, 0x6, &(val)->capabilityID))
  1546. return 0;
  1547. if ((val)->o[0] & 0x80) {
  1548. if (!ASN1BEREncOpenType(enc, &(val)->smimeParameters))
  1549. return 0;
  1550. }
  1551. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1552. return 0;
  1553. return 1;
  1554. }
  1555. static int ASN1CALL ASN1Dec_SMIMECapability(ASN1decoding_t dec, ASN1uint32_t tag, SMIMECapability *val)
  1556. {
  1557. ASN1decoding_t dd;
  1558. ASN1octet_t *di;
  1559. ASN1uint32_t t;
  1560. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1561. return 0;
  1562. ZeroMemory((val)->o, 1);
  1563. if (!ASN1BERDecEoid(dd, 0x6, &(val)->capabilityID))
  1564. return 0;
  1565. if (ASN1BERDecPeekTag(dd, &t)) {
  1566. (val)->o[0] |= 0x80;
  1567. if (!ASN1BERDecOpenType2(dd, &(val)->smimeParameters))
  1568. return 0;
  1569. }
  1570. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1571. return 0;
  1572. return 1;
  1573. }
  1574. static void ASN1CALL ASN1Free_SMIMECapability(SMIMECapability *val)
  1575. {
  1576. if (val) {
  1577. ASN1BEREoid_free(&(val)->capabilityID);
  1578. if ((val)->o[0] & 0x80) {
  1579. }
  1580. }
  1581. }
  1582. static int ASN1CALL ASN1Enc_SMIMECapabilities(ASN1encoding_t enc, ASN1uint32_t tag, SMIMECapabilities *val)
  1583. {
  1584. ASN1uint32_t nLenOff;
  1585. ASN1uint32_t i;
  1586. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1587. return 0;
  1588. for (i = 0; i < (val)->count; i++) {
  1589. if (!ASN1Enc_SMIMECapability(enc, 0, &((val)->value)[i]))
  1590. return 0;
  1591. }
  1592. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1593. return 0;
  1594. return 1;
  1595. }
  1596. static int ASN1CALL ASN1Dec_SMIMECapabilities(ASN1decoding_t dec, ASN1uint32_t tag, SMIMECapabilities *val)
  1597. {
  1598. ASN1decoding_t dd;
  1599. ASN1octet_t *di;
  1600. ASN1uint32_t t;
  1601. ASN1uint32_t n;
  1602. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1603. return 0;
  1604. (val)->count = n = 0;
  1605. (val)->value = NULL;
  1606. while (ASN1BERDecNotEndOfContents(dd, di)) {
  1607. if (!ASN1BERDecPeekTag(dd, &t))
  1608. return 0;
  1609. if ((val)->count >= n) {
  1610. void *pvASN1DecRealloc;
  1611. n = n ? (n << 1) : 16;
  1612. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  1613. return 0;
  1614. (val)->value = (SMIMECapability *) pvASN1DecRealloc;
  1615. }
  1616. if (!ASN1Dec_SMIMECapability(dd, 0, &((val)->value)[(val)->count]))
  1617. return 0;
  1618. ((val)->count)++;
  1619. }
  1620. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1621. return 0;
  1622. return 1;
  1623. }
  1624. static void ASN1CALL ASN1Free_SMIMECapabilities(SMIMECapabilities *val)
  1625. {
  1626. ASN1uint32_t i;
  1627. if (val) {
  1628. ASN1Free_SMIMECapability(&(val)->value[0]);
  1629. for (i = 1; i < (val)->count; i++) {
  1630. ASN1Free_SMIMECapability(&(val)->value[i]);
  1631. }
  1632. ASN1Free((val)->value);
  1633. }
  1634. }
  1635. static int ASN1CALL ASN1Enc_SubjectPublicKeyInfo(ASN1encoding_t enc, ASN1uint32_t tag, SubjectPublicKeyInfo *val)
  1636. {
  1637. ASN1uint32_t nLenOff;
  1638. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1639. return 0;
  1640. if (!ASN1Enc_AlgorithmIdentifier(enc, 0, &(val)->algorithm))
  1641. return 0;
  1642. if (!ASN1DEREncBitString(enc, 0x3, ((val)->subjectPublicKey).length, ((val)->subjectPublicKey).value))
  1643. return 0;
  1644. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1645. return 0;
  1646. return 1;
  1647. }
  1648. static int ASN1CALL ASN1Dec_SubjectPublicKeyInfo(ASN1decoding_t dec, ASN1uint32_t tag, SubjectPublicKeyInfo *val)
  1649. {
  1650. ASN1decoding_t dd;
  1651. ASN1octet_t *di;
  1652. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1653. return 0;
  1654. if (!ASN1Dec_AlgorithmIdentifier(dd, 0, &(val)->algorithm))
  1655. return 0;
  1656. if (!ASN1BERDecBitString2(dd, 0x3, &(val)->subjectPublicKey))
  1657. return 0;
  1658. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1659. return 0;
  1660. return 1;
  1661. }
  1662. static void ASN1CALL ASN1Free_SubjectPublicKeyInfo(SubjectPublicKeyInfo *val)
  1663. {
  1664. if (val) {
  1665. ASN1Free_AlgorithmIdentifier(&(val)->algorithm);
  1666. }
  1667. }
  1668. static int ASN1CALL ASN1Enc_ChoiceOfTime(ASN1encoding_t enc, ASN1uint32_t tag, ChoiceOfTime *val)
  1669. {
  1670. switch ((val)->choice) {
  1671. case 1:
  1672. if (!ASN1DEREncUTCTime(enc, 0x17, &(val)->u.utcTime))
  1673. return 0;
  1674. break;
  1675. case 2:
  1676. if (!ASN1DEREncGeneralizedTime(enc, 0x18, &(val)->u.generalTime))
  1677. return 0;
  1678. break;
  1679. default:
  1680. /* impossible */
  1681. ASN1EncSetError(enc, ASN1_ERR_CHOICE);
  1682. return 0;
  1683. }
  1684. return 1;
  1685. }
  1686. static int ASN1CALL ASN1Dec_ChoiceOfTime(ASN1decoding_t dec, ASN1uint32_t tag, ChoiceOfTime *val)
  1687. {
  1688. ASN1uint32_t t;
  1689. if (!ASN1BERDecPeekTag(dec, &t))
  1690. return 0;
  1691. switch (t) {
  1692. case 0x17:
  1693. (val)->choice = 1;
  1694. if (!ASN1BERDecUTCTime(dec, 0x17, &(val)->u.utcTime))
  1695. return 0;
  1696. break;
  1697. case 0x18:
  1698. (val)->choice = 2;
  1699. if (!ASN1BERDecGeneralizedTime(dec, 0x18, &(val)->u.generalTime))
  1700. return 0;
  1701. break;
  1702. default:
  1703. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  1704. return 0;
  1705. }
  1706. return 1;
  1707. }
  1708. static void ASN1CALL ASN1Free_ChoiceOfTime(ChoiceOfTime *val)
  1709. {
  1710. if (val) {
  1711. switch ((val)->choice) {
  1712. case 1:
  1713. break;
  1714. case 2:
  1715. break;
  1716. }
  1717. }
  1718. }
  1719. static int ASN1CALL ASN1Enc_Validity(ASN1encoding_t enc, ASN1uint32_t tag, Validity *val)
  1720. {
  1721. ASN1uint32_t nLenOff;
  1722. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1723. return 0;
  1724. if (!ASN1Enc_ChoiceOfTime(enc, 0, &(val)->notBefore))
  1725. return 0;
  1726. if (!ASN1Enc_ChoiceOfTime(enc, 0, &(val)->notAfter))
  1727. return 0;
  1728. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1729. return 0;
  1730. return 1;
  1731. }
  1732. static int ASN1CALL ASN1Dec_Validity(ASN1decoding_t dec, ASN1uint32_t tag, Validity *val)
  1733. {
  1734. ASN1decoding_t dd;
  1735. ASN1octet_t *di;
  1736. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1737. return 0;
  1738. if (!ASN1Dec_ChoiceOfTime(dd, 0, &(val)->notBefore))
  1739. return 0;
  1740. if (!ASN1Dec_ChoiceOfTime(dd, 0, &(val)->notAfter))
  1741. return 0;
  1742. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1743. return 0;
  1744. return 1;
  1745. }
  1746. static void ASN1CALL ASN1Free_Validity(Validity *val)
  1747. {
  1748. if (val) {
  1749. ASN1Free_ChoiceOfTime(&(val)->notBefore);
  1750. ASN1Free_ChoiceOfTime(&(val)->notAfter);
  1751. }
  1752. }
  1753. static int ASN1CALL ASN1Enc_Extensions(ASN1encoding_t enc, ASN1uint32_t tag, Extensions *val)
  1754. {
  1755. ASN1uint32_t nLenOff;
  1756. ASN1uint32_t i;
  1757. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1758. return 0;
  1759. for (i = 0; i < (val)->count; i++) {
  1760. if (!ASN1Enc_Extension(enc, 0, &((val)->value)[i]))
  1761. return 0;
  1762. }
  1763. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1764. return 0;
  1765. return 1;
  1766. }
  1767. static int ASN1CALL ASN1Dec_Extensions(ASN1decoding_t dec, ASN1uint32_t tag, Extensions *val)
  1768. {
  1769. ASN1decoding_t dd;
  1770. ASN1octet_t *di;
  1771. ASN1uint32_t t;
  1772. ASN1uint32_t n;
  1773. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1774. return 0;
  1775. (val)->count = n = 0;
  1776. (val)->value = NULL;
  1777. while (ASN1BERDecNotEndOfContents(dd, di)) {
  1778. if (!ASN1BERDecPeekTag(dd, &t))
  1779. return 0;
  1780. if ((val)->count >= n) {
  1781. void *pvASN1DecRealloc;
  1782. n = n ? (n << 1) : 16;
  1783. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  1784. return 0;
  1785. (val)->value = (Extension *) pvASN1DecRealloc;
  1786. }
  1787. if (!ASN1Dec_Extension(dd, 0, &((val)->value)[(val)->count]))
  1788. return 0;
  1789. ((val)->count)++;
  1790. }
  1791. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1792. return 0;
  1793. return 1;
  1794. }
  1795. static void ASN1CALL ASN1Free_Extensions(Extensions *val)
  1796. {
  1797. ASN1uint32_t i;
  1798. if (val) {
  1799. ASN1Free_Extension(&(val)->value[0]);
  1800. for (i = 1; i < (val)->count; i++) {
  1801. ASN1Free_Extension(&(val)->value[i]);
  1802. }
  1803. ASN1Free((val)->value);
  1804. }
  1805. }
  1806. static int ASN1CALL ASN1Enc_Extension(ASN1encoding_t enc, ASN1uint32_t tag, Extension *val)
  1807. {
  1808. ASN1uint32_t nLenOff;
  1809. ASN1octet_t o[1];
  1810. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1811. return 0;
  1812. CopyMemory(o, (val)->o, 1);
  1813. if (!(val)->critical)
  1814. o[0] &= ~0x80;
  1815. if (!ASN1BEREncEoid(enc, 0x6, &(val)->extnId))
  1816. return 0;
  1817. if (o[0] & 0x80) {
  1818. if (!ASN1BEREncBool(enc, 0x1, (val)->critical))
  1819. return 0;
  1820. }
  1821. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->extnValue).length, ((val)->extnValue).value))
  1822. return 0;
  1823. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1824. return 0;
  1825. return 1;
  1826. }
  1827. static int ASN1CALL ASN1Dec_Extension(ASN1decoding_t dec, ASN1uint32_t tag, Extension *val)
  1828. {
  1829. ASN1decoding_t dd;
  1830. ASN1octet_t *di;
  1831. ASN1uint32_t t;
  1832. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1833. return 0;
  1834. ZeroMemory((val)->o, 1);
  1835. if (!ASN1BERDecEoid(dd, 0x6, &(val)->extnId))
  1836. return 0;
  1837. ASN1BERDecPeekTag(dd, &t);
  1838. if (t == 0x1) {
  1839. (val)->o[0] |= 0x80;
  1840. if (!ASN1BERDecBool(dd, 0x1, &(val)->critical))
  1841. return 0;
  1842. }
  1843. if (!ASN1BERDecOctetString2(dd, 0x4, &(val)->extnValue))
  1844. return 0;
  1845. if (!((val)->o[0] & 0x80))
  1846. (val)->critical = 0;
  1847. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1848. return 0;
  1849. return 1;
  1850. }
  1851. static void ASN1CALL ASN1Free_Extension(Extension *val)
  1852. {
  1853. if (val) {
  1854. ASN1BEREoid_free(&(val)->extnId);
  1855. }
  1856. }
  1857. static int ASN1CALL ASN1Enc_SignedContent(ASN1encoding_t enc, ASN1uint32_t tag, SignedContent *val)
  1858. {
  1859. ASN1uint32_t nLenOff;
  1860. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1861. return 0;
  1862. if (!ASN1BEREncOpenType(enc, &(val)->toBeSigned))
  1863. return 0;
  1864. if (!ASN1Enc_AlgorithmIdentifier(enc, 0, &(val)->algorithm))
  1865. return 0;
  1866. if (!ASN1DEREncBitString(enc, 0x3, ((val)->signature).length, ((val)->signature).value))
  1867. return 0;
  1868. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1869. return 0;
  1870. return 1;
  1871. }
  1872. static int ASN1CALL ASN1Dec_SignedContent(ASN1decoding_t dec, ASN1uint32_t tag, SignedContent *val)
  1873. {
  1874. ASN1decoding_t dd;
  1875. ASN1octet_t *di;
  1876. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1877. return 0;
  1878. if (!ASN1BERDecOpenType2(dd, &(val)->toBeSigned))
  1879. return 0;
  1880. if (!ASN1Dec_AlgorithmIdentifier(dd, 0, &(val)->algorithm))
  1881. return 0;
  1882. if (!ASN1BERDecBitString2(dd, 0x3, &(val)->signature))
  1883. return 0;
  1884. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1885. return 0;
  1886. return 1;
  1887. }
  1888. static void ASN1CALL ASN1Free_SignedContent(SignedContent *val)
  1889. {
  1890. if (val) {
  1891. ASN1Free_AlgorithmIdentifier(&(val)->algorithm);
  1892. }
  1893. }
  1894. static int ASN1CALL ASN1Enc_RevokedCertificates(ASN1encoding_t enc, ASN1uint32_t tag, RevokedCertificates *val)
  1895. {
  1896. ASN1uint32_t nLenOff;
  1897. ASN1uint32_t i;
  1898. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1899. return 0;
  1900. for (i = 0; i < (val)->count; i++) {
  1901. if (!ASN1Enc_CRLEntry(enc, 0, &((val)->value)[i]))
  1902. return 0;
  1903. }
  1904. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1905. return 0;
  1906. return 1;
  1907. }
  1908. static int ASN1CALL ASN1Dec_RevokedCertificates(ASN1decoding_t dec, ASN1uint32_t tag, RevokedCertificates *val)
  1909. {
  1910. ASN1decoding_t dd;
  1911. ASN1octet_t *di;
  1912. ASN1uint32_t t;
  1913. ASN1uint32_t n;
  1914. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1915. return 0;
  1916. (val)->count = n = 0;
  1917. (val)->value = NULL;
  1918. while (ASN1BERDecNotEndOfContents(dd, di)) {
  1919. if (!ASN1BERDecPeekTag(dd, &t))
  1920. return 0;
  1921. if ((val)->count >= n) {
  1922. void *pvASN1DecRealloc;
  1923. n = n ? (n << 1) : 16;
  1924. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  1925. return 0;
  1926. (val)->value = (CRLEntry *) pvASN1DecRealloc;
  1927. }
  1928. if (!ASN1Dec_CRLEntry(dd, 0, &((val)->value)[(val)->count]))
  1929. return 0;
  1930. ((val)->count)++;
  1931. }
  1932. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1933. return 0;
  1934. return 1;
  1935. }
  1936. static void ASN1CALL ASN1Free_RevokedCertificates(RevokedCertificates *val)
  1937. {
  1938. ASN1uint32_t i;
  1939. if (val) {
  1940. ASN1Free_CRLEntry(&(val)->value[0]);
  1941. for (i = 1; i < (val)->count; i++) {
  1942. ASN1Free_CRLEntry(&(val)->value[i]);
  1943. }
  1944. ASN1Free((val)->value);
  1945. }
  1946. }
  1947. static int ASN1CALL ASN1Enc_CRLEntry(ASN1encoding_t enc, ASN1uint32_t tag, CRLEntry *val)
  1948. {
  1949. ASN1uint32_t nLenOff;
  1950. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  1951. return 0;
  1952. if (!ASN1BEREncSX(enc, 0x2, &(val)->userCertificate))
  1953. return 0;
  1954. if (!ASN1Enc_ChoiceOfTime(enc, 0, &(val)->revocationDate))
  1955. return 0;
  1956. if ((val)->o[0] & 0x80) {
  1957. if (!ASN1Enc_Extensions(enc, 0, &(val)->crlEntryExtensions))
  1958. return 0;
  1959. }
  1960. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  1961. return 0;
  1962. return 1;
  1963. }
  1964. static int ASN1CALL ASN1Dec_CRLEntry(ASN1decoding_t dec, ASN1uint32_t tag, CRLEntry *val)
  1965. {
  1966. ASN1decoding_t dd;
  1967. ASN1octet_t *di;
  1968. ASN1uint32_t t;
  1969. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  1970. return 0;
  1971. ZeroMemory((val)->o, 1);
  1972. if (!ASN1BERDecSXVal(dd, 0x2, &(val)->userCertificate))
  1973. return 0;
  1974. if (!ASN1Dec_ChoiceOfTime(dd, 0, &(val)->revocationDate))
  1975. return 0;
  1976. ASN1BERDecPeekTag(dd, &t);
  1977. if (t == 0x10) {
  1978. (val)->o[0] |= 0x80;
  1979. if (!ASN1Dec_Extensions(dd, 0, &(val)->crlEntryExtensions))
  1980. return 0;
  1981. }
  1982. if (!ASN1BERDecEndOfContents(dec, dd, di))
  1983. return 0;
  1984. return 1;
  1985. }
  1986. static void ASN1CALL ASN1Free_CRLEntry(CRLEntry *val)
  1987. {
  1988. if (val) {
  1989. ASN1intx_free(&(val)->userCertificate);
  1990. ASN1Free_ChoiceOfTime(&(val)->revocationDate);
  1991. if ((val)->o[0] & 0x80) {
  1992. ASN1Free_Extensions(&(val)->crlEntryExtensions);
  1993. }
  1994. }
  1995. }
  1996. static int ASN1CALL ASN1Enc_CertificationRequestInfo(ASN1encoding_t enc, ASN1uint32_t tag, CertificationRequestInfo *val)
  1997. {
  1998. ASN1uint32_t nLenOff;
  1999. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2000. return 0;
  2001. if (!ASN1BEREncS32(enc, 0x2, (val)->version))
  2002. return 0;
  2003. if (!ASN1BEREncOpenType(enc, &(val)->subject))
  2004. return 0;
  2005. if (!ASN1Enc_SubjectPublicKeyInfo(enc, 0, &(val)->subjectPublicKeyInfo))
  2006. return 0;
  2007. if (!ASN1Enc_Attributes(enc, 0x80000000, &(val)->attributes))
  2008. return 0;
  2009. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2010. return 0;
  2011. return 1;
  2012. }
  2013. static int ASN1CALL ASN1Dec_CertificationRequestInfo(ASN1decoding_t dec, ASN1uint32_t tag, CertificationRequestInfo *val)
  2014. {
  2015. ASN1decoding_t dd;
  2016. ASN1octet_t *di;
  2017. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  2018. return 0;
  2019. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->version))
  2020. return 0;
  2021. if (!ASN1BERDecOpenType2(dd, &(val)->subject))
  2022. return 0;
  2023. if (!ASN1Dec_SubjectPublicKeyInfo(dd, 0, &(val)->subjectPublicKeyInfo))
  2024. return 0;
  2025. if (!ASN1Dec_Attributes(dd, 0x80000000, &(val)->attributes))
  2026. return 0;
  2027. if (!ASN1BERDecEndOfContents(dec, dd, di))
  2028. return 0;
  2029. return 1;
  2030. }
  2031. static void ASN1CALL ASN1Free_CertificationRequestInfo(CertificationRequestInfo *val)
  2032. {
  2033. if (val) {
  2034. ASN1Free_SubjectPublicKeyInfo(&(val)->subjectPublicKeyInfo);
  2035. ASN1Free_Attributes(&(val)->attributes);
  2036. }
  2037. }
  2038. static int ASN1CALL ASN1Enc_CertificationRequestInfoDecode(ASN1encoding_t enc, ASN1uint32_t tag, CertificationRequestInfoDecode *val)
  2039. {
  2040. ASN1uint32_t nLenOff;
  2041. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2042. return 0;
  2043. if (!ASN1BEREncS32(enc, 0x2, (val)->version))
  2044. return 0;
  2045. if (!ASN1BEREncOpenType(enc, &(val)->subject))
  2046. return 0;
  2047. if (!ASN1Enc_SubjectPublicKeyInfo(enc, 0, &(val)->subjectPublicKeyInfo))
  2048. return 0;
  2049. if ((val)->o[0] & 0x80) {
  2050. if (!ASN1Enc_Attributes(enc, 0x80000000, &(val)->attributes))
  2051. return 0;
  2052. }
  2053. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2054. return 0;
  2055. return 1;
  2056. }
  2057. static int ASN1CALL ASN1Dec_CertificationRequestInfoDecode(ASN1decoding_t dec, ASN1uint32_t tag, CertificationRequestInfoDecode *val)
  2058. {
  2059. ASN1decoding_t dd;
  2060. ASN1octet_t *di;
  2061. ASN1uint32_t t;
  2062. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  2063. return 0;
  2064. ZeroMemory((val)->o, 1);
  2065. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->version))
  2066. return 0;
  2067. if (!ASN1BERDecOpenType2(dd, &(val)->subject))
  2068. return 0;
  2069. if (!ASN1Dec_SubjectPublicKeyInfo(dd, 0, &(val)->subjectPublicKeyInfo))
  2070. return 0;
  2071. ASN1BERDecPeekTag(dd, &t);
  2072. if (t == 0x80000000) {
  2073. (val)->o[0] |= 0x80;
  2074. if (!ASN1Dec_Attributes(dd, 0x80000000, &(val)->attributes))
  2075. return 0;
  2076. }
  2077. if (!ASN1BERDecEndOfContents(dec, dd, di))
  2078. return 0;
  2079. return 1;
  2080. }
  2081. static void ASN1CALL ASN1Free_CertificationRequestInfoDecode(CertificationRequestInfoDecode *val)
  2082. {
  2083. if (val) {
  2084. ASN1Free_SubjectPublicKeyInfo(&(val)->subjectPublicKeyInfo);
  2085. if ((val)->o[0] & 0x80) {
  2086. ASN1Free_Attributes(&(val)->attributes);
  2087. }
  2088. }
  2089. }
  2090. static int ASN1CALL ASN1Enc_KeygenRequestInfo(ASN1encoding_t enc, ASN1uint32_t tag, KeygenRequestInfo *val)
  2091. {
  2092. ASN1uint32_t nLenOff;
  2093. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2094. return 0;
  2095. if (!ASN1Enc_SubjectPublicKeyInfo(enc, 0, &(val)->subjectPublicKeyInfo))
  2096. return 0;
  2097. if (!ASN1DEREncCharString(enc, 0x16, ((val)->challenge).length, ((val)->challenge).value))
  2098. return 0;
  2099. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2100. return 0;
  2101. return 1;
  2102. }
  2103. static int ASN1CALL ASN1Dec_KeygenRequestInfo(ASN1decoding_t dec, ASN1uint32_t tag, KeygenRequestInfo *val)
  2104. {
  2105. ASN1decoding_t dd;
  2106. ASN1octet_t *di;
  2107. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  2108. return 0;
  2109. if (!ASN1Dec_SubjectPublicKeyInfo(dd, 0, &(val)->subjectPublicKeyInfo))
  2110. return 0;
  2111. if (!ASN1BERDecCharString(dd, 0x16, &(val)->challenge))
  2112. return 0;
  2113. if (!ASN1BERDecEndOfContents(dec, dd, di))
  2114. return 0;
  2115. return 1;
  2116. }
  2117. static void ASN1CALL ASN1Free_KeygenRequestInfo(KeygenRequestInfo *val)
  2118. {
  2119. if (val) {
  2120. ASN1Free_SubjectPublicKeyInfo(&(val)->subjectPublicKeyInfo);
  2121. ASN1charstring_free(&(val)->challenge);
  2122. }
  2123. }
  2124. static int ASN1CALL ASN1Enc_AuthorityKeyId(ASN1encoding_t enc, ASN1uint32_t tag, AuthorityKeyId *val)
  2125. {
  2126. ASN1uint32_t nLenOff;
  2127. ASN1uint32_t nLenOff0;
  2128. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2129. return 0;
  2130. if ((val)->o[0] & 0x80) {
  2131. if (!ASN1DEREncOctetString(enc, 0x80000000, ((val)->keyIdentifier).length, ((val)->keyIdentifier).value))
  2132. return 0;
  2133. }
  2134. if ((val)->o[0] & 0x40) {
  2135. if (!ASN1BEREncExplicitTag(enc, 0x80000001, &nLenOff0))
  2136. return 0;
  2137. if (!ASN1BEREncOpenType(enc, &(val)->certIssuer))
  2138. return 0;
  2139. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  2140. return 0;
  2141. }
  2142. if ((val)->o[0] & 0x20) {
  2143. if (!ASN1BEREncSX(enc, 0x80000002, &(val)->certSerialNumber))
  2144. return 0;
  2145. }
  2146. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2147. return 0;
  2148. return 1;
  2149. }
  2150. static int ASN1CALL ASN1Dec_AuthorityKeyId(ASN1decoding_t dec, ASN1uint32_t tag, AuthorityKeyId *val)
  2151. {
  2152. ASN1decoding_t dd;
  2153. ASN1octet_t *di;
  2154. ASN1uint32_t t;
  2155. ASN1decoding_t dd0;
  2156. ASN1octet_t *di0;
  2157. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  2158. return 0;
  2159. ZeroMemory((val)->o, 1);
  2160. ASN1BERDecPeekTag(dd, &t);
  2161. if (t == 0x80000000) {
  2162. (val)->o[0] |= 0x80;
  2163. if (!ASN1BERDecOctetString2(dd, 0x80000000, &(val)->keyIdentifier))
  2164. return 0;
  2165. }
  2166. if (ASN1BERDecPeekTag(dd, &t)) {
  2167. if (t == 0x80000001) {
  2168. (val)->o[0] |= 0x40;
  2169. if (!ASN1BERDecExplicitTag(dd, 0x80000001, &dd0, &di0))
  2170. return 0;
  2171. if (!ASN1BERDecOpenType2(dd0, &(val)->certIssuer))
  2172. return 0;
  2173. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  2174. return 0;
  2175. }
  2176. }
  2177. ASN1BERDecPeekTag(dd, &t);
  2178. if (t == 0x80000002) {
  2179. (val)->o[0] |= 0x20;
  2180. if (!ASN1BERDecSXVal(dd, 0x80000002, &(val)->certSerialNumber))
  2181. return 0;
  2182. }
  2183. if (!ASN1BERDecEndOfContents(dec, dd, di))
  2184. return 0;
  2185. return 1;
  2186. }
  2187. static void ASN1CALL ASN1Free_AuthorityKeyId(AuthorityKeyId *val)
  2188. {
  2189. if (val) {
  2190. if ((val)->o[0] & 0x80) {
  2191. }
  2192. if ((val)->o[0] & 0x40) {
  2193. }
  2194. if ((val)->o[0] & 0x20) {
  2195. ASN1intx_free(&(val)->certSerialNumber);
  2196. }
  2197. }
  2198. }
  2199. static int ASN1CALL ASN1Enc_PrivateKeyValidity(ASN1encoding_t enc, ASN1uint32_t tag, PrivateKeyValidity *val)
  2200. {
  2201. ASN1uint32_t nLenOff;
  2202. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2203. return 0;
  2204. if ((val)->o[0] & 0x80) {
  2205. if (!ASN1DEREncGeneralizedTime(enc, 0x80000000, &(val)->notBefore))
  2206. return 0;
  2207. }
  2208. if ((val)->o[0] & 0x40) {
  2209. if (!ASN1DEREncGeneralizedTime(enc, 0x80000001, &(val)->notAfter))
  2210. return 0;
  2211. }
  2212. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2213. return 0;
  2214. return 1;
  2215. }
  2216. static int ASN1CALL ASN1Dec_PrivateKeyValidity(ASN1decoding_t dec, ASN1uint32_t tag, PrivateKeyValidity *val)
  2217. {
  2218. ASN1decoding_t dd;
  2219. ASN1octet_t *di;
  2220. ASN1uint32_t t;
  2221. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  2222. return 0;
  2223. ZeroMemory((val)->o, 1);
  2224. ASN1BERDecPeekTag(dd, &t);
  2225. if (t == 0x80000000) {
  2226. (val)->o[0] |= 0x80;
  2227. if (!ASN1BERDecGeneralizedTime(dd, 0x80000000, &(val)->notBefore))
  2228. return 0;
  2229. }
  2230. ASN1BERDecPeekTag(dd, &t);
  2231. if (t == 0x80000001) {
  2232. (val)->o[0] |= 0x40;
  2233. if (!ASN1BERDecGeneralizedTime(dd, 0x80000001, &(val)->notAfter))
  2234. return 0;
  2235. }
  2236. if (!ASN1BERDecEndOfContents(dec, dd, di))
  2237. return 0;
  2238. return 1;
  2239. }
  2240. static void ASN1CALL ASN1Free_PrivateKeyValidity(PrivateKeyValidity *val)
  2241. {
  2242. if (val) {
  2243. if ((val)->o[0] & 0x80) {
  2244. }
  2245. if ((val)->o[0] & 0x40) {
  2246. }
  2247. }
  2248. }
  2249. static int ASN1CALL ASN1Enc_CertPolicySet(ASN1encoding_t enc, ASN1uint32_t tag, CertPolicySet *val)
  2250. {
  2251. ASN1uint32_t nLenOff;
  2252. ASN1uint32_t i;
  2253. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2254. return 0;
  2255. for (i = 0; i < (val)->count; i++) {
  2256. if (!ASN1Enc_CertPolicyId(enc, 0, &((val)->value)[i]))
  2257. return 0;
  2258. }
  2259. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2260. return 0;
  2261. return 1;
  2262. }
  2263. static int ASN1CALL ASN1Dec_CertPolicySet(ASN1decoding_t dec, ASN1uint32_t tag, CertPolicySet *val)
  2264. {
  2265. ASN1decoding_t dd;
  2266. ASN1octet_t *di;
  2267. ASN1uint32_t t;
  2268. ASN1uint32_t n;
  2269. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  2270. return 0;
  2271. (val)->count = n = 0;
  2272. (val)->value = NULL;
  2273. while (ASN1BERDecNotEndOfContents(dd, di)) {
  2274. if (!ASN1BERDecPeekTag(dd, &t))
  2275. return 0;
  2276. if ((val)->count >= n) {
  2277. void *pvASN1DecRealloc;
  2278. n = n ? (n << 1) : 16;
  2279. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  2280. return 0;
  2281. (val)->value = (CertPolicyId *) pvASN1DecRealloc;
  2282. }
  2283. if (!ASN1Dec_CertPolicyId(dd, 0, &((val)->value)[(val)->count]))
  2284. return 0;
  2285. ((val)->count)++;
  2286. }
  2287. if (!ASN1BERDecEndOfContents(dec, dd, di))
  2288. return 0;
  2289. return 1;
  2290. }
  2291. static void ASN1CALL ASN1Free_CertPolicySet(CertPolicySet *val)
  2292. {
  2293. ASN1uint32_t i;
  2294. if (val) {
  2295. ASN1Free_CertPolicyId(&(val)->value[0]);
  2296. for (i = 1; i < (val)->count; i++) {
  2297. ASN1Free_CertPolicyId(&(val)->value[i]);
  2298. }
  2299. ASN1Free((val)->value);
  2300. }
  2301. }
  2302. static int ASN1CALL ASN1Enc_CertPolicyId(ASN1encoding_t enc, ASN1uint32_t tag, CertPolicyId *val)
  2303. {
  2304. ASN1uint32_t nLenOff;
  2305. ASN1uint32_t i;
  2306. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2307. return 0;
  2308. for (i = 0; i < (val)->count; i++) {
  2309. if (!ASN1BEREncEoid(enc, 0x6, &((val)->value)[i]))
  2310. return 0;
  2311. }
  2312. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2313. return 0;
  2314. return 1;
  2315. }
  2316. static int ASN1CALL ASN1Dec_CertPolicyId(ASN1decoding_t dec, ASN1uint32_t tag, CertPolicyId *val)
  2317. {
  2318. ASN1decoding_t dd;
  2319. ASN1octet_t *di;
  2320. ASN1uint32_t t;
  2321. ASN1uint32_t n;
  2322. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  2323. return 0;
  2324. (val)->count = n = 0;
  2325. (val)->value = NULL;
  2326. while (ASN1BERDecNotEndOfContents(dd, di)) {
  2327. if (!ASN1BERDecPeekTag(dd, &t))
  2328. return 0;
  2329. if ((val)->count >= n) {
  2330. void *pvASN1DecRealloc;
  2331. n = n ? (n << 1) : 16;
  2332. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  2333. return 0;
  2334. (val)->value = (CertPolicyElementId *) pvASN1DecRealloc;
  2335. }
  2336. if (!ASN1BERDecEoid(dd, 0x6, &((val)->value)[(val)->count]))
  2337. return 0;
  2338. ((val)->count)++;
  2339. }
  2340. if (!ASN1BERDecEndOfContents(dec, dd, di))
  2341. return 0;
  2342. return 1;
  2343. }
  2344. static void ASN1CALL ASN1Free_CertPolicyId(CertPolicyId *val)
  2345. {
  2346. ASN1uint32_t i;
  2347. if (val) {
  2348. ASN1BEREoid_free(&(val)->value[0]);
  2349. for (i = 1; i < (val)->count; i++) {
  2350. ASN1BEREoid_free(&(val)->value[i]);
  2351. }
  2352. ASN1Free((val)->value);
  2353. }
  2354. }
  2355. static int ASN1CALL ASN1Enc_AltNames(ASN1encoding_t enc, ASN1uint32_t tag, AltNames *val)
  2356. {
  2357. ASN1uint32_t nLenOff;
  2358. ASN1uint32_t i;
  2359. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2360. return 0;
  2361. for (i = 0; i < (val)->count; i++) {
  2362. if (!ASN1Enc_GeneralName(enc, 0, &((val)->value)[i]))
  2363. return 0;
  2364. }
  2365. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2366. return 0;
  2367. return 1;
  2368. }
  2369. static int ASN1CALL ASN1Dec_AltNames(ASN1decoding_t dec, ASN1uint32_t tag, AltNames *val)
  2370. {
  2371. ASN1decoding_t dd;
  2372. ASN1octet_t *di;
  2373. ASN1uint32_t t;
  2374. ASN1uint32_t n;
  2375. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  2376. return 0;
  2377. (val)->count = n = 0;
  2378. (val)->value = NULL;
  2379. while (ASN1BERDecNotEndOfContents(dd, di)) {
  2380. if (!ASN1BERDecPeekTag(dd, &t))
  2381. return 0;
  2382. if ((val)->count >= n) {
  2383. void *pvASN1DecRealloc;
  2384. n = n ? (n << 1) : 16;
  2385. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  2386. return 0;
  2387. (val)->value = (GeneralName *) pvASN1DecRealloc;
  2388. }
  2389. if (!ASN1Dec_GeneralName(dd, 0, &((val)->value)[(val)->count]))
  2390. return 0;
  2391. ((val)->count)++;
  2392. }
  2393. if (!ASN1BERDecEndOfContents(dec, dd, di))
  2394. return 0;
  2395. return 1;
  2396. }
  2397. static void ASN1CALL ASN1Free_AltNames(AltNames *val)
  2398. {
  2399. ASN1uint32_t i;
  2400. if (val) {
  2401. ASN1Free_GeneralName(&(val)->value[0]);
  2402. for (i = 1; i < (val)->count; i++) {
  2403. ASN1Free_GeneralName(&(val)->value[i]);
  2404. }
  2405. ASN1Free((val)->value);
  2406. }
  2407. }
  2408. static int ASN1CALL ASN1Enc_GeneralNames(ASN1encoding_t enc, ASN1uint32_t tag, GeneralNames *val)
  2409. {
  2410. if (!ASN1Enc_AltNames(enc, tag, val))
  2411. return 0;
  2412. return 1;
  2413. }
  2414. static int ASN1CALL ASN1Dec_GeneralNames(ASN1decoding_t dec, ASN1uint32_t tag, GeneralNames *val)
  2415. {
  2416. if (!ASN1Dec_AltNames(dec, tag, val))
  2417. return 0;
  2418. return 1;
  2419. }
  2420. static void ASN1CALL ASN1Free_GeneralNames(GeneralNames *val)
  2421. {
  2422. if (val) {
  2423. ASN1Free_AltNames(val);
  2424. }
  2425. }
  2426. static int ASN1CALL ASN1Enc_OtherName(ASN1encoding_t enc, ASN1uint32_t tag, OtherName *val)
  2427. {
  2428. ASN1uint32_t nLenOff;
  2429. ASN1uint32_t nLenOff0;
  2430. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2431. return 0;
  2432. if (!ASN1BEREncEoid(enc, 0x6, &(val)->type))
  2433. return 0;
  2434. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  2435. return 0;
  2436. if (!ASN1BEREncOpenType(enc, &(val)->value))
  2437. return 0;
  2438. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  2439. return 0;
  2440. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2441. return 0;
  2442. return 1;
  2443. }
  2444. static int ASN1CALL ASN1Dec_OtherName(ASN1decoding_t dec, ASN1uint32_t tag, OtherName *val)
  2445. {
  2446. ASN1decoding_t dd;
  2447. ASN1octet_t *di;
  2448. ASN1decoding_t dd0;
  2449. ASN1octet_t *di0;
  2450. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  2451. return 0;
  2452. if (!ASN1BERDecEoid(dd, 0x6, &(val)->type))
  2453. return 0;
  2454. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  2455. return 0;
  2456. if (!ASN1BERDecOpenType2(dd0, &(val)->value))
  2457. return 0;
  2458. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  2459. return 0;
  2460. if (!ASN1BERDecEndOfContents(dec, dd, di))
  2461. return 0;
  2462. return 1;
  2463. }
  2464. static void ASN1CALL ASN1Free_OtherName(OtherName *val)
  2465. {
  2466. if (val) {
  2467. ASN1BEREoid_free(&(val)->type);
  2468. }
  2469. }
  2470. static int ASN1CALL ASN1Enc_EDIPartyName(ASN1encoding_t enc, ASN1uint32_t tag, EDIPartyName *val)
  2471. {
  2472. ASN1uint32_t nLenOff;
  2473. ASN1uint32_t nLenOff0;
  2474. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2475. return 0;
  2476. if ((val)->o[0] & 0x80) {
  2477. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  2478. return 0;
  2479. if (!ASN1BEREncOpenType(enc, &(val)->nameAssigner))
  2480. return 0;
  2481. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  2482. return 0;
  2483. }
  2484. if (!ASN1BEREncExplicitTag(enc, 0x80000001, &nLenOff0))
  2485. return 0;
  2486. if (!ASN1BEREncOpenType(enc, &(val)->partyName))
  2487. return 0;
  2488. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  2489. return 0;
  2490. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2491. return 0;
  2492. return 1;
  2493. }
  2494. static int ASN1CALL ASN1Dec_EDIPartyName(ASN1decoding_t dec, ASN1uint32_t tag, EDIPartyName *val)
  2495. {
  2496. ASN1decoding_t dd;
  2497. ASN1octet_t *di;
  2498. ASN1uint32_t t;
  2499. ASN1decoding_t dd0;
  2500. ASN1octet_t *di0;
  2501. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  2502. return 0;
  2503. ZeroMemory((val)->o, 1);
  2504. if (ASN1BERDecPeekTag(dd, &t)) {
  2505. if (t == 0x80000000) {
  2506. (val)->o[0] |= 0x80;
  2507. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  2508. return 0;
  2509. if (!ASN1BERDecOpenType2(dd0, &(val)->nameAssigner))
  2510. return 0;
  2511. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  2512. return 0;
  2513. }
  2514. }
  2515. if (!ASN1BERDecExplicitTag(dd, 0x80000001, &dd0, &di0))
  2516. return 0;
  2517. if (!ASN1BERDecOpenType2(dd0, &(val)->partyName))
  2518. return 0;
  2519. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  2520. return 0;
  2521. if (!ASN1BERDecEndOfContents(dec, dd, di))
  2522. return 0;
  2523. return 1;
  2524. }
  2525. static void ASN1CALL ASN1Free_EDIPartyName(EDIPartyName *val)
  2526. {
  2527. if (val) {
  2528. if ((val)->o[0] & 0x80) {
  2529. }
  2530. }
  2531. }
  2532. static int ASN1CALL ASN1Enc_SubtreesConstraint(ASN1encoding_t enc, ASN1uint32_t tag, SubtreesConstraint *val)
  2533. {
  2534. ASN1uint32_t nLenOff;
  2535. ASN1uint32_t i;
  2536. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2537. return 0;
  2538. for (i = 0; i < (val)->count; i++) {
  2539. if (!ASN1BEREncOpenType(enc, &((val)->value)[i]))
  2540. return 0;
  2541. }
  2542. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2543. return 0;
  2544. return 1;
  2545. }
  2546. static int ASN1CALL ASN1Dec_SubtreesConstraint(ASN1decoding_t dec, ASN1uint32_t tag, SubtreesConstraint *val)
  2547. {
  2548. ASN1decoding_t dd;
  2549. ASN1octet_t *di;
  2550. ASN1uint32_t t;
  2551. ASN1uint32_t n;
  2552. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  2553. return 0;
  2554. (val)->count = n = 0;
  2555. (val)->value = NULL;
  2556. while (ASN1BERDecNotEndOfContents(dd, di)) {
  2557. if (!ASN1BERDecPeekTag(dd, &t))
  2558. return 0;
  2559. if ((val)->count >= n) {
  2560. void *pvASN1DecRealloc;
  2561. n = n ? (n << 1) : 16;
  2562. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  2563. return 0;
  2564. (val)->value = (NOCOPYANY *) pvASN1DecRealloc;
  2565. }
  2566. if (!ASN1BERDecOpenType2(dd, &((val)->value)[(val)->count]))
  2567. return 0;
  2568. ((val)->count)++;
  2569. }
  2570. if (!ASN1BERDecEndOfContents(dec, dd, di))
  2571. return 0;
  2572. return 1;
  2573. }
  2574. static void ASN1CALL ASN1Free_SubtreesConstraint(SubtreesConstraint *val)
  2575. {
  2576. ASN1uint32_t i;
  2577. if (val) {
  2578. for (i = 1; i < (val)->count; i++) {
  2579. }
  2580. ASN1Free((val)->value);
  2581. }
  2582. }
  2583. static int ASN1CALL ASN1Enc_BasicConstraints2(ASN1encoding_t enc, ASN1uint32_t tag, BasicConstraints2 *val)
  2584. {
  2585. ASN1uint32_t nLenOff;
  2586. ASN1octet_t o[1];
  2587. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2588. return 0;
  2589. CopyMemory(o, (val)->o, 1);
  2590. if (!(val)->cA)
  2591. o[0] &= ~0x80;
  2592. if (o[0] & 0x80) {
  2593. if (!ASN1BEREncBool(enc, 0x1, (val)->cA))
  2594. return 0;
  2595. }
  2596. if (o[0] & 0x40) {
  2597. if (!ASN1BEREncS32(enc, 0x2, (val)->pathLenConstraint))
  2598. return 0;
  2599. }
  2600. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2601. return 0;
  2602. return 1;
  2603. }
  2604. static int ASN1CALL ASN1Dec_BasicConstraints2(ASN1decoding_t dec, ASN1uint32_t tag, BasicConstraints2 *val)
  2605. {
  2606. ASN1decoding_t dd;
  2607. ASN1octet_t *di;
  2608. ASN1uint32_t t;
  2609. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  2610. return 0;
  2611. ZeroMemory((val)->o, 1);
  2612. ASN1BERDecPeekTag(dd, &t);
  2613. if (t == 0x1) {
  2614. (val)->o[0] |= 0x80;
  2615. if (!ASN1BERDecBool(dd, 0x1, &(val)->cA))
  2616. return 0;
  2617. }
  2618. ASN1BERDecPeekTag(dd, &t);
  2619. if (t == 0x2) {
  2620. (val)->o[0] |= 0x40;
  2621. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->pathLenConstraint))
  2622. return 0;
  2623. }
  2624. if (!((val)->o[0] & 0x80))
  2625. (val)->cA = 0;
  2626. if (!ASN1BERDecEndOfContents(dec, dd, di))
  2627. return 0;
  2628. return 1;
  2629. }
  2630. static int ASN1CALL ASN1Enc_CertificatePolicies(ASN1encoding_t enc, ASN1uint32_t tag, CertificatePolicies *val)
  2631. {
  2632. ASN1uint32_t nLenOff;
  2633. ASN1uint32_t i;
  2634. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2635. return 0;
  2636. for (i = 0; i < (val)->count; i++) {
  2637. if (!ASN1Enc_PolicyInformation(enc, 0, &((val)->value)[i]))
  2638. return 0;
  2639. }
  2640. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2641. return 0;
  2642. return 1;
  2643. }
  2644. static int ASN1CALL ASN1Dec_CertificatePolicies(ASN1decoding_t dec, ASN1uint32_t tag, CertificatePolicies *val)
  2645. {
  2646. ASN1decoding_t dd;
  2647. ASN1octet_t *di;
  2648. ASN1uint32_t t;
  2649. ASN1uint32_t n;
  2650. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  2651. return 0;
  2652. (val)->count = n = 0;
  2653. (val)->value = NULL;
  2654. while (ASN1BERDecNotEndOfContents(dd, di)) {
  2655. if (!ASN1BERDecPeekTag(dd, &t))
  2656. return 0;
  2657. if ((val)->count >= n) {
  2658. void *pvASN1DecRealloc;
  2659. n = n ? (n << 1) : 16;
  2660. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  2661. return 0;
  2662. (val)->value = (PolicyInformation *) pvASN1DecRealloc;
  2663. }
  2664. if (!ASN1Dec_PolicyInformation(dd, 0, &((val)->value)[(val)->count]))
  2665. return 0;
  2666. ((val)->count)++;
  2667. }
  2668. if (!ASN1BERDecEndOfContents(dec, dd, di))
  2669. return 0;
  2670. return 1;
  2671. }
  2672. static void ASN1CALL ASN1Free_CertificatePolicies(CertificatePolicies *val)
  2673. {
  2674. ASN1uint32_t i;
  2675. if (val) {
  2676. ASN1Free_PolicyInformation(&(val)->value[0]);
  2677. for (i = 1; i < (val)->count; i++) {
  2678. ASN1Free_PolicyInformation(&(val)->value[i]);
  2679. }
  2680. ASN1Free((val)->value);
  2681. }
  2682. }
  2683. static int ASN1CALL ASN1Enc_PolicyQualifiers(ASN1encoding_t enc, ASN1uint32_t tag, PolicyQualifiers *val)
  2684. {
  2685. ASN1uint32_t nLenOff;
  2686. ASN1uint32_t i;
  2687. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2688. return 0;
  2689. for (i = 0; i < (val)->count; i++) {
  2690. if (!ASN1Enc_PolicyQualifierInfo(enc, 0, &((val)->value)[i]))
  2691. return 0;
  2692. }
  2693. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2694. return 0;
  2695. return 1;
  2696. }
  2697. static int ASN1CALL ASN1Dec_PolicyQualifiers(ASN1decoding_t dec, ASN1uint32_t tag, PolicyQualifiers *val)
  2698. {
  2699. ASN1decoding_t dd;
  2700. ASN1octet_t *di;
  2701. ASN1uint32_t t;
  2702. ASN1uint32_t n;
  2703. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  2704. return 0;
  2705. (val)->count = n = 0;
  2706. (val)->value = NULL;
  2707. while (ASN1BERDecNotEndOfContents(dd, di)) {
  2708. if (!ASN1BERDecPeekTag(dd, &t))
  2709. return 0;
  2710. if ((val)->count >= n) {
  2711. void *pvASN1DecRealloc;
  2712. n = n ? (n << 1) : 16;
  2713. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  2714. return 0;
  2715. (val)->value = (PolicyQualifierInfo *) pvASN1DecRealloc;
  2716. }
  2717. if (!ASN1Dec_PolicyQualifierInfo(dd, 0, &((val)->value)[(val)->count]))
  2718. return 0;
  2719. ((val)->count)++;
  2720. }
  2721. if (!ASN1BERDecEndOfContents(dec, dd, di))
  2722. return 0;
  2723. return 1;
  2724. }
  2725. static void ASN1CALL ASN1Free_PolicyQualifiers(PolicyQualifiers *val)
  2726. {
  2727. ASN1uint32_t i;
  2728. if (val) {
  2729. ASN1Free_PolicyQualifierInfo(&(val)->value[0]);
  2730. for (i = 1; i < (val)->count; i++) {
  2731. ASN1Free_PolicyQualifierInfo(&(val)->value[i]);
  2732. }
  2733. ASN1Free((val)->value);
  2734. }
  2735. }
  2736. static int ASN1CALL ASN1Enc_PolicyQualifierInfo(ASN1encoding_t enc, ASN1uint32_t tag, PolicyQualifierInfo *val)
  2737. {
  2738. ASN1uint32_t nLenOff;
  2739. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2740. return 0;
  2741. if (!ASN1BEREncEoid(enc, 0x6, &(val)->policyQualifierId))
  2742. return 0;
  2743. if ((val)->o[0] & 0x80) {
  2744. if (!ASN1BEREncOpenType(enc, &(val)->qualifier))
  2745. return 0;
  2746. }
  2747. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2748. return 0;
  2749. return 1;
  2750. }
  2751. static int ASN1CALL ASN1Dec_PolicyQualifierInfo(ASN1decoding_t dec, ASN1uint32_t tag, PolicyQualifierInfo *val)
  2752. {
  2753. ASN1decoding_t dd;
  2754. ASN1octet_t *di;
  2755. ASN1uint32_t t;
  2756. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  2757. return 0;
  2758. ZeroMemory((val)->o, 1);
  2759. if (!ASN1BERDecEoid(dd, 0x6, &(val)->policyQualifierId))
  2760. return 0;
  2761. if (ASN1BERDecPeekTag(dd, &t)) {
  2762. (val)->o[0] |= 0x80;
  2763. if (!ASN1BERDecOpenType2(dd, &(val)->qualifier))
  2764. return 0;
  2765. }
  2766. if (!ASN1BERDecEndOfContents(dec, dd, di))
  2767. return 0;
  2768. return 1;
  2769. }
  2770. static void ASN1CALL ASN1Free_PolicyQualifierInfo(PolicyQualifierInfo *val)
  2771. {
  2772. if (val) {
  2773. ASN1BEREoid_free(&(val)->policyQualifierId);
  2774. if ((val)->o[0] & 0x80) {
  2775. }
  2776. }
  2777. }
  2778. static int ASN1CALL ASN1Enc_NoticeReference(ASN1encoding_t enc, ASN1uint32_t tag, NoticeReference *val)
  2779. {
  2780. ASN1uint32_t nLenOff;
  2781. ASN1uint32_t t;
  2782. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2783. return 0;
  2784. t = lstrlenA((val)->organization);
  2785. if (!ASN1DEREncCharString(enc, 0x16, t, (val)->organization))
  2786. return 0;
  2787. if (!ASN1Enc_NoticeReference_noticeNumbers(enc, 0, &(val)->noticeNumbers))
  2788. return 0;
  2789. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2790. return 0;
  2791. return 1;
  2792. }
  2793. static int ASN1CALL ASN1Dec_NoticeReference(ASN1decoding_t dec, ASN1uint32_t tag, NoticeReference *val)
  2794. {
  2795. ASN1decoding_t dd;
  2796. ASN1octet_t *di;
  2797. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  2798. return 0;
  2799. if (!ASN1BERDecZeroCharString(dd, 0x16, &(val)->organization))
  2800. return 0;
  2801. if (!ASN1Dec_NoticeReference_noticeNumbers(dd, 0, &(val)->noticeNumbers))
  2802. return 0;
  2803. if (!ASN1BERDecEndOfContents(dec, dd, di))
  2804. return 0;
  2805. return 1;
  2806. }
  2807. static void ASN1CALL ASN1Free_NoticeReference(NoticeReference *val)
  2808. {
  2809. if (val) {
  2810. ASN1ztcharstring_free((val)->organization);
  2811. ASN1Free_NoticeReference_noticeNumbers(&(val)->noticeNumbers);
  2812. }
  2813. }
  2814. static int ASN1CALL ASN1Enc_DisplayText(ASN1encoding_t enc, ASN1uint32_t tag, DisplayText *val)
  2815. {
  2816. ASN1uint32_t t;
  2817. switch ((val)->choice) {
  2818. case 1:
  2819. t = lstrlenA((val)->u.theVisibleString);
  2820. if (!ASN1DEREncCharString(enc, 0x1a, t, (val)->u.theVisibleString))
  2821. return 0;
  2822. break;
  2823. case 2:
  2824. if (!ASN1DEREncChar16String(enc, 0x1e, ((val)->u.theBMPString).length, ((val)->u.theBMPString).value))
  2825. return 0;
  2826. break;
  2827. default:
  2828. /* impossible */
  2829. ASN1EncSetError(enc, ASN1_ERR_CHOICE);
  2830. return 0;
  2831. }
  2832. return 1;
  2833. }
  2834. static int ASN1CALL ASN1Dec_DisplayText(ASN1decoding_t dec, ASN1uint32_t tag, DisplayText *val)
  2835. {
  2836. ASN1uint32_t t;
  2837. if (!ASN1BERDecPeekTag(dec, &t))
  2838. return 0;
  2839. switch (t) {
  2840. case 0x1a:
  2841. (val)->choice = 1;
  2842. if (!ASN1BERDecZeroCharString(dec, 0x1a, &(val)->u.theVisibleString))
  2843. return 0;
  2844. break;
  2845. case 0x1e:
  2846. (val)->choice = 2;
  2847. if (!ASN1BERDecChar16String(dec, 0x1e, &(val)->u.theBMPString))
  2848. return 0;
  2849. break;
  2850. default:
  2851. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  2852. return 0;
  2853. }
  2854. return 1;
  2855. }
  2856. static void ASN1CALL ASN1Free_DisplayText(DisplayText *val)
  2857. {
  2858. if (val) {
  2859. switch ((val)->choice) {
  2860. case 1:
  2861. ASN1ztcharstring_free((val)->u.theVisibleString);
  2862. break;
  2863. case 2:
  2864. ASN1char16string_free(&(val)->u.theBMPString);
  2865. break;
  2866. }
  2867. }
  2868. }
  2869. static int ASN1CALL ASN1Enc_CertificatePolicies95(ASN1encoding_t enc, ASN1uint32_t tag, CertificatePolicies95 *val)
  2870. {
  2871. ASN1uint32_t nLenOff;
  2872. ASN1uint32_t i;
  2873. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2874. return 0;
  2875. for (i = 0; i < (val)->count; i++) {
  2876. if (!ASN1Enc_PolicyQualifiers(enc, 0, &((val)->value)[i]))
  2877. return 0;
  2878. }
  2879. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2880. return 0;
  2881. return 1;
  2882. }
  2883. static int ASN1CALL ASN1Dec_CertificatePolicies95(ASN1decoding_t dec, ASN1uint32_t tag, CertificatePolicies95 *val)
  2884. {
  2885. ASN1decoding_t dd;
  2886. ASN1octet_t *di;
  2887. ASN1uint32_t t;
  2888. ASN1uint32_t n;
  2889. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  2890. return 0;
  2891. (val)->count = n = 0;
  2892. (val)->value = NULL;
  2893. while (ASN1BERDecNotEndOfContents(dd, di)) {
  2894. if (!ASN1BERDecPeekTag(dd, &t))
  2895. return 0;
  2896. if ((val)->count >= n) {
  2897. void *pvASN1DecRealloc;
  2898. n = n ? (n << 1) : 16;
  2899. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  2900. return 0;
  2901. (val)->value = (PolicyQualifiers *) pvASN1DecRealloc;
  2902. }
  2903. if (!ASN1Dec_PolicyQualifiers(dd, 0, &((val)->value)[(val)->count]))
  2904. return 0;
  2905. ((val)->count)++;
  2906. }
  2907. if (!ASN1BERDecEndOfContents(dec, dd, di))
  2908. return 0;
  2909. return 1;
  2910. }
  2911. static void ASN1CALL ASN1Free_CertificatePolicies95(CertificatePolicies95 *val)
  2912. {
  2913. ASN1uint32_t i;
  2914. if (val) {
  2915. ASN1Free_PolicyQualifiers(&(val)->value[0]);
  2916. for (i = 1; i < (val)->count; i++) {
  2917. ASN1Free_PolicyQualifiers(&(val)->value[i]);
  2918. }
  2919. ASN1Free((val)->value);
  2920. }
  2921. }
  2922. static int ASN1CALL ASN1Enc_CpsURLs(ASN1encoding_t enc, ASN1uint32_t tag, CpsURLs *val)
  2923. {
  2924. ASN1uint32_t nLenOff;
  2925. ASN1uint32_t i;
  2926. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2927. return 0;
  2928. for (i = 0; i < (val)->count; i++) {
  2929. if (!ASN1Enc_CpsURLs_Seq(enc, 0, &((val)->value)[i]))
  2930. return 0;
  2931. }
  2932. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2933. return 0;
  2934. return 1;
  2935. }
  2936. static int ASN1CALL ASN1Dec_CpsURLs(ASN1decoding_t dec, ASN1uint32_t tag, CpsURLs *val)
  2937. {
  2938. ASN1decoding_t dd;
  2939. ASN1octet_t *di;
  2940. ASN1uint32_t t;
  2941. ASN1uint32_t n;
  2942. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  2943. return 0;
  2944. (val)->count = n = 0;
  2945. (val)->value = NULL;
  2946. while (ASN1BERDecNotEndOfContents(dd, di)) {
  2947. if (!ASN1BERDecPeekTag(dd, &t))
  2948. return 0;
  2949. if ((val)->count >= n) {
  2950. void *pvASN1DecRealloc;
  2951. n = n ? (n << 1) : 16;
  2952. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  2953. return 0;
  2954. (val)->value = (CpsURLs_Seq *) pvASN1DecRealloc;
  2955. }
  2956. if (!ASN1Dec_CpsURLs_Seq(dd, 0, &((val)->value)[(val)->count]))
  2957. return 0;
  2958. ((val)->count)++;
  2959. }
  2960. if (!ASN1BERDecEndOfContents(dec, dd, di))
  2961. return 0;
  2962. return 1;
  2963. }
  2964. static void ASN1CALL ASN1Free_CpsURLs(CpsURLs *val)
  2965. {
  2966. ASN1uint32_t i;
  2967. if (val) {
  2968. ASN1Free_CpsURLs_Seq(&(val)->value[0]);
  2969. for (i = 1; i < (val)->count; i++) {
  2970. ASN1Free_CpsURLs_Seq(&(val)->value[i]);
  2971. }
  2972. ASN1Free((val)->value);
  2973. }
  2974. }
  2975. static int ASN1CALL ASN1Enc_AuthorityKeyId2(ASN1encoding_t enc, ASN1uint32_t tag, AuthorityKeyId2 *val)
  2976. {
  2977. ASN1uint32_t nLenOff;
  2978. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  2979. return 0;
  2980. if ((val)->o[0] & 0x80) {
  2981. if (!ASN1DEREncOctetString(enc, 0x80000000, ((val)->keyIdentifier).length, ((val)->keyIdentifier).value))
  2982. return 0;
  2983. }
  2984. if ((val)->o[0] & 0x40) {
  2985. if (!ASN1Enc_GeneralNames(enc, 0x80000001, &(val)->authorityCertIssuer))
  2986. return 0;
  2987. }
  2988. if ((val)->o[0] & 0x20) {
  2989. if (!ASN1BEREncSX(enc, 0x80000002, &(val)->authorityCertSerialNumber))
  2990. return 0;
  2991. }
  2992. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  2993. return 0;
  2994. return 1;
  2995. }
  2996. static int ASN1CALL ASN1Dec_AuthorityKeyId2(ASN1decoding_t dec, ASN1uint32_t tag, AuthorityKeyId2 *val)
  2997. {
  2998. ASN1decoding_t dd;
  2999. ASN1octet_t *di;
  3000. ASN1uint32_t t;
  3001. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  3002. return 0;
  3003. ZeroMemory((val)->o, 1);
  3004. ASN1BERDecPeekTag(dd, &t);
  3005. if (t == 0x80000000) {
  3006. (val)->o[0] |= 0x80;
  3007. if (!ASN1BERDecOctetString2(dd, 0x80000000, &(val)->keyIdentifier))
  3008. return 0;
  3009. }
  3010. ASN1BERDecPeekTag(dd, &t);
  3011. if (t == 0x80000001) {
  3012. (val)->o[0] |= 0x40;
  3013. if (!ASN1Dec_GeneralNames(dd, 0x80000001, &(val)->authorityCertIssuer))
  3014. return 0;
  3015. }
  3016. ASN1BERDecPeekTag(dd, &t);
  3017. if (t == 0x80000002) {
  3018. (val)->o[0] |= 0x20;
  3019. if (!ASN1BERDecSXVal(dd, 0x80000002, &(val)->authorityCertSerialNumber))
  3020. return 0;
  3021. }
  3022. if (!ASN1BERDecEndOfContents(dec, dd, di))
  3023. return 0;
  3024. return 1;
  3025. }
  3026. static void ASN1CALL ASN1Free_AuthorityKeyId2(AuthorityKeyId2 *val)
  3027. {
  3028. if (val) {
  3029. if ((val)->o[0] & 0x80) {
  3030. }
  3031. if ((val)->o[0] & 0x40) {
  3032. ASN1Free_GeneralNames(&(val)->authorityCertIssuer);
  3033. }
  3034. if ((val)->o[0] & 0x20) {
  3035. ASN1intx_free(&(val)->authorityCertSerialNumber);
  3036. }
  3037. }
  3038. }
  3039. static int ASN1CALL ASN1Enc_AuthorityInfoAccess(ASN1encoding_t enc, ASN1uint32_t tag, AuthorityInfoAccess *val)
  3040. {
  3041. ASN1uint32_t nLenOff;
  3042. ASN1uint32_t i;
  3043. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  3044. return 0;
  3045. for (i = 0; i < (val)->count; i++) {
  3046. if (!ASN1Enc_AccessDescription(enc, 0, &((val)->value)[i]))
  3047. return 0;
  3048. }
  3049. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  3050. return 0;
  3051. return 1;
  3052. }
  3053. static int ASN1CALL ASN1Dec_AuthorityInfoAccess(ASN1decoding_t dec, ASN1uint32_t tag, AuthorityInfoAccess *val)
  3054. {
  3055. ASN1decoding_t dd;
  3056. ASN1octet_t *di;
  3057. ASN1uint32_t t;
  3058. ASN1uint32_t n;
  3059. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  3060. return 0;
  3061. (val)->count = n = 0;
  3062. (val)->value = NULL;
  3063. while (ASN1BERDecNotEndOfContents(dd, di)) {
  3064. if (!ASN1BERDecPeekTag(dd, &t))
  3065. return 0;
  3066. if ((val)->count >= n) {
  3067. void *pvASN1DecRealloc;
  3068. n = n ? (n << 1) : 16;
  3069. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  3070. return 0;
  3071. (val)->value = (AccessDescription *) pvASN1DecRealloc;
  3072. }
  3073. if (!ASN1Dec_AccessDescription(dd, 0, &((val)->value)[(val)->count]))
  3074. return 0;
  3075. ((val)->count)++;
  3076. }
  3077. if (!ASN1BERDecEndOfContents(dec, dd, di))
  3078. return 0;
  3079. return 1;
  3080. }
  3081. static void ASN1CALL ASN1Free_AuthorityInfoAccess(AuthorityInfoAccess *val)
  3082. {
  3083. ASN1uint32_t i;
  3084. if (val) {
  3085. ASN1Free_AccessDescription(&(val)->value[0]);
  3086. for (i = 1; i < (val)->count; i++) {
  3087. ASN1Free_AccessDescription(&(val)->value[i]);
  3088. }
  3089. ASN1Free((val)->value);
  3090. }
  3091. }
  3092. static int ASN1CALL ASN1Enc_CRLDistributionPoints(ASN1encoding_t enc, ASN1uint32_t tag, CRLDistributionPoints *val)
  3093. {
  3094. ASN1uint32_t nLenOff;
  3095. ASN1uint32_t i;
  3096. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  3097. return 0;
  3098. for (i = 0; i < (val)->count; i++) {
  3099. if (!ASN1Enc_DistributionPoint(enc, 0, &((val)->value)[i]))
  3100. return 0;
  3101. }
  3102. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  3103. return 0;
  3104. return 1;
  3105. }
  3106. static int ASN1CALL ASN1Dec_CRLDistributionPoints(ASN1decoding_t dec, ASN1uint32_t tag, CRLDistributionPoints *val)
  3107. {
  3108. ASN1decoding_t dd;
  3109. ASN1octet_t *di;
  3110. ASN1uint32_t t;
  3111. ASN1uint32_t n;
  3112. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  3113. return 0;
  3114. (val)->count = n = 0;
  3115. (val)->value = NULL;
  3116. while (ASN1BERDecNotEndOfContents(dd, di)) {
  3117. if (!ASN1BERDecPeekTag(dd, &t))
  3118. return 0;
  3119. if ((val)->count >= n) {
  3120. void *pvASN1DecRealloc;
  3121. n = n ? (n << 1) : 16;
  3122. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  3123. return 0;
  3124. (val)->value = (DistributionPoint *) pvASN1DecRealloc;
  3125. }
  3126. if (!ASN1Dec_DistributionPoint(dd, 0, &((val)->value)[(val)->count]))
  3127. return 0;
  3128. ((val)->count)++;
  3129. }
  3130. if (!ASN1BERDecEndOfContents(dec, dd, di))
  3131. return 0;
  3132. return 1;
  3133. }
  3134. static void ASN1CALL ASN1Free_CRLDistributionPoints(CRLDistributionPoints *val)
  3135. {
  3136. ASN1uint32_t i;
  3137. if (val) {
  3138. ASN1Free_DistributionPoint(&(val)->value[0]);
  3139. for (i = 1; i < (val)->count; i++) {
  3140. ASN1Free_DistributionPoint(&(val)->value[i]);
  3141. }
  3142. ASN1Free((val)->value);
  3143. }
  3144. }
  3145. static int ASN1CALL ASN1Enc_DistributionPointName(ASN1encoding_t enc, ASN1uint32_t tag, DistributionPointName *val)
  3146. {
  3147. switch ((val)->choice) {
  3148. case 1:
  3149. if (!ASN1Enc_GeneralNames(enc, 0x80000000, &(val)->u.fullName))
  3150. return 0;
  3151. break;
  3152. case 2:
  3153. if (!ASN1Enc_RelativeDistinguishedName(enc, 0x80000001, &(val)->u.nameRelativeToCRLIssuer))
  3154. return 0;
  3155. break;
  3156. default:
  3157. /* impossible */
  3158. ASN1EncSetError(enc, ASN1_ERR_CHOICE);
  3159. return 0;
  3160. }
  3161. return 1;
  3162. }
  3163. static int ASN1CALL ASN1Dec_DistributionPointName(ASN1decoding_t dec, ASN1uint32_t tag, DistributionPointName *val)
  3164. {
  3165. ASN1uint32_t t;
  3166. if (!ASN1BERDecPeekTag(dec, &t))
  3167. return 0;
  3168. switch (t) {
  3169. case 0x80000000:
  3170. (val)->choice = 1;
  3171. if (!ASN1Dec_GeneralNames(dec, 0x80000000, &(val)->u.fullName))
  3172. return 0;
  3173. break;
  3174. case 0x80000001:
  3175. (val)->choice = 2;
  3176. if (!ASN1Dec_RelativeDistinguishedName(dec, 0x80000001, &(val)->u.nameRelativeToCRLIssuer))
  3177. return 0;
  3178. break;
  3179. default:
  3180. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  3181. return 0;
  3182. }
  3183. return 1;
  3184. }
  3185. static void ASN1CALL ASN1Free_DistributionPointName(DistributionPointName *val)
  3186. {
  3187. if (val) {
  3188. switch ((val)->choice) {
  3189. case 1:
  3190. ASN1Free_GeneralNames(&(val)->u.fullName);
  3191. break;
  3192. case 2:
  3193. ASN1Free_RelativeDistinguishedName(&(val)->u.nameRelativeToCRLIssuer);
  3194. break;
  3195. }
  3196. }
  3197. }
  3198. static int ASN1CALL ASN1Enc_ContentInfo(ASN1encoding_t enc, ASN1uint32_t tag, ContentInfo *val)
  3199. {
  3200. ASN1uint32_t nLenOff;
  3201. ASN1uint32_t nLenOff0;
  3202. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  3203. return 0;
  3204. if (!ASN1BEREncEoid(enc, 0x6, &(val)->contentType))
  3205. return 0;
  3206. if ((val)->o[0] & 0x80) {
  3207. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  3208. return 0;
  3209. if (!ASN1BEREncOpenType(enc, &(val)->content))
  3210. return 0;
  3211. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  3212. return 0;
  3213. }
  3214. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  3215. return 0;
  3216. return 1;
  3217. }
  3218. static int ASN1CALL ASN1Dec_ContentInfo(ASN1decoding_t dec, ASN1uint32_t tag, ContentInfo *val)
  3219. {
  3220. ASN1decoding_t dd;
  3221. ASN1octet_t *di;
  3222. ASN1uint32_t t;
  3223. ASN1decoding_t dd0;
  3224. ASN1octet_t *di0;
  3225. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  3226. return 0;
  3227. ZeroMemory((val)->o, 1);
  3228. if (!ASN1BERDecEoid(dd, 0x6, &(val)->contentType))
  3229. return 0;
  3230. if (ASN1BERDecPeekTag(dd, &t)) {
  3231. if (t == 0x80000000) {
  3232. (val)->o[0] |= 0x80;
  3233. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  3234. return 0;
  3235. if (!ASN1BERDecOpenType2(dd0, &(val)->content))
  3236. return 0;
  3237. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  3238. return 0;
  3239. }
  3240. }
  3241. if (!ASN1BERDecEndOfContents(dec, dd, di))
  3242. return 0;
  3243. return 1;
  3244. }
  3245. static void ASN1CALL ASN1Free_ContentInfo(ContentInfo *val)
  3246. {
  3247. if (val) {
  3248. ASN1BEREoid_free(&(val)->contentType);
  3249. if ((val)->o[0] & 0x80) {
  3250. }
  3251. }
  3252. }
  3253. static int ASN1CALL ASN1Enc_SeqOfAny(ASN1encoding_t enc, ASN1uint32_t tag, SeqOfAny *val)
  3254. {
  3255. ASN1uint32_t nLenOff;
  3256. ASN1uint32_t i;
  3257. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  3258. return 0;
  3259. for (i = 0; i < (val)->count; i++) {
  3260. if (!ASN1BEREncOpenType(enc, &((val)->value)[i]))
  3261. return 0;
  3262. }
  3263. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  3264. return 0;
  3265. return 1;
  3266. }
  3267. static int ASN1CALL ASN1Dec_SeqOfAny(ASN1decoding_t dec, ASN1uint32_t tag, SeqOfAny *val)
  3268. {
  3269. ASN1decoding_t dd;
  3270. ASN1octet_t *di;
  3271. ASN1uint32_t t;
  3272. ASN1uint32_t n;
  3273. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  3274. return 0;
  3275. (val)->count = n = 0;
  3276. (val)->value = NULL;
  3277. while (ASN1BERDecNotEndOfContents(dd, di)) {
  3278. if (!ASN1BERDecPeekTag(dd, &t))
  3279. return 0;
  3280. if ((val)->count >= n) {
  3281. void *pvASN1DecRealloc;
  3282. n = n ? (n << 1) : 16;
  3283. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  3284. return 0;
  3285. (val)->value = (NOCOPYANY *) pvASN1DecRealloc;
  3286. }
  3287. if (!ASN1BERDecOpenType2(dd, &((val)->value)[(val)->count]))
  3288. return 0;
  3289. ((val)->count)++;
  3290. }
  3291. if (!ASN1BERDecEndOfContents(dec, dd, di))
  3292. return 0;
  3293. return 1;
  3294. }
  3295. static void ASN1CALL ASN1Free_SeqOfAny(SeqOfAny *val)
  3296. {
  3297. ASN1uint32_t i;
  3298. if (val) {
  3299. for (i = 1; i < (val)->count; i++) {
  3300. }
  3301. ASN1Free((val)->value);
  3302. }
  3303. }
  3304. static int ASN1CALL ASN1Enc_TimeStampRequest(ASN1encoding_t enc, ASN1uint32_t tag, TimeStampRequest *val)
  3305. {
  3306. ASN1uint32_t nLenOff;
  3307. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  3308. return 0;
  3309. if (!ASN1BEREncEoid(enc, 0x6, &(val)->timeStampAlgorithm))
  3310. return 0;
  3311. if ((val)->o[0] & 0x80) {
  3312. if (!ASN1Enc_Attributes(enc, 0, &(val)->attributesTS))
  3313. return 0;
  3314. }
  3315. if (!ASN1Enc_ContentInfo(enc, 0, &(val)->content))
  3316. return 0;
  3317. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  3318. return 0;
  3319. return 1;
  3320. }
  3321. static int ASN1CALL ASN1Dec_TimeStampRequest(ASN1decoding_t dec, ASN1uint32_t tag, TimeStampRequest *val)
  3322. {
  3323. ASN1decoding_t dd;
  3324. ASN1octet_t *di;
  3325. ASN1uint32_t t;
  3326. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  3327. return 0;
  3328. ZeroMemory((val)->o, 1);
  3329. if (!ASN1BERDecEoid(dd, 0x6, &(val)->timeStampAlgorithm))
  3330. return 0;
  3331. ASN1BERDecPeekTag(dd, &t);
  3332. if (t == 0x11) {
  3333. (val)->o[0] |= 0x80;
  3334. if (!ASN1Dec_Attributes(dd, 0, &(val)->attributesTS))
  3335. return 0;
  3336. }
  3337. if (!ASN1Dec_ContentInfo(dd, 0, &(val)->content))
  3338. return 0;
  3339. if (!ASN1BERDecEndOfContents(dec, dd, di))
  3340. return 0;
  3341. return 1;
  3342. }
  3343. static void ASN1CALL ASN1Free_TimeStampRequest(TimeStampRequest *val)
  3344. {
  3345. if (val) {
  3346. ASN1BEREoid_free(&(val)->timeStampAlgorithm);
  3347. if ((val)->o[0] & 0x80) {
  3348. ASN1Free_Attributes(&(val)->attributesTS);
  3349. }
  3350. ASN1Free_ContentInfo(&(val)->content);
  3351. }
  3352. }
  3353. static int ASN1CALL ASN1Enc_ContentInfoOTS(ASN1encoding_t enc, ASN1uint32_t tag, ContentInfoOTS *val)
  3354. {
  3355. ASN1uint32_t nLenOff;
  3356. ASN1uint32_t nLenOff0;
  3357. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  3358. return 0;
  3359. if (!ASN1BEREncEoid(enc, 0x6, &(val)->contentTypeOTS))
  3360. return 0;
  3361. if ((val)->o[0] & 0x80) {
  3362. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  3363. return 0;
  3364. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->contentOTS).length, ((val)->contentOTS).value))
  3365. return 0;
  3366. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  3367. return 0;
  3368. }
  3369. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  3370. return 0;
  3371. return 1;
  3372. }
  3373. static int ASN1CALL ASN1Dec_ContentInfoOTS(ASN1decoding_t dec, ASN1uint32_t tag, ContentInfoOTS *val)
  3374. {
  3375. ASN1decoding_t dd;
  3376. ASN1octet_t *di;
  3377. ASN1uint32_t t;
  3378. ASN1decoding_t dd0;
  3379. ASN1octet_t *di0;
  3380. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  3381. return 0;
  3382. ZeroMemory((val)->o, 1);
  3383. if (!ASN1BERDecEoid(dd, 0x6, &(val)->contentTypeOTS))
  3384. return 0;
  3385. ASN1BERDecPeekTag(dd, &t);
  3386. if (t == 0x80000000) {
  3387. (val)->o[0] |= 0x80;
  3388. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  3389. return 0;
  3390. if (!ASN1BERDecOctetString2(dd0, 0x4, &(val)->contentOTS))
  3391. return 0;
  3392. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  3393. return 0;
  3394. }
  3395. if (!ASN1BERDecEndOfContents(dec, dd, di))
  3396. return 0;
  3397. return 1;
  3398. }
  3399. static void ASN1CALL ASN1Free_ContentInfoOTS(ContentInfoOTS *val)
  3400. {
  3401. if (val) {
  3402. ASN1BEREoid_free(&(val)->contentTypeOTS);
  3403. if ((val)->o[0] & 0x80) {
  3404. }
  3405. }
  3406. }
  3407. static int ASN1CALL ASN1Enc_TimeStampRequestOTS(ASN1encoding_t enc, ASN1uint32_t tag, TimeStampRequestOTS *val)
  3408. {
  3409. ASN1uint32_t nLenOff;
  3410. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  3411. return 0;
  3412. if (!ASN1BEREncEoid(enc, 0x6, &(val)->timeStampAlgorithmOTS))
  3413. return 0;
  3414. if ((val)->o[0] & 0x80) {
  3415. if (!ASN1Enc_Attributes(enc, 0, &(val)->attributesOTS))
  3416. return 0;
  3417. }
  3418. if (!ASN1Enc_ContentInfoOTS(enc, 0, &(val)->contentOTS))
  3419. return 0;
  3420. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  3421. return 0;
  3422. return 1;
  3423. }
  3424. static int ASN1CALL ASN1Dec_TimeStampRequestOTS(ASN1decoding_t dec, ASN1uint32_t tag, TimeStampRequestOTS *val)
  3425. {
  3426. ASN1decoding_t dd;
  3427. ASN1octet_t *di;
  3428. ASN1uint32_t t;
  3429. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  3430. return 0;
  3431. ZeroMemory((val)->o, 1);
  3432. if (!ASN1BERDecEoid(dd, 0x6, &(val)->timeStampAlgorithmOTS))
  3433. return 0;
  3434. ASN1BERDecPeekTag(dd, &t);
  3435. if (t == 0x11) {
  3436. (val)->o[0] |= 0x80;
  3437. if (!ASN1Dec_Attributes(dd, 0, &(val)->attributesOTS))
  3438. return 0;
  3439. }
  3440. if (!ASN1Dec_ContentInfoOTS(dd, 0, &(val)->contentOTS))
  3441. return 0;
  3442. if (!ASN1BERDecEndOfContents(dec, dd, di))
  3443. return 0;
  3444. return 1;
  3445. }
  3446. static void ASN1CALL ASN1Free_TimeStampRequestOTS(TimeStampRequestOTS *val)
  3447. {
  3448. if (val) {
  3449. ASN1BEREoid_free(&(val)->timeStampAlgorithmOTS);
  3450. if ((val)->o[0] & 0x80) {
  3451. ASN1Free_Attributes(&(val)->attributesOTS);
  3452. }
  3453. ASN1Free_ContentInfoOTS(&(val)->contentOTS);
  3454. }
  3455. }
  3456. static int ASN1CALL ASN1Enc_EnhancedKeyUsage(ASN1encoding_t enc, ASN1uint32_t tag, EnhancedKeyUsage *val)
  3457. {
  3458. ASN1uint32_t nLenOff;
  3459. ASN1uint32_t i;
  3460. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  3461. return 0;
  3462. for (i = 0; i < (val)->count; i++) {
  3463. if (!ASN1BEREncEoid(enc, 0x6, &((val)->value)[i]))
  3464. return 0;
  3465. }
  3466. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  3467. return 0;
  3468. return 1;
  3469. }
  3470. static int ASN1CALL ASN1Dec_EnhancedKeyUsage(ASN1decoding_t dec, ASN1uint32_t tag, EnhancedKeyUsage *val)
  3471. {
  3472. ASN1decoding_t dd;
  3473. ASN1octet_t *di;
  3474. ASN1uint32_t t;
  3475. ASN1uint32_t n;
  3476. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  3477. return 0;
  3478. (val)->count = n = 0;
  3479. (val)->value = NULL;
  3480. while (ASN1BERDecNotEndOfContents(dd, di)) {
  3481. if (!ASN1BERDecPeekTag(dd, &t))
  3482. return 0;
  3483. if ((val)->count >= n) {
  3484. void *pvASN1DecRealloc;
  3485. n = n ? (n << 1) : 16;
  3486. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  3487. return 0;
  3488. (val)->value = (UsageIdentifier *) pvASN1DecRealloc;
  3489. }
  3490. if (!ASN1BERDecEoid(dd, 0x6, &((val)->value)[(val)->count]))
  3491. return 0;
  3492. ((val)->count)++;
  3493. }
  3494. if (!ASN1BERDecEndOfContents(dec, dd, di))
  3495. return 0;
  3496. return 1;
  3497. }
  3498. static void ASN1CALL ASN1Free_EnhancedKeyUsage(EnhancedKeyUsage *val)
  3499. {
  3500. ASN1uint32_t i;
  3501. if (val) {
  3502. ASN1BEREoid_free(&(val)->value[0]);
  3503. for (i = 1; i < (val)->count; i++) {
  3504. ASN1BEREoid_free(&(val)->value[i]);
  3505. }
  3506. ASN1Free((val)->value);
  3507. }
  3508. }
  3509. static int ASN1CALL ASN1Enc_SubjectUsage(ASN1encoding_t enc, ASN1uint32_t tag, SubjectUsage *val)
  3510. {
  3511. if (!ASN1Enc_EnhancedKeyUsage(enc, tag, val))
  3512. return 0;
  3513. return 1;
  3514. }
  3515. static int ASN1CALL ASN1Dec_SubjectUsage(ASN1decoding_t dec, ASN1uint32_t tag, SubjectUsage *val)
  3516. {
  3517. if (!ASN1Dec_EnhancedKeyUsage(dec, tag, val))
  3518. return 0;
  3519. return 1;
  3520. }
  3521. static void ASN1CALL ASN1Free_SubjectUsage(SubjectUsage *val)
  3522. {
  3523. if (val) {
  3524. ASN1Free_EnhancedKeyUsage(val);
  3525. }
  3526. }
  3527. static int ASN1CALL ASN1Enc_TrustedSubjects(ASN1encoding_t enc, ASN1uint32_t tag, TrustedSubjects *val)
  3528. {
  3529. ASN1uint32_t nLenOff;
  3530. ASN1uint32_t i;
  3531. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  3532. return 0;
  3533. for (i = 0; i < (val)->count; i++) {
  3534. if (!ASN1Enc_TrustedSubject(enc, 0, &((val)->value)[i]))
  3535. return 0;
  3536. }
  3537. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  3538. return 0;
  3539. return 1;
  3540. }
  3541. static int ASN1CALL ASN1Dec_TrustedSubjects(ASN1decoding_t dec, ASN1uint32_t tag, TrustedSubjects *val)
  3542. {
  3543. ASN1decoding_t dd;
  3544. ASN1octet_t *di;
  3545. ASN1uint32_t t;
  3546. ASN1uint32_t n;
  3547. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  3548. return 0;
  3549. (val)->count = n = 0;
  3550. (val)->value = NULL;
  3551. while (ASN1BERDecNotEndOfContents(dd, di)) {
  3552. if (!ASN1BERDecPeekTag(dd, &t))
  3553. return 0;
  3554. if ((val)->count >= n) {
  3555. void *pvASN1DecRealloc;
  3556. n = n ? (n << 1) : 16;
  3557. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  3558. return 0;
  3559. (val)->value = (TrustedSubject *) pvASN1DecRealloc;
  3560. }
  3561. if (!ASN1Dec_TrustedSubject(dd, 0, &((val)->value)[(val)->count]))
  3562. return 0;
  3563. ((val)->count)++;
  3564. }
  3565. if (!ASN1BERDecEndOfContents(dec, dd, di))
  3566. return 0;
  3567. return 1;
  3568. }
  3569. static void ASN1CALL ASN1Free_TrustedSubjects(TrustedSubjects *val)
  3570. {
  3571. ASN1uint32_t i;
  3572. if (val) {
  3573. ASN1Free_TrustedSubject(&(val)->value[0]);
  3574. for (i = 1; i < (val)->count; i++) {
  3575. ASN1Free_TrustedSubject(&(val)->value[i]);
  3576. }
  3577. ASN1Free((val)->value);
  3578. }
  3579. }
  3580. static int ASN1CALL ASN1Enc_TrustedSubject(ASN1encoding_t enc, ASN1uint32_t tag, TrustedSubject *val)
  3581. {
  3582. ASN1uint32_t nLenOff;
  3583. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  3584. return 0;
  3585. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->subjectIdentifier).length, ((val)->subjectIdentifier).value))
  3586. return 0;
  3587. if ((val)->o[0] & 0x80) {
  3588. if (!ASN1Enc_Attributes(enc, 0, &(val)->subjectAttributes))
  3589. return 0;
  3590. }
  3591. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  3592. return 0;
  3593. return 1;
  3594. }
  3595. static int ASN1CALL ASN1Dec_TrustedSubject(ASN1decoding_t dec, ASN1uint32_t tag, TrustedSubject *val)
  3596. {
  3597. ASN1decoding_t dd;
  3598. ASN1octet_t *di;
  3599. ASN1uint32_t t;
  3600. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  3601. return 0;
  3602. ZeroMemory((val)->o, 1);
  3603. if (!ASN1BERDecOctetString2(dd, 0x4, &(val)->subjectIdentifier))
  3604. return 0;
  3605. ASN1BERDecPeekTag(dd, &t);
  3606. if (t == 0x11) {
  3607. (val)->o[0] |= 0x80;
  3608. if (!ASN1Dec_Attributes(dd, 0, &(val)->subjectAttributes))
  3609. return 0;
  3610. }
  3611. if (!ASN1BERDecEndOfContents(dec, dd, di))
  3612. return 0;
  3613. return 1;
  3614. }
  3615. static void ASN1CALL ASN1Free_TrustedSubject(TrustedSubject *val)
  3616. {
  3617. if (val) {
  3618. if ((val)->o[0] & 0x80) {
  3619. ASN1Free_Attributes(&(val)->subjectAttributes);
  3620. }
  3621. }
  3622. }
  3623. static int ASN1CALL ASN1Enc_EnrollmentNameValuePair(ASN1encoding_t enc, ASN1uint32_t tag, EnrollmentNameValuePair *val)
  3624. {
  3625. ASN1uint32_t nLenOff;
  3626. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  3627. return 0;
  3628. if (!ASN1DEREncChar16String(enc, 0x1e, ((val)->name).length, ((val)->name).value))
  3629. return 0;
  3630. if (!ASN1DEREncChar16String(enc, 0x1e, ((val)->value).length, ((val)->value).value))
  3631. return 0;
  3632. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  3633. return 0;
  3634. return 1;
  3635. }
  3636. static int ASN1CALL ASN1Dec_EnrollmentNameValuePair(ASN1decoding_t dec, ASN1uint32_t tag, EnrollmentNameValuePair *val)
  3637. {
  3638. ASN1decoding_t dd;
  3639. ASN1octet_t *di;
  3640. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  3641. return 0;
  3642. if (!ASN1BERDecChar16String(dd, 0x1e, &(val)->name))
  3643. return 0;
  3644. if (!ASN1BERDecChar16String(dd, 0x1e, &(val)->value))
  3645. return 0;
  3646. if (!ASN1BERDecEndOfContents(dec, dd, di))
  3647. return 0;
  3648. return 1;
  3649. }
  3650. static void ASN1CALL ASN1Free_EnrollmentNameValuePair(EnrollmentNameValuePair *val)
  3651. {
  3652. if (val) {
  3653. ASN1char16string_free(&(val)->name);
  3654. ASN1char16string_free(&(val)->value);
  3655. }
  3656. }
  3657. static int ASN1CALL ASN1Enc_CSPProvider(ASN1encoding_t enc, ASN1uint32_t tag, CSPProvider *val)
  3658. {
  3659. ASN1uint32_t nLenOff;
  3660. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  3661. return 0;
  3662. if (!ASN1BEREncS32(enc, 0x2, (val)->keySpec))
  3663. return 0;
  3664. if (!ASN1DEREncChar16String(enc, 0x1e, ((val)->cspName).length, ((val)->cspName).value))
  3665. return 0;
  3666. if (!ASN1DEREncBitString(enc, 0x3, ((val)->signature).length, ((val)->signature).value))
  3667. return 0;
  3668. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  3669. return 0;
  3670. return 1;
  3671. }
  3672. static int ASN1CALL ASN1Dec_CSPProvider(ASN1decoding_t dec, ASN1uint32_t tag, CSPProvider *val)
  3673. {
  3674. ASN1decoding_t dd;
  3675. ASN1octet_t *di;
  3676. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  3677. return 0;
  3678. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->keySpec))
  3679. return 0;
  3680. if (!ASN1BERDecChar16String(dd, 0x1e, &(val)->cspName))
  3681. return 0;
  3682. if (!ASN1BERDecBitString2(dd, 0x3, &(val)->signature))
  3683. return 0;
  3684. if (!ASN1BERDecEndOfContents(dec, dd, di))
  3685. return 0;
  3686. return 1;
  3687. }
  3688. static void ASN1CALL ASN1Free_CSPProvider(CSPProvider *val)
  3689. {
  3690. if (val) {
  3691. ASN1char16string_free(&(val)->cspName);
  3692. }
  3693. }
  3694. static int ASN1CALL ASN1Enc_CertificatePair(ASN1encoding_t enc, ASN1uint32_t tag, CertificatePair *val)
  3695. {
  3696. ASN1uint32_t nLenOff;
  3697. ASN1uint32_t nLenOff0;
  3698. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  3699. return 0;
  3700. if ((val)->o[0] & 0x80) {
  3701. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  3702. return 0;
  3703. if (!ASN1BEREncOpenType(enc, &(val)->forward))
  3704. return 0;
  3705. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  3706. return 0;
  3707. }
  3708. if ((val)->o[0] & 0x40) {
  3709. if (!ASN1BEREncExplicitTag(enc, 0x80000001, &nLenOff0))
  3710. return 0;
  3711. if (!ASN1BEREncOpenType(enc, &(val)->reverse))
  3712. return 0;
  3713. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  3714. return 0;
  3715. }
  3716. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  3717. return 0;
  3718. return 1;
  3719. }
  3720. static int ASN1CALL ASN1Dec_CertificatePair(ASN1decoding_t dec, ASN1uint32_t tag, CertificatePair *val)
  3721. {
  3722. ASN1decoding_t dd;
  3723. ASN1octet_t *di;
  3724. ASN1uint32_t t;
  3725. ASN1decoding_t dd0;
  3726. ASN1octet_t *di0;
  3727. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  3728. return 0;
  3729. ZeroMemory((val)->o, 1);
  3730. if (ASN1BERDecPeekTag(dd, &t)) {
  3731. if (t == 0x80000000) {
  3732. (val)->o[0] |= 0x80;
  3733. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  3734. return 0;
  3735. if (!ASN1BERDecOpenType2(dd0, &(val)->forward))
  3736. return 0;
  3737. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  3738. return 0;
  3739. }
  3740. }
  3741. if (ASN1BERDecPeekTag(dd, &t)) {
  3742. if (t == 0x80000001) {
  3743. (val)->o[0] |= 0x40;
  3744. if (!ASN1BERDecExplicitTag(dd, 0x80000001, &dd0, &di0))
  3745. return 0;
  3746. if (!ASN1BERDecOpenType2(dd0, &(val)->reverse))
  3747. return 0;
  3748. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  3749. return 0;
  3750. }
  3751. }
  3752. if (!ASN1BERDecEndOfContents(dec, dd, di))
  3753. return 0;
  3754. return 1;
  3755. }
  3756. static void ASN1CALL ASN1Free_CertificatePair(CertificatePair *val)
  3757. {
  3758. if (val) {
  3759. if ((val)->o[0] & 0x80) {
  3760. }
  3761. if ((val)->o[0] & 0x40) {
  3762. }
  3763. }
  3764. }
  3765. static int ASN1CALL ASN1Enc_GeneralSubtrees(ASN1encoding_t enc, ASN1uint32_t tag, GeneralSubtrees *val)
  3766. {
  3767. ASN1uint32_t nLenOff;
  3768. ASN1uint32_t i;
  3769. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  3770. return 0;
  3771. for (i = 0; i < (val)->count; i++) {
  3772. if (!ASN1Enc_GeneralSubtree(enc, 0, &((val)->value)[i]))
  3773. return 0;
  3774. }
  3775. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  3776. return 0;
  3777. return 1;
  3778. }
  3779. static int ASN1CALL ASN1Dec_GeneralSubtrees(ASN1decoding_t dec, ASN1uint32_t tag, GeneralSubtrees *val)
  3780. {
  3781. ASN1decoding_t dd;
  3782. ASN1octet_t *di;
  3783. ASN1uint32_t t;
  3784. ASN1uint32_t n;
  3785. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  3786. return 0;
  3787. (val)->count = n = 0;
  3788. (val)->value = NULL;
  3789. while (ASN1BERDecNotEndOfContents(dd, di)) {
  3790. if (!ASN1BERDecPeekTag(dd, &t))
  3791. return 0;
  3792. if ((val)->count >= n) {
  3793. void *pvASN1DecRealloc;
  3794. n = n ? (n << 1) : 16;
  3795. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  3796. return 0;
  3797. (val)->value = (GeneralSubtree *) pvASN1DecRealloc;
  3798. }
  3799. if (!ASN1Dec_GeneralSubtree(dd, 0, &((val)->value)[(val)->count]))
  3800. return 0;
  3801. ((val)->count)++;
  3802. }
  3803. if (!ASN1BERDecEndOfContents(dec, dd, di))
  3804. return 0;
  3805. return 1;
  3806. }
  3807. static void ASN1CALL ASN1Free_GeneralSubtrees(GeneralSubtrees *val)
  3808. {
  3809. ASN1uint32_t i;
  3810. if (val) {
  3811. ASN1Free_GeneralSubtree(&(val)->value[0]);
  3812. for (i = 1; i < (val)->count; i++) {
  3813. ASN1Free_GeneralSubtree(&(val)->value[i]);
  3814. }
  3815. ASN1Free((val)->value);
  3816. }
  3817. }
  3818. static int ASN1CALL ASN1Enc_IssuingDistributionPoint(ASN1encoding_t enc, ASN1uint32_t tag, IssuingDistributionPoint *val)
  3819. {
  3820. ASN1uint32_t nLenOff;
  3821. ASN1octet_t o[1];
  3822. ASN1uint32_t nLenOff0;
  3823. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  3824. return 0;
  3825. CopyMemory(o, (val)->o, 1);
  3826. if (!(val)->onlyContainsUserCerts)
  3827. o[0] &= ~0x40;
  3828. if (!(val)->onlyContainsCACerts)
  3829. o[0] &= ~0x20;
  3830. if (!(val)->indirectCRL)
  3831. o[0] &= ~0x8;
  3832. if (o[0] & 0x80) {
  3833. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  3834. return 0;
  3835. if (!ASN1Enc_DistributionPointName(enc, 0, &(val)->issuingDistributionPoint))
  3836. return 0;
  3837. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  3838. return 0;
  3839. }
  3840. if (o[0] & 0x40) {
  3841. if (!ASN1BEREncBool(enc, 0x80000001, (val)->onlyContainsUserCerts))
  3842. return 0;
  3843. }
  3844. if (o[0] & 0x20) {
  3845. if (!ASN1BEREncBool(enc, 0x80000002, (val)->onlyContainsCACerts))
  3846. return 0;
  3847. }
  3848. if (o[0] & 0x10) {
  3849. if (!ASN1DEREncBitString(enc, 0x80000003, ((val)->onlySomeReasons).length, ((val)->onlySomeReasons).value))
  3850. return 0;
  3851. }
  3852. if (o[0] & 0x8) {
  3853. if (!ASN1BEREncBool(enc, 0x80000004, (val)->indirectCRL))
  3854. return 0;
  3855. }
  3856. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  3857. return 0;
  3858. return 1;
  3859. }
  3860. static int ASN1CALL ASN1Dec_IssuingDistributionPoint(ASN1decoding_t dec, ASN1uint32_t tag, IssuingDistributionPoint *val)
  3861. {
  3862. ASN1decoding_t dd;
  3863. ASN1octet_t *di;
  3864. ASN1uint32_t t;
  3865. ASN1decoding_t dd0;
  3866. ASN1octet_t *di0;
  3867. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  3868. return 0;
  3869. ZeroMemory((val)->o, 1);
  3870. ASN1BERDecPeekTag(dd, &t);
  3871. if (t == 0x80000000) {
  3872. (val)->o[0] |= 0x80;
  3873. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  3874. return 0;
  3875. if (!ASN1Dec_DistributionPointName(dd0, 0, &(val)->issuingDistributionPoint))
  3876. return 0;
  3877. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  3878. return 0;
  3879. }
  3880. ASN1BERDecPeekTag(dd, &t);
  3881. if (t == 0x80000001) {
  3882. (val)->o[0] |= 0x40;
  3883. if (!ASN1BERDecBool(dd, 0x80000001, &(val)->onlyContainsUserCerts))
  3884. return 0;
  3885. }
  3886. ASN1BERDecPeekTag(dd, &t);
  3887. if (t == 0x80000002) {
  3888. (val)->o[0] |= 0x20;
  3889. if (!ASN1BERDecBool(dd, 0x80000002, &(val)->onlyContainsCACerts))
  3890. return 0;
  3891. }
  3892. ASN1BERDecPeekTag(dd, &t);
  3893. if (t == 0x80000003) {
  3894. (val)->o[0] |= 0x10;
  3895. if (!ASN1BERDecBitString2(dd, 0x80000003, &(val)->onlySomeReasons))
  3896. return 0;
  3897. }
  3898. ASN1BERDecPeekTag(dd, &t);
  3899. if (t == 0x80000004) {
  3900. (val)->o[0] |= 0x8;
  3901. if (!ASN1BERDecBool(dd, 0x80000004, &(val)->indirectCRL))
  3902. return 0;
  3903. }
  3904. if (!((val)->o[0] & 0x40))
  3905. (val)->onlyContainsUserCerts = 0;
  3906. if (!((val)->o[0] & 0x20))
  3907. (val)->onlyContainsCACerts = 0;
  3908. if (!((val)->o[0] & 0x8))
  3909. (val)->indirectCRL = 0;
  3910. if (!ASN1BERDecEndOfContents(dec, dd, di))
  3911. return 0;
  3912. return 1;
  3913. }
  3914. static void ASN1CALL ASN1Free_IssuingDistributionPoint(IssuingDistributionPoint *val)
  3915. {
  3916. if (val) {
  3917. if ((val)->o[0] & 0x80) {
  3918. ASN1Free_DistributionPointName(&(val)->issuingDistributionPoint);
  3919. }
  3920. if ((val)->o[0] & 0x10) {
  3921. }
  3922. }
  3923. }
  3924. static int ASN1CALL ASN1Enc_CrossCertDistPointNames(ASN1encoding_t enc, ASN1uint32_t tag, CrossCertDistPointNames *val)
  3925. {
  3926. ASN1uint32_t nLenOff;
  3927. ASN1uint32_t i;
  3928. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  3929. return 0;
  3930. for (i = 0; i < (val)->count; i++) {
  3931. if (!ASN1Enc_GeneralNames(enc, 0, &((val)->value)[i]))
  3932. return 0;
  3933. }
  3934. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  3935. return 0;
  3936. return 1;
  3937. }
  3938. static int ASN1CALL ASN1Dec_CrossCertDistPointNames(ASN1decoding_t dec, ASN1uint32_t tag, CrossCertDistPointNames *val)
  3939. {
  3940. ASN1decoding_t dd;
  3941. ASN1octet_t *di;
  3942. ASN1uint32_t t;
  3943. ASN1uint32_t n;
  3944. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  3945. return 0;
  3946. (val)->count = n = 0;
  3947. (val)->value = NULL;
  3948. while (ASN1BERDecNotEndOfContents(dd, di)) {
  3949. if (!ASN1BERDecPeekTag(dd, &t))
  3950. return 0;
  3951. if ((val)->count >= n) {
  3952. void *pvASN1DecRealloc;
  3953. n = n ? (n << 1) : 16;
  3954. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  3955. return 0;
  3956. (val)->value = (GeneralNames *) pvASN1DecRealloc;
  3957. }
  3958. if (!ASN1Dec_GeneralNames(dd, 0, &((val)->value)[(val)->count]))
  3959. return 0;
  3960. ((val)->count)++;
  3961. }
  3962. if (!ASN1BERDecEndOfContents(dec, dd, di))
  3963. return 0;
  3964. return 1;
  3965. }
  3966. static void ASN1CALL ASN1Free_CrossCertDistPointNames(CrossCertDistPointNames *val)
  3967. {
  3968. ASN1uint32_t i;
  3969. if (val) {
  3970. ASN1Free_GeneralNames(&(val)->value[0]);
  3971. for (i = 1; i < (val)->count; i++) {
  3972. ASN1Free_GeneralNames(&(val)->value[i]);
  3973. }
  3974. ASN1Free((val)->value);
  3975. }
  3976. }
  3977. static int ASN1CALL ASN1Enc_PolicyMappings(ASN1encoding_t enc, ASN1uint32_t tag, PolicyMappings *val)
  3978. {
  3979. ASN1uint32_t nLenOff;
  3980. ASN1uint32_t i;
  3981. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  3982. return 0;
  3983. for (i = 0; i < (val)->count; i++) {
  3984. if (!ASN1Enc_PolicyMapping(enc, 0, &((val)->value)[i]))
  3985. return 0;
  3986. }
  3987. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  3988. return 0;
  3989. return 1;
  3990. }
  3991. static int ASN1CALL ASN1Dec_PolicyMappings(ASN1decoding_t dec, ASN1uint32_t tag, PolicyMappings *val)
  3992. {
  3993. ASN1decoding_t dd;
  3994. ASN1octet_t *di;
  3995. ASN1uint32_t t;
  3996. ASN1uint32_t n;
  3997. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  3998. return 0;
  3999. (val)->count = n = 0;
  4000. (val)->value = NULL;
  4001. while (ASN1BERDecNotEndOfContents(dd, di)) {
  4002. if (!ASN1BERDecPeekTag(dd, &t))
  4003. return 0;
  4004. if ((val)->count >= n) {
  4005. void *pvASN1DecRealloc;
  4006. n = n ? (n << 1) : 16;
  4007. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  4008. return 0;
  4009. (val)->value = (PolicyMapping *) pvASN1DecRealloc;
  4010. }
  4011. if (!ASN1Dec_PolicyMapping(dd, 0, &((val)->value)[(val)->count]))
  4012. return 0;
  4013. ((val)->count)++;
  4014. }
  4015. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4016. return 0;
  4017. return 1;
  4018. }
  4019. static void ASN1CALL ASN1Free_PolicyMappings(PolicyMappings *val)
  4020. {
  4021. ASN1uint32_t i;
  4022. if (val) {
  4023. ASN1Free_PolicyMapping(&(val)->value[0]);
  4024. for (i = 1; i < (val)->count; i++) {
  4025. ASN1Free_PolicyMapping(&(val)->value[i]);
  4026. }
  4027. ASN1Free((val)->value);
  4028. }
  4029. }
  4030. static int ASN1CALL ASN1Enc_PolicyMapping(ASN1encoding_t enc, ASN1uint32_t tag, PolicyMapping *val)
  4031. {
  4032. ASN1uint32_t nLenOff;
  4033. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4034. return 0;
  4035. if (!ASN1BEREncEoid(enc, 0x6, &(val)->issuerDomainPolicy))
  4036. return 0;
  4037. if (!ASN1BEREncEoid(enc, 0x6, &(val)->subjectDomainPolicy))
  4038. return 0;
  4039. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4040. return 0;
  4041. return 1;
  4042. }
  4043. static int ASN1CALL ASN1Dec_PolicyMapping(ASN1decoding_t dec, ASN1uint32_t tag, PolicyMapping *val)
  4044. {
  4045. ASN1decoding_t dd;
  4046. ASN1octet_t *di;
  4047. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4048. return 0;
  4049. if (!ASN1BERDecEoid(dd, 0x6, &(val)->issuerDomainPolicy))
  4050. return 0;
  4051. if (!ASN1BERDecEoid(dd, 0x6, &(val)->subjectDomainPolicy))
  4052. return 0;
  4053. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4054. return 0;
  4055. return 1;
  4056. }
  4057. static void ASN1CALL ASN1Free_PolicyMapping(PolicyMapping *val)
  4058. {
  4059. if (val) {
  4060. ASN1BEREoid_free(&(val)->issuerDomainPolicy);
  4061. ASN1BEREoid_free(&(val)->subjectDomainPolicy);
  4062. }
  4063. }
  4064. static int ASN1CALL ASN1Enc_PolicyConstraints(ASN1encoding_t enc, ASN1uint32_t tag, PolicyConstraints *val)
  4065. {
  4066. ASN1uint32_t nLenOff;
  4067. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4068. return 0;
  4069. if ((val)->o[0] & 0x80) {
  4070. if (!ASN1BEREncU32(enc, 0x80000000, (val)->requireExplicitPolicy))
  4071. return 0;
  4072. }
  4073. if ((val)->o[0] & 0x40) {
  4074. if (!ASN1BEREncU32(enc, 0x80000001, (val)->inhibitPolicyMapping))
  4075. return 0;
  4076. }
  4077. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4078. return 0;
  4079. return 1;
  4080. }
  4081. static int ASN1CALL ASN1Dec_PolicyConstraints(ASN1decoding_t dec, ASN1uint32_t tag, PolicyConstraints *val)
  4082. {
  4083. ASN1decoding_t dd;
  4084. ASN1octet_t *di;
  4085. ASN1uint32_t t;
  4086. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4087. return 0;
  4088. ZeroMemory((val)->o, 1);
  4089. ASN1BERDecPeekTag(dd, &t);
  4090. if (t == 0x80000000) {
  4091. (val)->o[0] |= 0x80;
  4092. if (!ASN1BERDecU32Val(dd, 0x80000000, (ASN1uint32_t *) &(val)->requireExplicitPolicy))
  4093. return 0;
  4094. }
  4095. ASN1BERDecPeekTag(dd, &t);
  4096. if (t == 0x80000001) {
  4097. (val)->o[0] |= 0x40;
  4098. if (!ASN1BERDecU32Val(dd, 0x80000001, (ASN1uint32_t *) &(val)->inhibitPolicyMapping))
  4099. return 0;
  4100. }
  4101. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4102. return 0;
  4103. return 1;
  4104. }
  4105. static int ASN1CALL ASN1Enc_ControlSequence(ASN1encoding_t enc, ASN1uint32_t tag, ControlSequence *val)
  4106. {
  4107. ASN1uint32_t nLenOff;
  4108. ASN1uint32_t i;
  4109. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4110. return 0;
  4111. for (i = 0; i < (val)->count; i++) {
  4112. if (!ASN1Enc_TaggedAttribute(enc, 0, &((val)->value)[i]))
  4113. return 0;
  4114. }
  4115. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4116. return 0;
  4117. return 1;
  4118. }
  4119. static int ASN1CALL ASN1Dec_ControlSequence(ASN1decoding_t dec, ASN1uint32_t tag, ControlSequence *val)
  4120. {
  4121. ASN1decoding_t dd;
  4122. ASN1octet_t *di;
  4123. ASN1uint32_t t;
  4124. ASN1uint32_t n;
  4125. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4126. return 0;
  4127. (val)->count = n = 0;
  4128. (val)->value = NULL;
  4129. while (ASN1BERDecNotEndOfContents(dd, di)) {
  4130. if (!ASN1BERDecPeekTag(dd, &t))
  4131. return 0;
  4132. if ((val)->count >= n) {
  4133. void *pvASN1DecRealloc;
  4134. n = n ? (n << 1) : 16;
  4135. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  4136. return 0;
  4137. (val)->value = (TaggedAttribute *) pvASN1DecRealloc;
  4138. }
  4139. if (!ASN1Dec_TaggedAttribute(dd, 0, &((val)->value)[(val)->count]))
  4140. return 0;
  4141. ((val)->count)++;
  4142. }
  4143. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4144. return 0;
  4145. return 1;
  4146. }
  4147. static void ASN1CALL ASN1Free_ControlSequence(ControlSequence *val)
  4148. {
  4149. ASN1uint32_t i;
  4150. if (val) {
  4151. ASN1Free_TaggedAttribute(&(val)->value[0]);
  4152. for (i = 1; i < (val)->count; i++) {
  4153. ASN1Free_TaggedAttribute(&(val)->value[i]);
  4154. }
  4155. ASN1Free((val)->value);
  4156. }
  4157. }
  4158. static int ASN1CALL ASN1Enc_ReqSequence(ASN1encoding_t enc, ASN1uint32_t tag, ReqSequence *val)
  4159. {
  4160. ASN1uint32_t nLenOff;
  4161. ASN1uint32_t i;
  4162. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4163. return 0;
  4164. for (i = 0; i < (val)->count; i++) {
  4165. if (!ASN1Enc_TaggedRequest(enc, 0, &((val)->value)[i]))
  4166. return 0;
  4167. }
  4168. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4169. return 0;
  4170. return 1;
  4171. }
  4172. static int ASN1CALL ASN1Dec_ReqSequence(ASN1decoding_t dec, ASN1uint32_t tag, ReqSequence *val)
  4173. {
  4174. ASN1decoding_t dd;
  4175. ASN1octet_t *di;
  4176. ASN1uint32_t t;
  4177. ASN1uint32_t n;
  4178. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4179. return 0;
  4180. (val)->count = n = 0;
  4181. (val)->value = NULL;
  4182. while (ASN1BERDecNotEndOfContents(dd, di)) {
  4183. if (!ASN1BERDecPeekTag(dd, &t))
  4184. return 0;
  4185. if ((val)->count >= n) {
  4186. void *pvASN1DecRealloc;
  4187. n = n ? (n << 1) : 16;
  4188. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  4189. return 0;
  4190. (val)->value = (TaggedRequest *) pvASN1DecRealloc;
  4191. }
  4192. if (!ASN1Dec_TaggedRequest(dd, 0, &((val)->value)[(val)->count]))
  4193. return 0;
  4194. ((val)->count)++;
  4195. }
  4196. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4197. return 0;
  4198. return 1;
  4199. }
  4200. static void ASN1CALL ASN1Free_ReqSequence(ReqSequence *val)
  4201. {
  4202. ASN1uint32_t i;
  4203. if (val) {
  4204. ASN1Free_TaggedRequest(&(val)->value[0]);
  4205. for (i = 1; i < (val)->count; i++) {
  4206. ASN1Free_TaggedRequest(&(val)->value[i]);
  4207. }
  4208. ASN1Free((val)->value);
  4209. }
  4210. }
  4211. static int ASN1CALL ASN1Enc_CmsSequence(ASN1encoding_t enc, ASN1uint32_t tag, CmsSequence *val)
  4212. {
  4213. ASN1uint32_t nLenOff;
  4214. ASN1uint32_t i;
  4215. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4216. return 0;
  4217. for (i = 0; i < (val)->count; i++) {
  4218. if (!ASN1Enc_TaggedContentInfo(enc, 0, &((val)->value)[i]))
  4219. return 0;
  4220. }
  4221. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4222. return 0;
  4223. return 1;
  4224. }
  4225. static int ASN1CALL ASN1Dec_CmsSequence(ASN1decoding_t dec, ASN1uint32_t tag, CmsSequence *val)
  4226. {
  4227. ASN1decoding_t dd;
  4228. ASN1octet_t *di;
  4229. ASN1uint32_t t;
  4230. ASN1uint32_t n;
  4231. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4232. return 0;
  4233. (val)->count = n = 0;
  4234. (val)->value = NULL;
  4235. while (ASN1BERDecNotEndOfContents(dd, di)) {
  4236. if (!ASN1BERDecPeekTag(dd, &t))
  4237. return 0;
  4238. if ((val)->count >= n) {
  4239. void *pvASN1DecRealloc;
  4240. n = n ? (n << 1) : 16;
  4241. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  4242. return 0;
  4243. (val)->value = (TaggedContentInfo *) pvASN1DecRealloc;
  4244. }
  4245. if (!ASN1Dec_TaggedContentInfo(dd, 0, &((val)->value)[(val)->count]))
  4246. return 0;
  4247. ((val)->count)++;
  4248. }
  4249. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4250. return 0;
  4251. return 1;
  4252. }
  4253. static void ASN1CALL ASN1Free_CmsSequence(CmsSequence *val)
  4254. {
  4255. ASN1uint32_t i;
  4256. if (val) {
  4257. ASN1Free_TaggedContentInfo(&(val)->value[0]);
  4258. for (i = 1; i < (val)->count; i++) {
  4259. ASN1Free_TaggedContentInfo(&(val)->value[i]);
  4260. }
  4261. ASN1Free((val)->value);
  4262. }
  4263. }
  4264. static int ASN1CALL ASN1Enc_OtherMsgSequence(ASN1encoding_t enc, ASN1uint32_t tag, OtherMsgSequence *val)
  4265. {
  4266. ASN1uint32_t nLenOff;
  4267. ASN1uint32_t i;
  4268. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4269. return 0;
  4270. for (i = 0; i < (val)->count; i++) {
  4271. if (!ASN1Enc_TaggedOtherMsg(enc, 0, &((val)->value)[i]))
  4272. return 0;
  4273. }
  4274. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4275. return 0;
  4276. return 1;
  4277. }
  4278. static int ASN1CALL ASN1Dec_OtherMsgSequence(ASN1decoding_t dec, ASN1uint32_t tag, OtherMsgSequence *val)
  4279. {
  4280. ASN1decoding_t dd;
  4281. ASN1octet_t *di;
  4282. ASN1uint32_t t;
  4283. ASN1uint32_t n;
  4284. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4285. return 0;
  4286. (val)->count = n = 0;
  4287. (val)->value = NULL;
  4288. while (ASN1BERDecNotEndOfContents(dd, di)) {
  4289. if (!ASN1BERDecPeekTag(dd, &t))
  4290. return 0;
  4291. if ((val)->count >= n) {
  4292. void *pvASN1DecRealloc;
  4293. n = n ? (n << 1) : 16;
  4294. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  4295. return 0;
  4296. (val)->value = (TaggedOtherMsg *) pvASN1DecRealloc;
  4297. }
  4298. if (!ASN1Dec_TaggedOtherMsg(dd, 0, &((val)->value)[(val)->count]))
  4299. return 0;
  4300. ((val)->count)++;
  4301. }
  4302. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4303. return 0;
  4304. return 1;
  4305. }
  4306. static void ASN1CALL ASN1Free_OtherMsgSequence(OtherMsgSequence *val)
  4307. {
  4308. ASN1uint32_t i;
  4309. if (val) {
  4310. ASN1Free_TaggedOtherMsg(&(val)->value[0]);
  4311. for (i = 1; i < (val)->count; i++) {
  4312. ASN1Free_TaggedOtherMsg(&(val)->value[i]);
  4313. }
  4314. ASN1Free((val)->value);
  4315. }
  4316. }
  4317. static int ASN1CALL ASN1Enc_BodyPartIDSequence(ASN1encoding_t enc, ASN1uint32_t tag, BodyPartIDSequence *val)
  4318. {
  4319. ASN1uint32_t nLenOff;
  4320. ASN1uint32_t i;
  4321. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4322. return 0;
  4323. for (i = 0; i < (val)->count; i++) {
  4324. if (!ASN1BEREncU32(enc, 0x2, ((val)->value)[i]))
  4325. return 0;
  4326. }
  4327. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4328. return 0;
  4329. return 1;
  4330. }
  4331. static int ASN1CALL ASN1Dec_BodyPartIDSequence(ASN1decoding_t dec, ASN1uint32_t tag, BodyPartIDSequence *val)
  4332. {
  4333. ASN1decoding_t dd;
  4334. ASN1octet_t *di;
  4335. ASN1uint32_t t;
  4336. ASN1uint32_t n;
  4337. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4338. return 0;
  4339. (val)->count = n = 0;
  4340. (val)->value = NULL;
  4341. while (ASN1BERDecNotEndOfContents(dd, di)) {
  4342. if (!ASN1BERDecPeekTag(dd, &t))
  4343. return 0;
  4344. if ((val)->count >= n) {
  4345. void *pvASN1DecRealloc;
  4346. n = n ? (n << 1) : 16;
  4347. if (!(pvASN1DecRealloc = ASN1DecRealloc(dd, (val)->value, n * sizeof(*(val)->value))))
  4348. return 0;
  4349. (val)->value = (BodyPartID *) pvASN1DecRealloc;
  4350. }
  4351. if (!ASN1BERDecU32Val(dd, 0x2, (ASN1uint32_t *) &((val)->value)[(val)->count]))
  4352. return 0;
  4353. ((val)->count)++;
  4354. }
  4355. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4356. return 0;
  4357. return 1;
  4358. }
  4359. static void ASN1CALL ASN1Free_BodyPartIDSequence(BodyPartIDSequence *val)
  4360. {
  4361. if (val) {
  4362. ASN1Free((val)->value);
  4363. }
  4364. }
  4365. static int ASN1CALL ASN1Enc_TaggedAttribute(ASN1encoding_t enc, ASN1uint32_t tag, TaggedAttribute *val)
  4366. {
  4367. ASN1uint32_t nLenOff;
  4368. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4369. return 0;
  4370. if (!ASN1BEREncU32(enc, 0x2, (val)->bodyPartID))
  4371. return 0;
  4372. if (!ASN1BEREncEoid(enc, 0x6, &(val)->type))
  4373. return 0;
  4374. if (!ASN1Enc_AttributeSetValue(enc, 0, &(val)->values))
  4375. return 0;
  4376. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4377. return 0;
  4378. return 1;
  4379. }
  4380. static int ASN1CALL ASN1Dec_TaggedAttribute(ASN1decoding_t dec, ASN1uint32_t tag, TaggedAttribute *val)
  4381. {
  4382. ASN1decoding_t dd;
  4383. ASN1octet_t *di;
  4384. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4385. return 0;
  4386. if (!ASN1BERDecU32Val(dd, 0x2, (ASN1uint32_t *) &(val)->bodyPartID))
  4387. return 0;
  4388. if (!ASN1BERDecEoid(dd, 0x6, &(val)->type))
  4389. return 0;
  4390. if (!ASN1Dec_AttributeSetValue(dd, 0, &(val)->values))
  4391. return 0;
  4392. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4393. return 0;
  4394. return 1;
  4395. }
  4396. static void ASN1CALL ASN1Free_TaggedAttribute(TaggedAttribute *val)
  4397. {
  4398. if (val) {
  4399. ASN1BEREoid_free(&(val)->type);
  4400. ASN1Free_AttributeSetValue(&(val)->values);
  4401. }
  4402. }
  4403. static int ASN1CALL ASN1Enc_TaggedCertificationRequest(ASN1encoding_t enc, ASN1uint32_t tag, TaggedCertificationRequest *val)
  4404. {
  4405. ASN1uint32_t nLenOff;
  4406. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4407. return 0;
  4408. if (!ASN1BEREncU32(enc, 0x2, (val)->bodyPartID))
  4409. return 0;
  4410. if (!ASN1BEREncOpenType(enc, &(val)->certificationRequest))
  4411. return 0;
  4412. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4413. return 0;
  4414. return 1;
  4415. }
  4416. static int ASN1CALL ASN1Dec_TaggedCertificationRequest(ASN1decoding_t dec, ASN1uint32_t tag, TaggedCertificationRequest *val)
  4417. {
  4418. ASN1decoding_t dd;
  4419. ASN1octet_t *di;
  4420. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4421. return 0;
  4422. if (!ASN1BERDecU32Val(dd, 0x2, (ASN1uint32_t *) &(val)->bodyPartID))
  4423. return 0;
  4424. if (!ASN1BERDecOpenType2(dd, &(val)->certificationRequest))
  4425. return 0;
  4426. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4427. return 0;
  4428. return 1;
  4429. }
  4430. static void ASN1CALL ASN1Free_TaggedCertificationRequest(TaggedCertificationRequest *val)
  4431. {
  4432. if (val) {
  4433. }
  4434. }
  4435. static int ASN1CALL ASN1Enc_TaggedContentInfo(ASN1encoding_t enc, ASN1uint32_t tag, TaggedContentInfo *val)
  4436. {
  4437. ASN1uint32_t nLenOff;
  4438. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4439. return 0;
  4440. if (!ASN1BEREncU32(enc, 0x2, (val)->bodyPartID))
  4441. return 0;
  4442. if (!ASN1BEREncOpenType(enc, &(val)->contentInfo))
  4443. return 0;
  4444. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4445. return 0;
  4446. return 1;
  4447. }
  4448. static int ASN1CALL ASN1Dec_TaggedContentInfo(ASN1decoding_t dec, ASN1uint32_t tag, TaggedContentInfo *val)
  4449. {
  4450. ASN1decoding_t dd;
  4451. ASN1octet_t *di;
  4452. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4453. return 0;
  4454. if (!ASN1BERDecU32Val(dd, 0x2, (ASN1uint32_t *) &(val)->bodyPartID))
  4455. return 0;
  4456. if (!ASN1BERDecOpenType2(dd, &(val)->contentInfo))
  4457. return 0;
  4458. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4459. return 0;
  4460. return 1;
  4461. }
  4462. static void ASN1CALL ASN1Free_TaggedContentInfo(TaggedContentInfo *val)
  4463. {
  4464. if (val) {
  4465. }
  4466. }
  4467. static int ASN1CALL ASN1Enc_TaggedOtherMsg(ASN1encoding_t enc, ASN1uint32_t tag, TaggedOtherMsg *val)
  4468. {
  4469. ASN1uint32_t nLenOff;
  4470. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4471. return 0;
  4472. if (!ASN1BEREncU32(enc, 0x2, (val)->bodyPartID))
  4473. return 0;
  4474. if (!ASN1BEREncEoid(enc, 0x6, &(val)->otherMsgType))
  4475. return 0;
  4476. if (!ASN1BEREncOpenType(enc, &(val)->otherMsgValue))
  4477. return 0;
  4478. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4479. return 0;
  4480. return 1;
  4481. }
  4482. static int ASN1CALL ASN1Dec_TaggedOtherMsg(ASN1decoding_t dec, ASN1uint32_t tag, TaggedOtherMsg *val)
  4483. {
  4484. ASN1decoding_t dd;
  4485. ASN1octet_t *di;
  4486. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4487. return 0;
  4488. if (!ASN1BERDecU32Val(dd, 0x2, (ASN1uint32_t *) &(val)->bodyPartID))
  4489. return 0;
  4490. if (!ASN1BERDecEoid(dd, 0x6, &(val)->otherMsgType))
  4491. return 0;
  4492. if (!ASN1BERDecOpenType2(dd, &(val)->otherMsgValue))
  4493. return 0;
  4494. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4495. return 0;
  4496. return 1;
  4497. }
  4498. static void ASN1CALL ASN1Free_TaggedOtherMsg(TaggedOtherMsg *val)
  4499. {
  4500. if (val) {
  4501. ASN1BEREoid_free(&(val)->otherMsgType);
  4502. }
  4503. }
  4504. static int ASN1CALL ASN1Enc_PendInfo(ASN1encoding_t enc, ASN1uint32_t tag, PendInfo *val)
  4505. {
  4506. ASN1uint32_t nLenOff;
  4507. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4508. return 0;
  4509. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->pendToken).length, ((val)->pendToken).value))
  4510. return 0;
  4511. if (!ASN1DEREncGeneralizedTime(enc, 0x18, &(val)->pendTime))
  4512. return 0;
  4513. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4514. return 0;
  4515. return 1;
  4516. }
  4517. static int ASN1CALL ASN1Dec_PendInfo(ASN1decoding_t dec, ASN1uint32_t tag, PendInfo *val)
  4518. {
  4519. ASN1decoding_t dd;
  4520. ASN1octet_t *di;
  4521. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4522. return 0;
  4523. if (!ASN1BERDecOctetString2(dd, 0x4, &(val)->pendToken))
  4524. return 0;
  4525. if (!ASN1BERDecGeneralizedTime(dd, 0x18, &(val)->pendTime))
  4526. return 0;
  4527. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4528. return 0;
  4529. return 1;
  4530. }
  4531. static void ASN1CALL ASN1Free_PendInfo(PendInfo *val)
  4532. {
  4533. if (val) {
  4534. }
  4535. }
  4536. static int ASN1CALL ASN1Enc_CmcAddExtensions(ASN1encoding_t enc, ASN1uint32_t tag, CmcAddExtensions *val)
  4537. {
  4538. ASN1uint32_t nLenOff;
  4539. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4540. return 0;
  4541. if (!ASN1BEREncU32(enc, 0x2, (val)->pkiDataReference))
  4542. return 0;
  4543. if (!ASN1Enc_BodyPartIDSequence(enc, 0, &(val)->certReferences))
  4544. return 0;
  4545. if (!ASN1Enc_Extensions(enc, 0, &(val)->extensions))
  4546. return 0;
  4547. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4548. return 0;
  4549. return 1;
  4550. }
  4551. static int ASN1CALL ASN1Dec_CmcAddExtensions(ASN1decoding_t dec, ASN1uint32_t tag, CmcAddExtensions *val)
  4552. {
  4553. ASN1decoding_t dd;
  4554. ASN1octet_t *di;
  4555. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4556. return 0;
  4557. if (!ASN1BERDecU32Val(dd, 0x2, (ASN1uint32_t *) &(val)->pkiDataReference))
  4558. return 0;
  4559. if (!ASN1Dec_BodyPartIDSequence(dd, 0, &(val)->certReferences))
  4560. return 0;
  4561. if (!ASN1Dec_Extensions(dd, 0, &(val)->extensions))
  4562. return 0;
  4563. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4564. return 0;
  4565. return 1;
  4566. }
  4567. static void ASN1CALL ASN1Free_CmcAddExtensions(CmcAddExtensions *val)
  4568. {
  4569. if (val) {
  4570. ASN1Free_BodyPartIDSequence(&(val)->certReferences);
  4571. ASN1Free_Extensions(&(val)->extensions);
  4572. }
  4573. }
  4574. static int ASN1CALL ASN1Enc_CmcAddAttributes(ASN1encoding_t enc, ASN1uint32_t tag, CmcAddAttributes *val)
  4575. {
  4576. ASN1uint32_t nLenOff;
  4577. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4578. return 0;
  4579. if (!ASN1BEREncU32(enc, 0x2, (val)->pkiDataReference))
  4580. return 0;
  4581. if (!ASN1Enc_BodyPartIDSequence(enc, 0, &(val)->certReferences))
  4582. return 0;
  4583. if (!ASN1Enc_Attributes(enc, 0, &(val)->attributes))
  4584. return 0;
  4585. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4586. return 0;
  4587. return 1;
  4588. }
  4589. static int ASN1CALL ASN1Dec_CmcAddAttributes(ASN1decoding_t dec, ASN1uint32_t tag, CmcAddAttributes *val)
  4590. {
  4591. ASN1decoding_t dd;
  4592. ASN1octet_t *di;
  4593. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4594. return 0;
  4595. if (!ASN1BERDecU32Val(dd, 0x2, (ASN1uint32_t *) &(val)->pkiDataReference))
  4596. return 0;
  4597. if (!ASN1Dec_BodyPartIDSequence(dd, 0, &(val)->certReferences))
  4598. return 0;
  4599. if (!ASN1Dec_Attributes(dd, 0, &(val)->attributes))
  4600. return 0;
  4601. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4602. return 0;
  4603. return 1;
  4604. }
  4605. static void ASN1CALL ASN1Free_CmcAddAttributes(CmcAddAttributes *val)
  4606. {
  4607. if (val) {
  4608. ASN1Free_BodyPartIDSequence(&(val)->certReferences);
  4609. ASN1Free_Attributes(&(val)->attributes);
  4610. }
  4611. }
  4612. static int ASN1CALL ASN1Enc_CertificateTemplate(ASN1encoding_t enc, ASN1uint32_t tag, CertificateTemplate *val)
  4613. {
  4614. ASN1uint32_t nLenOff;
  4615. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4616. return 0;
  4617. if (!ASN1BEREncEoid(enc, 0x6, &(val)->templateID))
  4618. return 0;
  4619. if (!ASN1BEREncU32(enc, 0x2, (val)->templateMajorVersion))
  4620. return 0;
  4621. if ((val)->o[0] & 0x80) {
  4622. if (!ASN1BEREncU32(enc, 0x2, (val)->templateMinorVersion))
  4623. return 0;
  4624. }
  4625. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4626. return 0;
  4627. return 1;
  4628. }
  4629. static int ASN1CALL ASN1Dec_CertificateTemplate(ASN1decoding_t dec, ASN1uint32_t tag, CertificateTemplate *val)
  4630. {
  4631. ASN1decoding_t dd;
  4632. ASN1octet_t *di;
  4633. ASN1uint32_t t;
  4634. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4635. return 0;
  4636. ZeroMemory((val)->o, 1);
  4637. if (!ASN1BERDecEoid(dd, 0x6, &(val)->templateID))
  4638. return 0;
  4639. if (!ASN1BERDecU32Val(dd, 0x2, (ASN1uint32_t *) &(val)->templateMajorVersion))
  4640. return 0;
  4641. ASN1BERDecPeekTag(dd, &t);
  4642. if (t == 0x2) {
  4643. (val)->o[0] |= 0x80;
  4644. if (!ASN1BERDecU32Val(dd, 0x2, (ASN1uint32_t *) &(val)->templateMinorVersion))
  4645. return 0;
  4646. }
  4647. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4648. return 0;
  4649. return 1;
  4650. }
  4651. static void ASN1CALL ASN1Free_CertificateTemplate(CertificateTemplate *val)
  4652. {
  4653. if (val) {
  4654. ASN1BEREoid_free(&(val)->templateID);
  4655. }
  4656. }
  4657. static int ASN1CALL ASN1Enc_CmcStatusInfo_otherInfo(ASN1encoding_t enc, ASN1uint32_t tag, CmcStatusInfo_otherInfo *val)
  4658. {
  4659. switch ((val)->choice) {
  4660. case 1:
  4661. if (!ASN1BEREncU32(enc, 0x2, (val)->u.failInfo))
  4662. return 0;
  4663. break;
  4664. case 2:
  4665. if (!ASN1Enc_PendInfo(enc, 0, &(val)->u.pendInfo))
  4666. return 0;
  4667. break;
  4668. default:
  4669. /* impossible */
  4670. ASN1EncSetError(enc, ASN1_ERR_CHOICE);
  4671. return 0;
  4672. }
  4673. return 1;
  4674. }
  4675. static int ASN1CALL ASN1Dec_CmcStatusInfo_otherInfo(ASN1decoding_t dec, ASN1uint32_t tag, CmcStatusInfo_otherInfo *val)
  4676. {
  4677. ASN1uint32_t t;
  4678. if (!ASN1BERDecPeekTag(dec, &t))
  4679. return 0;
  4680. switch (t) {
  4681. case 0x2:
  4682. (val)->choice = 1;
  4683. if (!ASN1BERDecU32Val(dec, 0x2, (ASN1uint32_t *) &(val)->u.failInfo))
  4684. return 0;
  4685. break;
  4686. case 0x10:
  4687. (val)->choice = 2;
  4688. if (!ASN1Dec_PendInfo(dec, 0, &(val)->u.pendInfo))
  4689. return 0;
  4690. break;
  4691. default:
  4692. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  4693. return 0;
  4694. }
  4695. return 1;
  4696. }
  4697. static void ASN1CALL ASN1Free_CmcStatusInfo_otherInfo(CmcStatusInfo_otherInfo *val)
  4698. {
  4699. if (val) {
  4700. switch ((val)->choice) {
  4701. case 2:
  4702. ASN1Free_PendInfo(&(val)->u.pendInfo);
  4703. break;
  4704. }
  4705. }
  4706. }
  4707. static int ASN1CALL ASN1Enc_CpsURLs_Seq(ASN1encoding_t enc, ASN1uint32_t tag, CpsURLs_Seq *val)
  4708. {
  4709. ASN1uint32_t nLenOff;
  4710. ASN1uint32_t t;
  4711. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4712. return 0;
  4713. t = lstrlenA((val)->url);
  4714. if (!ASN1DEREncCharString(enc, 0x16, t, (val)->url))
  4715. return 0;
  4716. if ((val)->o[0] & 0x80) {
  4717. if (!ASN1Enc_AlgorithmIdentifier(enc, 0, &(val)->digestAlgorithmId))
  4718. return 0;
  4719. }
  4720. if ((val)->o[0] & 0x40) {
  4721. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->digest).length, ((val)->digest).value))
  4722. return 0;
  4723. }
  4724. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4725. return 0;
  4726. return 1;
  4727. }
  4728. static int ASN1CALL ASN1Dec_CpsURLs_Seq(ASN1decoding_t dec, ASN1uint32_t tag, CpsURLs_Seq *val)
  4729. {
  4730. ASN1decoding_t dd;
  4731. ASN1octet_t *di;
  4732. ASN1uint32_t t;
  4733. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4734. return 0;
  4735. ZeroMemory((val)->o, 1);
  4736. if (!ASN1BERDecZeroCharString(dd, 0x16, &(val)->url))
  4737. return 0;
  4738. ASN1BERDecPeekTag(dd, &t);
  4739. if (t == 0x10) {
  4740. (val)->o[0] |= 0x80;
  4741. if (!ASN1Dec_AlgorithmIdentifier(dd, 0, &(val)->digestAlgorithmId))
  4742. return 0;
  4743. }
  4744. ASN1BERDecPeekTag(dd, &t);
  4745. if (t == 0x4) {
  4746. (val)->o[0] |= 0x40;
  4747. if (!ASN1BERDecOctetString2(dd, 0x4, &(val)->digest))
  4748. return 0;
  4749. }
  4750. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4751. return 0;
  4752. return 1;
  4753. }
  4754. static void ASN1CALL ASN1Free_CpsURLs_Seq(CpsURLs_Seq *val)
  4755. {
  4756. if (val) {
  4757. ASN1ztcharstring_free((val)->url);
  4758. if ((val)->o[0] & 0x80) {
  4759. ASN1Free_AlgorithmIdentifier(&(val)->digestAlgorithmId);
  4760. }
  4761. if ((val)->o[0] & 0x40) {
  4762. }
  4763. }
  4764. }
  4765. static int ASN1CALL ASN1Enc_Attribute(ASN1encoding_t enc, ASN1uint32_t tag, Attribute *val)
  4766. {
  4767. ASN1uint32_t nLenOff;
  4768. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4769. return 0;
  4770. if (!ASN1BEREncEoid(enc, 0x6, &(val)->type))
  4771. return 0;
  4772. if (!ASN1Enc_AttributeSetValue(enc, 0, &(val)->values))
  4773. return 0;
  4774. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4775. return 0;
  4776. return 1;
  4777. }
  4778. static int ASN1CALL ASN1Dec_Attribute(ASN1decoding_t dec, ASN1uint32_t tag, Attribute *val)
  4779. {
  4780. ASN1decoding_t dd;
  4781. ASN1octet_t *di;
  4782. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4783. return 0;
  4784. if (!ASN1BERDecEoid(dd, 0x6, &(val)->type))
  4785. return 0;
  4786. if (!ASN1Dec_AttributeSetValue(dd, 0, &(val)->values))
  4787. return 0;
  4788. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4789. return 0;
  4790. return 1;
  4791. }
  4792. static void ASN1CALL ASN1Free_Attribute(Attribute *val)
  4793. {
  4794. if (val) {
  4795. ASN1BEREoid_free(&(val)->type);
  4796. ASN1Free_AttributeSetValue(&(val)->values);
  4797. }
  4798. }
  4799. static int ASN1CALL ASN1Enc_X942DhParameters(ASN1encoding_t enc, ASN1uint32_t tag, X942DhParameters *val)
  4800. {
  4801. ASN1uint32_t nLenOff;
  4802. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4803. return 0;
  4804. if (!ASN1BEREncSX(enc, 0x2, &(val)->p))
  4805. return 0;
  4806. if (!ASN1BEREncSX(enc, 0x2, &(val)->g))
  4807. return 0;
  4808. if (!ASN1BEREncSX(enc, 0x2, &(val)->q))
  4809. return 0;
  4810. if ((val)->o[0] & 0x80) {
  4811. if (!ASN1BEREncSX(enc, 0x2, &(val)->j))
  4812. return 0;
  4813. }
  4814. if ((val)->o[0] & 0x40) {
  4815. if (!ASN1Enc_X942DhValidationParams(enc, 0, &(val)->validationParams))
  4816. return 0;
  4817. }
  4818. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4819. return 0;
  4820. return 1;
  4821. }
  4822. static int ASN1CALL ASN1Dec_X942DhParameters(ASN1decoding_t dec, ASN1uint32_t tag, X942DhParameters *val)
  4823. {
  4824. ASN1decoding_t dd;
  4825. ASN1octet_t *di;
  4826. ASN1uint32_t t;
  4827. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4828. return 0;
  4829. ZeroMemory((val)->o, 1);
  4830. if (!ASN1BERDecSXVal(dd, 0x2, &(val)->p))
  4831. return 0;
  4832. if (!ASN1BERDecSXVal(dd, 0x2, &(val)->g))
  4833. return 0;
  4834. if (!ASN1BERDecSXVal(dd, 0x2, &(val)->q))
  4835. return 0;
  4836. ASN1BERDecPeekTag(dd, &t);
  4837. if (t == 0x2) {
  4838. (val)->o[0] |= 0x80;
  4839. if (!ASN1BERDecSXVal(dd, 0x2, &(val)->j))
  4840. return 0;
  4841. }
  4842. ASN1BERDecPeekTag(dd, &t);
  4843. if (t == 0x10) {
  4844. (val)->o[0] |= 0x40;
  4845. if (!ASN1Dec_X942DhValidationParams(dd, 0, &(val)->validationParams))
  4846. return 0;
  4847. }
  4848. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4849. return 0;
  4850. return 1;
  4851. }
  4852. static void ASN1CALL ASN1Free_X942DhParameters(X942DhParameters *val)
  4853. {
  4854. if (val) {
  4855. ASN1intx_free(&(val)->p);
  4856. ASN1intx_free(&(val)->g);
  4857. ASN1intx_free(&(val)->q);
  4858. if ((val)->o[0] & 0x80) {
  4859. ASN1intx_free(&(val)->j);
  4860. }
  4861. if ((val)->o[0] & 0x40) {
  4862. ASN1Free_X942DhValidationParams(&(val)->validationParams);
  4863. }
  4864. }
  4865. }
  4866. static int ASN1CALL ASN1Enc_X942DhOtherInfo(ASN1encoding_t enc, ASN1uint32_t tag, X942DhOtherInfo *val)
  4867. {
  4868. ASN1uint32_t nLenOff;
  4869. ASN1uint32_t nLenOff0;
  4870. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4871. return 0;
  4872. if (!ASN1Enc_X942DhKeySpecificInfo(enc, 0, &(val)->keyInfo))
  4873. return 0;
  4874. if ((val)->o[0] & 0x80) {
  4875. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  4876. return 0;
  4877. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->pubInfo).length, ((val)->pubInfo).value))
  4878. return 0;
  4879. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  4880. return 0;
  4881. }
  4882. if (!ASN1BEREncExplicitTag(enc, 0x80000002, &nLenOff0))
  4883. return 0;
  4884. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->keyLength).length, ((val)->keyLength).value))
  4885. return 0;
  4886. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  4887. return 0;
  4888. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4889. return 0;
  4890. return 1;
  4891. }
  4892. static int ASN1CALL ASN1Dec_X942DhOtherInfo(ASN1decoding_t dec, ASN1uint32_t tag, X942DhOtherInfo *val)
  4893. {
  4894. ASN1decoding_t dd;
  4895. ASN1octet_t *di;
  4896. ASN1uint32_t t;
  4897. ASN1decoding_t dd0;
  4898. ASN1octet_t *di0;
  4899. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4900. return 0;
  4901. ZeroMemory((val)->o, 1);
  4902. if (!ASN1Dec_X942DhKeySpecificInfo(dd, 0, &(val)->keyInfo))
  4903. return 0;
  4904. ASN1BERDecPeekTag(dd, &t);
  4905. if (t == 0x80000000) {
  4906. (val)->o[0] |= 0x80;
  4907. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  4908. return 0;
  4909. if (!ASN1BERDecOctetString2(dd0, 0x4, &(val)->pubInfo))
  4910. return 0;
  4911. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  4912. return 0;
  4913. }
  4914. if (!ASN1BERDecExplicitTag(dd, 0x80000002, &dd0, &di0))
  4915. return 0;
  4916. if (!ASN1BERDecOctetString2(dd0, 0x4, &(val)->keyLength))
  4917. return 0;
  4918. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  4919. return 0;
  4920. if (!ASN1BERDecEndOfContents(dec, dd, di))
  4921. return 0;
  4922. return 1;
  4923. }
  4924. static void ASN1CALL ASN1Free_X942DhOtherInfo(X942DhOtherInfo *val)
  4925. {
  4926. if (val) {
  4927. ASN1Free_X942DhKeySpecificInfo(&(val)->keyInfo);
  4928. if ((val)->o[0] & 0x80) {
  4929. }
  4930. }
  4931. }
  4932. static int ASN1CALL ASN1Enc_CertificateToBeSigned(ASN1encoding_t enc, ASN1uint32_t tag, CertificateToBeSigned *val)
  4933. {
  4934. ASN1uint32_t nLenOff;
  4935. ASN1octet_t o[1];
  4936. ASN1uint32_t nLenOff0;
  4937. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  4938. return 0;
  4939. CopyMemory(o, (val)->o, 1);
  4940. if ((val)->version == 0)
  4941. o[0] &= ~0x80;
  4942. if (o[0] & 0x80) {
  4943. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  4944. return 0;
  4945. if (!ASN1BEREncS32(enc, 0x2, (val)->version))
  4946. return 0;
  4947. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  4948. return 0;
  4949. }
  4950. if (!ASN1BEREncSX(enc, 0x2, &(val)->serialNumber))
  4951. return 0;
  4952. if (!ASN1Enc_AlgorithmIdentifier(enc, 0, &(val)->signature))
  4953. return 0;
  4954. if (!ASN1BEREncOpenType(enc, &(val)->issuer))
  4955. return 0;
  4956. if (!ASN1Enc_Validity(enc, 0, &(val)->validity))
  4957. return 0;
  4958. if (!ASN1BEREncOpenType(enc, &(val)->subject))
  4959. return 0;
  4960. if (!ASN1Enc_SubjectPublicKeyInfo(enc, 0, &(val)->subjectPublicKeyInfo))
  4961. return 0;
  4962. if (o[0] & 0x40) {
  4963. if (!ASN1DEREncBitString(enc, 0x80000001, ((val)->issuerUniqueIdentifier).length, ((val)->issuerUniqueIdentifier).value))
  4964. return 0;
  4965. }
  4966. if (o[0] & 0x20) {
  4967. if (!ASN1DEREncBitString(enc, 0x80000002, ((val)->subjectUniqueIdentifier).length, ((val)->subjectUniqueIdentifier).value))
  4968. return 0;
  4969. }
  4970. if (o[0] & 0x10) {
  4971. if (!ASN1BEREncExplicitTag(enc, 0x80000003, &nLenOff0))
  4972. return 0;
  4973. if (!ASN1Enc_Extensions(enc, 0, &(val)->extensions))
  4974. return 0;
  4975. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  4976. return 0;
  4977. }
  4978. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  4979. return 0;
  4980. return 1;
  4981. }
  4982. static int ASN1CALL ASN1Dec_CertificateToBeSigned(ASN1decoding_t dec, ASN1uint32_t tag, CertificateToBeSigned *val)
  4983. {
  4984. ASN1decoding_t dd;
  4985. ASN1octet_t *di;
  4986. ASN1uint32_t t;
  4987. ASN1decoding_t dd0;
  4988. ASN1octet_t *di0;
  4989. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  4990. return 0;
  4991. ZeroMemory((val)->o, 1);
  4992. ASN1BERDecPeekTag(dd, &t);
  4993. if (t == 0x80000000) {
  4994. (val)->o[0] |= 0x80;
  4995. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  4996. return 0;
  4997. if (!ASN1BERDecS32Val(dd0, 0x2, &(val)->version))
  4998. return 0;
  4999. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  5000. return 0;
  5001. }
  5002. if (!ASN1BERDecSXVal(dd, 0x2, &(val)->serialNumber))
  5003. return 0;
  5004. if (!ASN1Dec_AlgorithmIdentifier(dd, 0, &(val)->signature))
  5005. return 0;
  5006. if (!ASN1BERDecOpenType2(dd, &(val)->issuer))
  5007. return 0;
  5008. if (!ASN1Dec_Validity(dd, 0, &(val)->validity))
  5009. return 0;
  5010. if (!ASN1BERDecOpenType2(dd, &(val)->subject))
  5011. return 0;
  5012. if (!ASN1Dec_SubjectPublicKeyInfo(dd, 0, &(val)->subjectPublicKeyInfo))
  5013. return 0;
  5014. ASN1BERDecPeekTag(dd, &t);
  5015. if (t == 0x80000001) {
  5016. (val)->o[0] |= 0x40;
  5017. if (!ASN1BERDecBitString2(dd, 0x80000001, &(val)->issuerUniqueIdentifier))
  5018. return 0;
  5019. }
  5020. ASN1BERDecPeekTag(dd, &t);
  5021. if (t == 0x80000002) {
  5022. (val)->o[0] |= 0x20;
  5023. if (!ASN1BERDecBitString2(dd, 0x80000002, &(val)->subjectUniqueIdentifier))
  5024. return 0;
  5025. }
  5026. ASN1BERDecPeekTag(dd, &t);
  5027. if (t == 0x80000003) {
  5028. (val)->o[0] |= 0x10;
  5029. if (!ASN1BERDecExplicitTag(dd, 0x80000003, &dd0, &di0))
  5030. return 0;
  5031. if (!ASN1Dec_Extensions(dd0, 0, &(val)->extensions))
  5032. return 0;
  5033. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  5034. return 0;
  5035. }
  5036. if (!((val)->o[0] & 0x80))
  5037. (val)->version = 0;
  5038. if (!ASN1BERDecEndOfContents(dec, dd, di))
  5039. return 0;
  5040. return 1;
  5041. }
  5042. static void ASN1CALL ASN1Free_CertificateToBeSigned(CertificateToBeSigned *val)
  5043. {
  5044. if (val) {
  5045. ASN1intx_free(&(val)->serialNumber);
  5046. ASN1Free_AlgorithmIdentifier(&(val)->signature);
  5047. ASN1Free_Validity(&(val)->validity);
  5048. ASN1Free_SubjectPublicKeyInfo(&(val)->subjectPublicKeyInfo);
  5049. if ((val)->o[0] & 0x40) {
  5050. }
  5051. if ((val)->o[0] & 0x20) {
  5052. }
  5053. if ((val)->o[0] & 0x10) {
  5054. ASN1Free_Extensions(&(val)->extensions);
  5055. }
  5056. }
  5057. }
  5058. static int ASN1CALL ASN1Enc_CertificateRevocationListToBeSigned(ASN1encoding_t enc, ASN1uint32_t tag, CertificateRevocationListToBeSigned *val)
  5059. {
  5060. ASN1uint32_t nLenOff;
  5061. ASN1uint32_t nLenOff0;
  5062. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  5063. return 0;
  5064. if ((val)->o[0] & 0x80) {
  5065. if (!ASN1BEREncS32(enc, 0x2, (val)->version))
  5066. return 0;
  5067. }
  5068. if (!ASN1Enc_AlgorithmIdentifier(enc, 0, &(val)->signature))
  5069. return 0;
  5070. if (!ASN1BEREncOpenType(enc, &(val)->issuer))
  5071. return 0;
  5072. if (!ASN1Enc_ChoiceOfTime(enc, 0, &(val)->thisUpdate))
  5073. return 0;
  5074. if ((val)->o[0] & 0x40) {
  5075. if (!ASN1Enc_ChoiceOfTime(enc, 0, &(val)->nextUpdate))
  5076. return 0;
  5077. }
  5078. if ((val)->o[0] & 0x20) {
  5079. if (!ASN1Enc_RevokedCertificates(enc, 0, &(val)->revokedCertificates))
  5080. return 0;
  5081. }
  5082. if ((val)->o[0] & 0x10) {
  5083. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  5084. return 0;
  5085. if (!ASN1Enc_Extensions(enc, 0, &(val)->crlExtensions))
  5086. return 0;
  5087. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  5088. return 0;
  5089. }
  5090. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  5091. return 0;
  5092. return 1;
  5093. }
  5094. static int ASN1CALL ASN1Dec_CertificateRevocationListToBeSigned(ASN1decoding_t dec, ASN1uint32_t tag, CertificateRevocationListToBeSigned *val)
  5095. {
  5096. ASN1decoding_t dd;
  5097. ASN1octet_t *di;
  5098. ASN1uint32_t t;
  5099. ASN1decoding_t dd0;
  5100. ASN1octet_t *di0;
  5101. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  5102. return 0;
  5103. ZeroMemory((val)->o, 1);
  5104. ASN1BERDecPeekTag(dd, &t);
  5105. if (t == 0x2) {
  5106. (val)->o[0] |= 0x80;
  5107. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->version))
  5108. return 0;
  5109. }
  5110. if (!ASN1Dec_AlgorithmIdentifier(dd, 0, &(val)->signature))
  5111. return 0;
  5112. if (!ASN1BERDecOpenType2(dd, &(val)->issuer))
  5113. return 0;
  5114. if (!ASN1Dec_ChoiceOfTime(dd, 0, &(val)->thisUpdate))
  5115. return 0;
  5116. ASN1BERDecPeekTag(dd, &t);
  5117. if (t == 0x17 || t == 0x18) {
  5118. (val)->o[0] |= 0x40;
  5119. if (!ASN1Dec_ChoiceOfTime(dd, 0, &(val)->nextUpdate))
  5120. return 0;
  5121. }
  5122. ASN1BERDecPeekTag(dd, &t);
  5123. if (t == 0x10) {
  5124. (val)->o[0] |= 0x20;
  5125. if (!ASN1Dec_RevokedCertificates(dd, 0, &(val)->revokedCertificates))
  5126. return 0;
  5127. }
  5128. ASN1BERDecPeekTag(dd, &t);
  5129. if (t == 0x80000000) {
  5130. (val)->o[0] |= 0x10;
  5131. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  5132. return 0;
  5133. if (!ASN1Dec_Extensions(dd0, 0, &(val)->crlExtensions))
  5134. return 0;
  5135. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  5136. return 0;
  5137. }
  5138. if (!ASN1BERDecEndOfContents(dec, dd, di))
  5139. return 0;
  5140. return 1;
  5141. }
  5142. static void ASN1CALL ASN1Free_CertificateRevocationListToBeSigned(CertificateRevocationListToBeSigned *val)
  5143. {
  5144. if (val) {
  5145. ASN1Free_AlgorithmIdentifier(&(val)->signature);
  5146. ASN1Free_ChoiceOfTime(&(val)->thisUpdate);
  5147. if ((val)->o[0] & 0x40) {
  5148. ASN1Free_ChoiceOfTime(&(val)->nextUpdate);
  5149. }
  5150. if ((val)->o[0] & 0x20) {
  5151. ASN1Free_RevokedCertificates(&(val)->revokedCertificates);
  5152. }
  5153. if ((val)->o[0] & 0x10) {
  5154. ASN1Free_Extensions(&(val)->crlExtensions);
  5155. }
  5156. }
  5157. }
  5158. static int ASN1CALL ASN1Enc_KeyAttributes(ASN1encoding_t enc, ASN1uint32_t tag, KeyAttributes *val)
  5159. {
  5160. ASN1uint32_t nLenOff;
  5161. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  5162. return 0;
  5163. if ((val)->o[0] & 0x80) {
  5164. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->keyIdentifier).length, ((val)->keyIdentifier).value))
  5165. return 0;
  5166. }
  5167. if ((val)->o[0] & 0x40) {
  5168. if (!ASN1DEREncBitString(enc, 0x3, ((val)->intendedKeyUsage).length, ((val)->intendedKeyUsage).value))
  5169. return 0;
  5170. }
  5171. if ((val)->o[0] & 0x20) {
  5172. if (!ASN1Enc_PrivateKeyValidity(enc, 0, &(val)->privateKeyUsagePeriod))
  5173. return 0;
  5174. }
  5175. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  5176. return 0;
  5177. return 1;
  5178. }
  5179. static int ASN1CALL ASN1Dec_KeyAttributes(ASN1decoding_t dec, ASN1uint32_t tag, KeyAttributes *val)
  5180. {
  5181. ASN1decoding_t dd;
  5182. ASN1octet_t *di;
  5183. ASN1uint32_t t;
  5184. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  5185. return 0;
  5186. ZeroMemory((val)->o, 1);
  5187. ASN1BERDecPeekTag(dd, &t);
  5188. if (t == 0x4) {
  5189. (val)->o[0] |= 0x80;
  5190. if (!ASN1BERDecOctetString2(dd, 0x4, &(val)->keyIdentifier))
  5191. return 0;
  5192. }
  5193. ASN1BERDecPeekTag(dd, &t);
  5194. if (t == 0x3) {
  5195. (val)->o[0] |= 0x40;
  5196. if (!ASN1BERDecBitString2(dd, 0x3, &(val)->intendedKeyUsage))
  5197. return 0;
  5198. }
  5199. ASN1BERDecPeekTag(dd, &t);
  5200. if (t == 0x10) {
  5201. (val)->o[0] |= 0x20;
  5202. if (!ASN1Dec_PrivateKeyValidity(dd, 0, &(val)->privateKeyUsagePeriod))
  5203. return 0;
  5204. }
  5205. if (!ASN1BERDecEndOfContents(dec, dd, di))
  5206. return 0;
  5207. return 1;
  5208. }
  5209. static void ASN1CALL ASN1Free_KeyAttributes(KeyAttributes *val)
  5210. {
  5211. if (val) {
  5212. if ((val)->o[0] & 0x80) {
  5213. }
  5214. if ((val)->o[0] & 0x40) {
  5215. }
  5216. if ((val)->o[0] & 0x20) {
  5217. ASN1Free_PrivateKeyValidity(&(val)->privateKeyUsagePeriod);
  5218. }
  5219. }
  5220. }
  5221. static int ASN1CALL ASN1Enc_KeyUsageRestriction(ASN1encoding_t enc, ASN1uint32_t tag, KeyUsageRestriction *val)
  5222. {
  5223. ASN1uint32_t nLenOff;
  5224. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  5225. return 0;
  5226. if ((val)->o[0] & 0x80) {
  5227. if (!ASN1Enc_CertPolicySet(enc, 0, &(val)->certPolicySet))
  5228. return 0;
  5229. }
  5230. if ((val)->o[0] & 0x40) {
  5231. if (!ASN1DEREncBitString(enc, 0x3, ((val)->restrictedKeyUsage).length, ((val)->restrictedKeyUsage).value))
  5232. return 0;
  5233. }
  5234. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  5235. return 0;
  5236. return 1;
  5237. }
  5238. static int ASN1CALL ASN1Dec_KeyUsageRestriction(ASN1decoding_t dec, ASN1uint32_t tag, KeyUsageRestriction *val)
  5239. {
  5240. ASN1decoding_t dd;
  5241. ASN1octet_t *di;
  5242. ASN1uint32_t t;
  5243. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  5244. return 0;
  5245. ZeroMemory((val)->o, 1);
  5246. ASN1BERDecPeekTag(dd, &t);
  5247. if (t == 0x10) {
  5248. (val)->o[0] |= 0x80;
  5249. if (!ASN1Dec_CertPolicySet(dd, 0, &(val)->certPolicySet))
  5250. return 0;
  5251. }
  5252. ASN1BERDecPeekTag(dd, &t);
  5253. if (t == 0x3) {
  5254. (val)->o[0] |= 0x40;
  5255. if (!ASN1BERDecBitString2(dd, 0x3, &(val)->restrictedKeyUsage))
  5256. return 0;
  5257. }
  5258. if (!ASN1BERDecEndOfContents(dec, dd, di))
  5259. return 0;
  5260. return 1;
  5261. }
  5262. static void ASN1CALL ASN1Free_KeyUsageRestriction(KeyUsageRestriction *val)
  5263. {
  5264. if (val) {
  5265. if ((val)->o[0] & 0x80) {
  5266. ASN1Free_CertPolicySet(&(val)->certPolicySet);
  5267. }
  5268. if ((val)->o[0] & 0x40) {
  5269. }
  5270. }
  5271. }
  5272. static int ASN1CALL ASN1Enc_GeneralName(ASN1encoding_t enc, ASN1uint32_t tag, GeneralName *val)
  5273. {
  5274. ASN1uint32_t nLenOff0;
  5275. switch ((val)->choice) {
  5276. case 1:
  5277. if (!ASN1Enc_OtherName(enc, 0x80000000, &(val)->u.otherName))
  5278. return 0;
  5279. break;
  5280. case 2:
  5281. if (!ASN1DEREncCharString(enc, 0x80000001, ((val)->u.rfc822Name).length, ((val)->u.rfc822Name).value))
  5282. return 0;
  5283. break;
  5284. case 3:
  5285. if (!ASN1DEREncCharString(enc, 0x80000002, ((val)->u.dNSName).length, ((val)->u.dNSName).value))
  5286. return 0;
  5287. break;
  5288. case 4:
  5289. if (!ASN1Enc_SeqOfAny(enc, 0x80000003, &(val)->u.x400Address))
  5290. return 0;
  5291. break;
  5292. case 5:
  5293. if (!ASN1BEREncExplicitTag(enc, 0x80000004, &nLenOff0))
  5294. return 0;
  5295. if (!ASN1BEREncOpenType(enc, &(val)->u.directoryName))
  5296. return 0;
  5297. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  5298. return 0;
  5299. break;
  5300. case 6:
  5301. if (!ASN1Enc_SeqOfAny(enc, 0x80000005, &(val)->u.ediPartyName))
  5302. return 0;
  5303. break;
  5304. case 7:
  5305. if (!ASN1DEREncCharString(enc, 0x80000006, ((val)->u.uniformResourceLocator).length, ((val)->u.uniformResourceLocator).value))
  5306. return 0;
  5307. break;
  5308. case 8:
  5309. if (!ASN1DEREncOctetString(enc, 0x80000007, ((val)->u.iPAddress).length, ((val)->u.iPAddress).value))
  5310. return 0;
  5311. break;
  5312. case 9:
  5313. if (!ASN1BEREncEoid(enc, 0x80000008, &(val)->u.registeredID))
  5314. return 0;
  5315. break;
  5316. default:
  5317. /* impossible */
  5318. ASN1EncSetError(enc, ASN1_ERR_CHOICE);
  5319. return 0;
  5320. }
  5321. return 1;
  5322. }
  5323. static int ASN1CALL ASN1Dec_GeneralName(ASN1decoding_t dec, ASN1uint32_t tag, GeneralName *val)
  5324. {
  5325. ASN1uint32_t t;
  5326. ASN1decoding_t dd0;
  5327. ASN1octet_t *di0;
  5328. if (!ASN1BERDecPeekTag(dec, &t))
  5329. return 0;
  5330. switch (t) {
  5331. case 0x80000000:
  5332. (val)->choice = 1;
  5333. if (!ASN1Dec_OtherName(dec, 0x80000000, &(val)->u.otherName))
  5334. return 0;
  5335. break;
  5336. case 0x80000001:
  5337. (val)->choice = 2;
  5338. if (!ASN1BERDecCharString(dec, 0x80000001, &(val)->u.rfc822Name))
  5339. return 0;
  5340. break;
  5341. case 0x80000002:
  5342. (val)->choice = 3;
  5343. if (!ASN1BERDecCharString(dec, 0x80000002, &(val)->u.dNSName))
  5344. return 0;
  5345. break;
  5346. case 0x80000003:
  5347. (val)->choice = 4;
  5348. if (!ASN1Dec_SeqOfAny(dec, 0x80000003, &(val)->u.x400Address))
  5349. return 0;
  5350. break;
  5351. case 0x80000004:
  5352. (val)->choice = 5;
  5353. if (!ASN1BERDecExplicitTag(dec, 0x80000004, &dd0, &di0))
  5354. return 0;
  5355. if (!ASN1BERDecOpenType2(dd0, &(val)->u.directoryName))
  5356. return 0;
  5357. if (!ASN1BERDecEndOfContents(dec, dd0, di0))
  5358. return 0;
  5359. break;
  5360. case 0x80000005:
  5361. (val)->choice = 6;
  5362. if (!ASN1Dec_SeqOfAny(dec, 0x80000005, &(val)->u.ediPartyName))
  5363. return 0;
  5364. break;
  5365. case 0x80000006:
  5366. (val)->choice = 7;
  5367. if (!ASN1BERDecCharString(dec, 0x80000006, &(val)->u.uniformResourceLocator))
  5368. return 0;
  5369. break;
  5370. case 0x80000007:
  5371. (val)->choice = 8;
  5372. if (!ASN1BERDecOctetString2(dec, 0x80000007, &(val)->u.iPAddress))
  5373. return 0;
  5374. break;
  5375. case 0x80000008:
  5376. (val)->choice = 9;
  5377. if (!ASN1BERDecEoid(dec, 0x80000008, &(val)->u.registeredID))
  5378. return 0;
  5379. break;
  5380. default:
  5381. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  5382. return 0;
  5383. }
  5384. return 1;
  5385. }
  5386. static void ASN1CALL ASN1Free_GeneralName(GeneralName *val)
  5387. {
  5388. if (val) {
  5389. switch ((val)->choice) {
  5390. case 1:
  5391. ASN1Free_OtherName(&(val)->u.otherName);
  5392. break;
  5393. case 2:
  5394. ASN1charstring_free(&(val)->u.rfc822Name);
  5395. break;
  5396. case 3:
  5397. ASN1charstring_free(&(val)->u.dNSName);
  5398. break;
  5399. case 4:
  5400. ASN1Free_SeqOfAny(&(val)->u.x400Address);
  5401. break;
  5402. case 5:
  5403. break;
  5404. case 6:
  5405. ASN1Free_SeqOfAny(&(val)->u.ediPartyName);
  5406. break;
  5407. case 7:
  5408. ASN1charstring_free(&(val)->u.uniformResourceLocator);
  5409. break;
  5410. case 8:
  5411. break;
  5412. case 9:
  5413. ASN1BEREoid_free(&(val)->u.registeredID);
  5414. break;
  5415. }
  5416. }
  5417. }
  5418. static int ASN1CALL ASN1Enc_BasicConstraints(ASN1encoding_t enc, ASN1uint32_t tag, BasicConstraints *val)
  5419. {
  5420. ASN1uint32_t nLenOff;
  5421. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  5422. return 0;
  5423. if (!ASN1DEREncBitString(enc, 0x3, ((val)->subjectType).length, ((val)->subjectType).value))
  5424. return 0;
  5425. if ((val)->o[0] & 0x80) {
  5426. if (!ASN1BEREncS32(enc, 0x2, (val)->pathLenConstraint))
  5427. return 0;
  5428. }
  5429. if ((val)->o[0] & 0x40) {
  5430. if (!ASN1Enc_SubtreesConstraint(enc, 0, &(val)->subtreesConstraint))
  5431. return 0;
  5432. }
  5433. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  5434. return 0;
  5435. return 1;
  5436. }
  5437. static int ASN1CALL ASN1Dec_BasicConstraints(ASN1decoding_t dec, ASN1uint32_t tag, BasicConstraints *val)
  5438. {
  5439. ASN1decoding_t dd;
  5440. ASN1octet_t *di;
  5441. ASN1uint32_t t;
  5442. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  5443. return 0;
  5444. ZeroMemory((val)->o, 1);
  5445. if (!ASN1BERDecBitString2(dd, 0x3, &(val)->subjectType))
  5446. return 0;
  5447. ASN1BERDecPeekTag(dd, &t);
  5448. if (t == 0x2) {
  5449. (val)->o[0] |= 0x80;
  5450. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->pathLenConstraint))
  5451. return 0;
  5452. }
  5453. ASN1BERDecPeekTag(dd, &t);
  5454. if (t == 0x10) {
  5455. (val)->o[0] |= 0x40;
  5456. if (!ASN1Dec_SubtreesConstraint(dd, 0, &(val)->subtreesConstraint))
  5457. return 0;
  5458. }
  5459. if (!ASN1BERDecEndOfContents(dec, dd, di))
  5460. return 0;
  5461. return 1;
  5462. }
  5463. static void ASN1CALL ASN1Free_BasicConstraints(BasicConstraints *val)
  5464. {
  5465. if (val) {
  5466. if ((val)->o[0] & 0x40) {
  5467. ASN1Free_SubtreesConstraint(&(val)->subtreesConstraint);
  5468. }
  5469. }
  5470. }
  5471. static int ASN1CALL ASN1Enc_PolicyInformation(ASN1encoding_t enc, ASN1uint32_t tag, PolicyInformation *val)
  5472. {
  5473. ASN1uint32_t nLenOff;
  5474. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  5475. return 0;
  5476. if (!ASN1BEREncEoid(enc, 0x6, &(val)->policyIdentifier))
  5477. return 0;
  5478. if ((val)->o[0] & 0x80) {
  5479. if (!ASN1Enc_PolicyQualifiers(enc, 0, &(val)->policyQualifiers))
  5480. return 0;
  5481. }
  5482. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  5483. return 0;
  5484. return 1;
  5485. }
  5486. static int ASN1CALL ASN1Dec_PolicyInformation(ASN1decoding_t dec, ASN1uint32_t tag, PolicyInformation *val)
  5487. {
  5488. ASN1decoding_t dd;
  5489. ASN1octet_t *di;
  5490. ASN1uint32_t t;
  5491. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  5492. return 0;
  5493. ZeroMemory((val)->o, 1);
  5494. if (!ASN1BERDecEoid(dd, 0x6, &(val)->policyIdentifier))
  5495. return 0;
  5496. ASN1BERDecPeekTag(dd, &t);
  5497. if (t == 0x10) {
  5498. (val)->o[0] |= 0x80;
  5499. if (!ASN1Dec_PolicyQualifiers(dd, 0, &(val)->policyQualifiers))
  5500. return 0;
  5501. }
  5502. if (!ASN1BERDecEndOfContents(dec, dd, di))
  5503. return 0;
  5504. return 1;
  5505. }
  5506. static void ASN1CALL ASN1Free_PolicyInformation(PolicyInformation *val)
  5507. {
  5508. if (val) {
  5509. ASN1BEREoid_free(&(val)->policyIdentifier);
  5510. if ((val)->o[0] & 0x80) {
  5511. ASN1Free_PolicyQualifiers(&(val)->policyQualifiers);
  5512. }
  5513. }
  5514. }
  5515. static int ASN1CALL ASN1Enc_UserNotice(ASN1encoding_t enc, ASN1uint32_t tag, UserNotice *val)
  5516. {
  5517. ASN1uint32_t nLenOff;
  5518. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  5519. return 0;
  5520. if ((val)->o[0] & 0x80) {
  5521. if (!ASN1Enc_NoticeReference(enc, 0, &(val)->noticeRef))
  5522. return 0;
  5523. }
  5524. if ((val)->o[0] & 0x40) {
  5525. if (!ASN1Enc_DisplayText(enc, 0, &(val)->explicitText))
  5526. return 0;
  5527. }
  5528. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  5529. return 0;
  5530. return 1;
  5531. }
  5532. static int ASN1CALL ASN1Dec_UserNotice(ASN1decoding_t dec, ASN1uint32_t tag, UserNotice *val)
  5533. {
  5534. ASN1decoding_t dd;
  5535. ASN1octet_t *di;
  5536. ASN1uint32_t t;
  5537. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  5538. return 0;
  5539. ZeroMemory((val)->o, 1);
  5540. ASN1BERDecPeekTag(dd, &t);
  5541. if (t == 0x10) {
  5542. (val)->o[0] |= 0x80;
  5543. if (!ASN1Dec_NoticeReference(dd, 0, &(val)->noticeRef))
  5544. return 0;
  5545. }
  5546. ASN1BERDecPeekTag(dd, &t);
  5547. if (t == 0x1a || t == 0x1e) {
  5548. (val)->o[0] |= 0x40;
  5549. if (!ASN1Dec_DisplayText(dd, 0, &(val)->explicitText))
  5550. return 0;
  5551. }
  5552. if (!ASN1BERDecEndOfContents(dec, dd, di))
  5553. return 0;
  5554. return 1;
  5555. }
  5556. static void ASN1CALL ASN1Free_UserNotice(UserNotice *val)
  5557. {
  5558. if (val) {
  5559. if ((val)->o[0] & 0x80) {
  5560. ASN1Free_NoticeReference(&(val)->noticeRef);
  5561. }
  5562. if ((val)->o[0] & 0x40) {
  5563. ASN1Free_DisplayText(&(val)->explicitText);
  5564. }
  5565. }
  5566. }
  5567. static int ASN1CALL ASN1Enc_VerisignQualifier1(ASN1encoding_t enc, ASN1uint32_t tag, VerisignQualifier1 *val)
  5568. {
  5569. ASN1uint32_t nLenOff;
  5570. ASN1uint32_t t;
  5571. ASN1uint32_t nLenOff0;
  5572. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  5573. return 0;
  5574. if ((val)->o[0] & 0x80) {
  5575. t = lstrlenA((val)->practicesReference);
  5576. if (!ASN1DEREncCharString(enc, 0x16, t, (val)->practicesReference))
  5577. return 0;
  5578. }
  5579. if ((val)->o[0] & 0x40) {
  5580. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  5581. return 0;
  5582. if (!ASN1BEREncEoid(enc, 0x6, &(val)->noticeId))
  5583. return 0;
  5584. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  5585. return 0;
  5586. }
  5587. if ((val)->o[0] & 0x20) {
  5588. if (!ASN1BEREncExplicitTag(enc, 0x80000001, &nLenOff0))
  5589. return 0;
  5590. if (!ASN1BEREncEoid(enc, 0x6, &(val)->nsiNoticeId))
  5591. return 0;
  5592. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  5593. return 0;
  5594. }
  5595. if ((val)->o[0] & 0x10) {
  5596. if (!ASN1Enc_CpsURLs(enc, 0, &(val)->cpsURLs))
  5597. return 0;
  5598. }
  5599. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  5600. return 0;
  5601. return 1;
  5602. }
  5603. static int ASN1CALL ASN1Dec_VerisignQualifier1(ASN1decoding_t dec, ASN1uint32_t tag, VerisignQualifier1 *val)
  5604. {
  5605. ASN1decoding_t dd;
  5606. ASN1octet_t *di;
  5607. ASN1uint32_t t;
  5608. ASN1decoding_t dd0;
  5609. ASN1octet_t *di0;
  5610. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  5611. return 0;
  5612. ZeroMemory((val)->o, 1);
  5613. ASN1BERDecPeekTag(dd, &t);
  5614. if (t == 0x16) {
  5615. (val)->o[0] |= 0x80;
  5616. if (!ASN1BERDecZeroCharString(dd, 0x16, &(val)->practicesReference))
  5617. return 0;
  5618. }
  5619. ASN1BERDecPeekTag(dd, &t);
  5620. if (t == 0x80000000) {
  5621. (val)->o[0] |= 0x40;
  5622. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  5623. return 0;
  5624. if (!ASN1BERDecEoid(dd0, 0x6, &(val)->noticeId))
  5625. return 0;
  5626. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  5627. return 0;
  5628. }
  5629. ASN1BERDecPeekTag(dd, &t);
  5630. if (t == 0x80000001) {
  5631. (val)->o[0] |= 0x20;
  5632. if (!ASN1BERDecExplicitTag(dd, 0x80000001, &dd0, &di0))
  5633. return 0;
  5634. if (!ASN1BERDecEoid(dd0, 0x6, &(val)->nsiNoticeId))
  5635. return 0;
  5636. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  5637. return 0;
  5638. }
  5639. ASN1BERDecPeekTag(dd, &t);
  5640. if (t == 0x10) {
  5641. (val)->o[0] |= 0x10;
  5642. if (!ASN1Dec_CpsURLs(dd, 0, &(val)->cpsURLs))
  5643. return 0;
  5644. }
  5645. if (!ASN1BERDecEndOfContents(dec, dd, di))
  5646. return 0;
  5647. return 1;
  5648. }
  5649. static void ASN1CALL ASN1Free_VerisignQualifier1(VerisignQualifier1 *val)
  5650. {
  5651. if (val) {
  5652. if ((val)->o[0] & 0x80) {
  5653. ASN1ztcharstring_free((val)->practicesReference);
  5654. }
  5655. if ((val)->o[0] & 0x40) {
  5656. ASN1BEREoid_free(&(val)->noticeId);
  5657. }
  5658. if ((val)->o[0] & 0x20) {
  5659. ASN1BEREoid_free(&(val)->nsiNoticeId);
  5660. }
  5661. if ((val)->o[0] & 0x10) {
  5662. ASN1Free_CpsURLs(&(val)->cpsURLs);
  5663. }
  5664. }
  5665. }
  5666. static int ASN1CALL ASN1Enc_AccessDescription(ASN1encoding_t enc, ASN1uint32_t tag, AccessDescription *val)
  5667. {
  5668. ASN1uint32_t nLenOff;
  5669. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  5670. return 0;
  5671. if (!ASN1BEREncEoid(enc, 0x6, &(val)->accessMethod))
  5672. return 0;
  5673. if (!ASN1Enc_GeneralName(enc, 0, &(val)->accessLocation))
  5674. return 0;
  5675. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  5676. return 0;
  5677. return 1;
  5678. }
  5679. static int ASN1CALL ASN1Dec_AccessDescription(ASN1decoding_t dec, ASN1uint32_t tag, AccessDescription *val)
  5680. {
  5681. ASN1decoding_t dd;
  5682. ASN1octet_t *di;
  5683. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  5684. return 0;
  5685. if (!ASN1BERDecEoid(dd, 0x6, &(val)->accessMethod))
  5686. return 0;
  5687. if (!ASN1Dec_GeneralName(dd, 0, &(val)->accessLocation))
  5688. return 0;
  5689. if (!ASN1BERDecEndOfContents(dec, dd, di))
  5690. return 0;
  5691. return 1;
  5692. }
  5693. static void ASN1CALL ASN1Free_AccessDescription(AccessDescription *val)
  5694. {
  5695. if (val) {
  5696. ASN1BEREoid_free(&(val)->accessMethod);
  5697. ASN1Free_GeneralName(&(val)->accessLocation);
  5698. }
  5699. }
  5700. static int ASN1CALL ASN1Enc_DistributionPoint(ASN1encoding_t enc, ASN1uint32_t tag, DistributionPoint *val)
  5701. {
  5702. ASN1uint32_t nLenOff;
  5703. ASN1uint32_t nLenOff0;
  5704. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  5705. return 0;
  5706. if ((val)->o[0] & 0x80) {
  5707. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  5708. return 0;
  5709. if (!ASN1Enc_DistributionPointName(enc, 0, &(val)->distributionPoint))
  5710. return 0;
  5711. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  5712. return 0;
  5713. }
  5714. if ((val)->o[0] & 0x40) {
  5715. if (!ASN1DEREncBitString(enc, 0x80000001, ((val)->reasons).length, ((val)->reasons).value))
  5716. return 0;
  5717. }
  5718. if ((val)->o[0] & 0x20) {
  5719. if (!ASN1Enc_GeneralNames(enc, 0x80000002, &(val)->cRLIssuer))
  5720. return 0;
  5721. }
  5722. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  5723. return 0;
  5724. return 1;
  5725. }
  5726. static int ASN1CALL ASN1Dec_DistributionPoint(ASN1decoding_t dec, ASN1uint32_t tag, DistributionPoint *val)
  5727. {
  5728. ASN1decoding_t dd;
  5729. ASN1octet_t *di;
  5730. ASN1uint32_t t;
  5731. ASN1decoding_t dd0;
  5732. ASN1octet_t *di0;
  5733. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  5734. return 0;
  5735. ZeroMemory((val)->o, 1);
  5736. ASN1BERDecPeekTag(dd, &t);
  5737. if (t == 0x80000000) {
  5738. (val)->o[0] |= 0x80;
  5739. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  5740. return 0;
  5741. if (!ASN1Dec_DistributionPointName(dd0, 0, &(val)->distributionPoint))
  5742. return 0;
  5743. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  5744. return 0;
  5745. }
  5746. ASN1BERDecPeekTag(dd, &t);
  5747. if (t == 0x80000001) {
  5748. (val)->o[0] |= 0x40;
  5749. if (!ASN1BERDecBitString2(dd, 0x80000001, &(val)->reasons))
  5750. return 0;
  5751. }
  5752. ASN1BERDecPeekTag(dd, &t);
  5753. if (t == 0x80000002) {
  5754. (val)->o[0] |= 0x20;
  5755. if (!ASN1Dec_GeneralNames(dd, 0x80000002, &(val)->cRLIssuer))
  5756. return 0;
  5757. }
  5758. if (!ASN1BERDecEndOfContents(dec, dd, di))
  5759. return 0;
  5760. return 1;
  5761. }
  5762. static void ASN1CALL ASN1Free_DistributionPoint(DistributionPoint *val)
  5763. {
  5764. if (val) {
  5765. if ((val)->o[0] & 0x80) {
  5766. ASN1Free_DistributionPointName(&(val)->distributionPoint);
  5767. }
  5768. if ((val)->o[0] & 0x40) {
  5769. }
  5770. if ((val)->o[0] & 0x20) {
  5771. ASN1Free_GeneralNames(&(val)->cRLIssuer);
  5772. }
  5773. }
  5774. }
  5775. static int ASN1CALL ASN1Enc_ContentInfoSeqOfAny(ASN1encoding_t enc, ASN1uint32_t tag, ContentInfoSeqOfAny *val)
  5776. {
  5777. ASN1uint32_t nLenOff;
  5778. ASN1uint32_t nLenOff0;
  5779. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  5780. return 0;
  5781. if (!ASN1BEREncEoid(enc, 0x6, &(val)->contentType))
  5782. return 0;
  5783. if ((val)->o[0] & 0x80) {
  5784. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  5785. return 0;
  5786. if (!ASN1Enc_SeqOfAny(enc, 0, &(val)->contentSeqOfAny))
  5787. return 0;
  5788. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  5789. return 0;
  5790. }
  5791. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  5792. return 0;
  5793. return 1;
  5794. }
  5795. static int ASN1CALL ASN1Dec_ContentInfoSeqOfAny(ASN1decoding_t dec, ASN1uint32_t tag, ContentInfoSeqOfAny *val)
  5796. {
  5797. ASN1decoding_t dd;
  5798. ASN1octet_t *di;
  5799. ASN1uint32_t t;
  5800. ASN1decoding_t dd0;
  5801. ASN1octet_t *di0;
  5802. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  5803. return 0;
  5804. ZeroMemory((val)->o, 1);
  5805. if (!ASN1BERDecEoid(dd, 0x6, &(val)->contentType))
  5806. return 0;
  5807. ASN1BERDecPeekTag(dd, &t);
  5808. if (t == 0x80000000) {
  5809. (val)->o[0] |= 0x80;
  5810. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  5811. return 0;
  5812. if (!ASN1Dec_SeqOfAny(dd0, 0, &(val)->contentSeqOfAny))
  5813. return 0;
  5814. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  5815. return 0;
  5816. }
  5817. if (!ASN1BERDecEndOfContents(dec, dd, di))
  5818. return 0;
  5819. return 1;
  5820. }
  5821. static void ASN1CALL ASN1Free_ContentInfoSeqOfAny(ContentInfoSeqOfAny *val)
  5822. {
  5823. if (val) {
  5824. ASN1BEREoid_free(&(val)->contentType);
  5825. if ((val)->o[0] & 0x80) {
  5826. ASN1Free_SeqOfAny(&(val)->contentSeqOfAny);
  5827. }
  5828. }
  5829. }
  5830. static int ASN1CALL ASN1Enc_CertificateTrustList(ASN1encoding_t enc, ASN1uint32_t tag, CertificateTrustList *val)
  5831. {
  5832. ASN1uint32_t nLenOff;
  5833. ASN1octet_t o[1];
  5834. ASN1uint32_t nLenOff0;
  5835. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  5836. return 0;
  5837. CopyMemory(o, (val)->o, 1);
  5838. if ((val)->version == 0)
  5839. o[0] &= ~0x80;
  5840. if (o[0] & 0x80) {
  5841. if (!ASN1BEREncS32(enc, 0x2, (val)->version))
  5842. return 0;
  5843. }
  5844. if (!ASN1Enc_SubjectUsage(enc, 0, &(val)->subjectUsage))
  5845. return 0;
  5846. if (o[0] & 0x40) {
  5847. if (!ASN1DEREncOctetString(enc, 0x4, ((val)->listIdentifier).length, ((val)->listIdentifier).value))
  5848. return 0;
  5849. }
  5850. if (o[0] & 0x20) {
  5851. if (!ASN1BEREncSX(enc, 0x2, &(val)->sequenceNumber))
  5852. return 0;
  5853. }
  5854. if (!ASN1Enc_ChoiceOfTime(enc, 0, &(val)->ctlThisUpdate))
  5855. return 0;
  5856. if (o[0] & 0x10) {
  5857. if (!ASN1Enc_ChoiceOfTime(enc, 0, &(val)->ctlNextUpdate))
  5858. return 0;
  5859. }
  5860. if (!ASN1Enc_AlgorithmIdentifier(enc, 0, &(val)->subjectAlgorithm))
  5861. return 0;
  5862. if (o[0] & 0x8) {
  5863. if (!ASN1Enc_TrustedSubjects(enc, 0, &(val)->trustedSubjects))
  5864. return 0;
  5865. }
  5866. if (o[0] & 0x4) {
  5867. if (!ASN1BEREncExplicitTag(enc, 0x80000000, &nLenOff0))
  5868. return 0;
  5869. if (!ASN1Enc_Extensions(enc, 0, &(val)->ctlExtensions))
  5870. return 0;
  5871. if (!ASN1BEREncEndOfContents(enc, nLenOff0))
  5872. return 0;
  5873. }
  5874. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  5875. return 0;
  5876. return 1;
  5877. }
  5878. static int ASN1CALL ASN1Dec_CertificateTrustList(ASN1decoding_t dec, ASN1uint32_t tag, CertificateTrustList *val)
  5879. {
  5880. ASN1decoding_t dd;
  5881. ASN1octet_t *di;
  5882. ASN1uint32_t t;
  5883. ASN1decoding_t dd0;
  5884. ASN1octet_t *di0;
  5885. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  5886. return 0;
  5887. ZeroMemory((val)->o, 1);
  5888. ASN1BERDecPeekTag(dd, &t);
  5889. if (t == 0x2) {
  5890. (val)->o[0] |= 0x80;
  5891. if (!ASN1BERDecS32Val(dd, 0x2, &(val)->version))
  5892. return 0;
  5893. }
  5894. if (!ASN1Dec_SubjectUsage(dd, 0, &(val)->subjectUsage))
  5895. return 0;
  5896. ASN1BERDecPeekTag(dd, &t);
  5897. if (t == 0x4) {
  5898. (val)->o[0] |= 0x40;
  5899. if (!ASN1BERDecOctetString2(dd, 0x4, &(val)->listIdentifier))
  5900. return 0;
  5901. }
  5902. ASN1BERDecPeekTag(dd, &t);
  5903. if (t == 0x2) {
  5904. (val)->o[0] |= 0x20;
  5905. if (!ASN1BERDecSXVal(dd, 0x2, &(val)->sequenceNumber))
  5906. return 0;
  5907. }
  5908. if (!ASN1Dec_ChoiceOfTime(dd, 0, &(val)->ctlThisUpdate))
  5909. return 0;
  5910. ASN1BERDecPeekTag(dd, &t);
  5911. if (t == 0x17 || t == 0x18) {
  5912. (val)->o[0] |= 0x10;
  5913. if (!ASN1Dec_ChoiceOfTime(dd, 0, &(val)->ctlNextUpdate))
  5914. return 0;
  5915. }
  5916. if (!ASN1Dec_AlgorithmIdentifier(dd, 0, &(val)->subjectAlgorithm))
  5917. return 0;
  5918. ASN1BERDecPeekTag(dd, &t);
  5919. if (t == 0x10) {
  5920. (val)->o[0] |= 0x8;
  5921. if (!ASN1Dec_TrustedSubjects(dd, 0, &(val)->trustedSubjects))
  5922. return 0;
  5923. }
  5924. ASN1BERDecPeekTag(dd, &t);
  5925. if (t == 0x80000000) {
  5926. (val)->o[0] |= 0x4;
  5927. if (!ASN1BERDecExplicitTag(dd, 0x80000000, &dd0, &di0))
  5928. return 0;
  5929. if (!ASN1Dec_Extensions(dd0, 0, &(val)->ctlExtensions))
  5930. return 0;
  5931. if (!ASN1BERDecEndOfContents(dd, dd0, di0))
  5932. return 0;
  5933. }
  5934. if (!((val)->o[0] & 0x80))
  5935. (val)->version = 0;
  5936. if (!ASN1BERDecEndOfContents(dec, dd, di))
  5937. return 0;
  5938. return 1;
  5939. }
  5940. static void ASN1CALL ASN1Free_CertificateTrustList(CertificateTrustList *val)
  5941. {
  5942. if (val) {
  5943. ASN1Free_SubjectUsage(&(val)->subjectUsage);
  5944. if ((val)->o[0] & 0x40) {
  5945. }
  5946. if ((val)->o[0] & 0x20) {
  5947. ASN1intx_free(&(val)->sequenceNumber);
  5948. }
  5949. ASN1Free_ChoiceOfTime(&(val)->ctlThisUpdate);
  5950. if ((val)->o[0] & 0x10) {
  5951. ASN1Free_ChoiceOfTime(&(val)->ctlNextUpdate);
  5952. }
  5953. ASN1Free_AlgorithmIdentifier(&(val)->subjectAlgorithm);
  5954. if ((val)->o[0] & 0x8) {
  5955. ASN1Free_TrustedSubjects(&(val)->trustedSubjects);
  5956. }
  5957. if ((val)->o[0] & 0x4) {
  5958. ASN1Free_Extensions(&(val)->ctlExtensions);
  5959. }
  5960. }
  5961. }
  5962. static int ASN1CALL ASN1Enc_NameConstraints(ASN1encoding_t enc, ASN1uint32_t tag, NameConstraints *val)
  5963. {
  5964. ASN1uint32_t nLenOff;
  5965. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  5966. return 0;
  5967. if ((val)->o[0] & 0x80) {
  5968. if (!ASN1Enc_GeneralSubtrees(enc, 0x80000000, &(val)->permittedSubtrees))
  5969. return 0;
  5970. }
  5971. if ((val)->o[0] & 0x40) {
  5972. if (!ASN1Enc_GeneralSubtrees(enc, 0x80000001, &(val)->excludedSubtrees))
  5973. return 0;
  5974. }
  5975. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  5976. return 0;
  5977. return 1;
  5978. }
  5979. static int ASN1CALL ASN1Dec_NameConstraints(ASN1decoding_t dec, ASN1uint32_t tag, NameConstraints *val)
  5980. {
  5981. ASN1decoding_t dd;
  5982. ASN1octet_t *di;
  5983. ASN1uint32_t t;
  5984. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  5985. return 0;
  5986. ZeroMemory((val)->o, 1);
  5987. ASN1BERDecPeekTag(dd, &t);
  5988. if (t == 0x80000000) {
  5989. (val)->o[0] |= 0x80;
  5990. if (!ASN1Dec_GeneralSubtrees(dd, 0x80000000, &(val)->permittedSubtrees))
  5991. return 0;
  5992. }
  5993. ASN1BERDecPeekTag(dd, &t);
  5994. if (t == 0x80000001) {
  5995. (val)->o[0] |= 0x40;
  5996. if (!ASN1Dec_GeneralSubtrees(dd, 0x80000001, &(val)->excludedSubtrees))
  5997. return 0;
  5998. }
  5999. if (!ASN1BERDecEndOfContents(dec, dd, di))
  6000. return 0;
  6001. return 1;
  6002. }
  6003. static void ASN1CALL ASN1Free_NameConstraints(NameConstraints *val)
  6004. {
  6005. if (val) {
  6006. if ((val)->o[0] & 0x80) {
  6007. ASN1Free_GeneralSubtrees(&(val)->permittedSubtrees);
  6008. }
  6009. if ((val)->o[0] & 0x40) {
  6010. ASN1Free_GeneralSubtrees(&(val)->excludedSubtrees);
  6011. }
  6012. }
  6013. }
  6014. static int ASN1CALL ASN1Enc_GeneralSubtree(ASN1encoding_t enc, ASN1uint32_t tag, GeneralSubtree *val)
  6015. {
  6016. ASN1uint32_t nLenOff;
  6017. ASN1octet_t o[1];
  6018. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  6019. return 0;
  6020. CopyMemory(o, (val)->o, 1);
  6021. if ((val)->minimum == 0)
  6022. o[0] &= ~0x80;
  6023. if (!ASN1Enc_GeneralName(enc, 0, &(val)->base))
  6024. return 0;
  6025. if (o[0] & 0x80) {
  6026. if (!ASN1BEREncU32(enc, 0x80000000, (val)->minimum))
  6027. return 0;
  6028. }
  6029. if (o[0] & 0x40) {
  6030. if (!ASN1BEREncU32(enc, 0x80000001, (val)->maximum))
  6031. return 0;
  6032. }
  6033. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  6034. return 0;
  6035. return 1;
  6036. }
  6037. static int ASN1CALL ASN1Dec_GeneralSubtree(ASN1decoding_t dec, ASN1uint32_t tag, GeneralSubtree *val)
  6038. {
  6039. ASN1decoding_t dd;
  6040. ASN1octet_t *di;
  6041. ASN1uint32_t t;
  6042. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  6043. return 0;
  6044. ZeroMemory((val)->o, 1);
  6045. if (!ASN1Dec_GeneralName(dd, 0, &(val)->base))
  6046. return 0;
  6047. ASN1BERDecPeekTag(dd, &t);
  6048. if (t == 0x80000000) {
  6049. (val)->o[0] |= 0x80;
  6050. if (!ASN1BERDecU32Val(dd, 0x80000000, (ASN1uint32_t *) &(val)->minimum))
  6051. return 0;
  6052. }
  6053. ASN1BERDecPeekTag(dd, &t);
  6054. if (t == 0x80000001) {
  6055. (val)->o[0] |= 0x40;
  6056. if (!ASN1BERDecU32Val(dd, 0x80000001, (ASN1uint32_t *) &(val)->maximum))
  6057. return 0;
  6058. }
  6059. if (!((val)->o[0] & 0x80))
  6060. (val)->minimum = 0;
  6061. if (!ASN1BERDecEndOfContents(dec, dd, di))
  6062. return 0;
  6063. return 1;
  6064. }
  6065. static void ASN1CALL ASN1Free_GeneralSubtree(GeneralSubtree *val)
  6066. {
  6067. if (val) {
  6068. ASN1Free_GeneralName(&(val)->base);
  6069. }
  6070. }
  6071. static int ASN1CALL ASN1Enc_CrossCertDistPoints(ASN1encoding_t enc, ASN1uint32_t tag, CrossCertDistPoints *val)
  6072. {
  6073. ASN1uint32_t nLenOff;
  6074. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  6075. return 0;
  6076. if ((val)->o[0] & 0x80) {
  6077. if (!ASN1BEREncU32(enc, 0x2, (val)->syncDeltaTime))
  6078. return 0;
  6079. }
  6080. if (!ASN1Enc_CrossCertDistPointNames(enc, 0, &(val)->crossCertDistPointNames))
  6081. return 0;
  6082. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  6083. return 0;
  6084. return 1;
  6085. }
  6086. static int ASN1CALL ASN1Dec_CrossCertDistPoints(ASN1decoding_t dec, ASN1uint32_t tag, CrossCertDistPoints *val)
  6087. {
  6088. ASN1decoding_t dd;
  6089. ASN1octet_t *di;
  6090. ASN1uint32_t t;
  6091. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  6092. return 0;
  6093. ZeroMemory((val)->o, 1);
  6094. ASN1BERDecPeekTag(dd, &t);
  6095. if (t == 0x2) {
  6096. (val)->o[0] |= 0x80;
  6097. if (!ASN1BERDecU32Val(dd, 0x2, (ASN1uint32_t *) &(val)->syncDeltaTime))
  6098. return 0;
  6099. }
  6100. if (!ASN1Dec_CrossCertDistPointNames(dd, 0, &(val)->crossCertDistPointNames))
  6101. return 0;
  6102. if (!ASN1BERDecEndOfContents(dec, dd, di))
  6103. return 0;
  6104. return 1;
  6105. }
  6106. static void ASN1CALL ASN1Free_CrossCertDistPoints(CrossCertDistPoints *val)
  6107. {
  6108. if (val) {
  6109. ASN1Free_CrossCertDistPointNames(&(val)->crossCertDistPointNames);
  6110. }
  6111. }
  6112. static int ASN1CALL ASN1Enc_CmcData(ASN1encoding_t enc, ASN1uint32_t tag, CmcData *val)
  6113. {
  6114. ASN1uint32_t nLenOff;
  6115. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  6116. return 0;
  6117. if (!ASN1Enc_ControlSequence(enc, 0, &(val)->controlSequence))
  6118. return 0;
  6119. if (!ASN1Enc_ReqSequence(enc, 0, &(val)->reqSequence))
  6120. return 0;
  6121. if (!ASN1Enc_CmsSequence(enc, 0, &(val)->cmsSequence))
  6122. return 0;
  6123. if (!ASN1Enc_OtherMsgSequence(enc, 0, &(val)->otherMsgSequence))
  6124. return 0;
  6125. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  6126. return 0;
  6127. return 1;
  6128. }
  6129. static int ASN1CALL ASN1Dec_CmcData(ASN1decoding_t dec, ASN1uint32_t tag, CmcData *val)
  6130. {
  6131. ASN1decoding_t dd;
  6132. ASN1octet_t *di;
  6133. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  6134. return 0;
  6135. if (!ASN1Dec_ControlSequence(dd, 0, &(val)->controlSequence))
  6136. return 0;
  6137. if (!ASN1Dec_ReqSequence(dd, 0, &(val)->reqSequence))
  6138. return 0;
  6139. if (!ASN1Dec_CmsSequence(dd, 0, &(val)->cmsSequence))
  6140. return 0;
  6141. if (!ASN1Dec_OtherMsgSequence(dd, 0, &(val)->otherMsgSequence))
  6142. return 0;
  6143. if (!ASN1BERDecEndOfContents(dec, dd, di))
  6144. return 0;
  6145. return 1;
  6146. }
  6147. static void ASN1CALL ASN1Free_CmcData(CmcData *val)
  6148. {
  6149. if (val) {
  6150. ASN1Free_ControlSequence(&(val)->controlSequence);
  6151. ASN1Free_ReqSequence(&(val)->reqSequence);
  6152. ASN1Free_CmsSequence(&(val)->cmsSequence);
  6153. ASN1Free_OtherMsgSequence(&(val)->otherMsgSequence);
  6154. }
  6155. }
  6156. static int ASN1CALL ASN1Enc_CmcResponseBody(ASN1encoding_t enc, ASN1uint32_t tag, CmcResponseBody *val)
  6157. {
  6158. ASN1uint32_t nLenOff;
  6159. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  6160. return 0;
  6161. if (!ASN1Enc_ControlSequence(enc, 0, &(val)->controlSequence))
  6162. return 0;
  6163. if (!ASN1Enc_CmsSequence(enc, 0, &(val)->cmsSequence))
  6164. return 0;
  6165. if (!ASN1Enc_OtherMsgSequence(enc, 0, &(val)->otherMsgSequence))
  6166. return 0;
  6167. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  6168. return 0;
  6169. return 1;
  6170. }
  6171. static int ASN1CALL ASN1Dec_CmcResponseBody(ASN1decoding_t dec, ASN1uint32_t tag, CmcResponseBody *val)
  6172. {
  6173. ASN1decoding_t dd;
  6174. ASN1octet_t *di;
  6175. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  6176. return 0;
  6177. if (!ASN1Dec_ControlSequence(dd, 0, &(val)->controlSequence))
  6178. return 0;
  6179. if (!ASN1Dec_CmsSequence(dd, 0, &(val)->cmsSequence))
  6180. return 0;
  6181. if (!ASN1Dec_OtherMsgSequence(dd, 0, &(val)->otherMsgSequence))
  6182. return 0;
  6183. if (!ASN1BERDecEndOfContents(dec, dd, di))
  6184. return 0;
  6185. return 1;
  6186. }
  6187. static void ASN1CALL ASN1Free_CmcResponseBody(CmcResponseBody *val)
  6188. {
  6189. if (val) {
  6190. ASN1Free_ControlSequence(&(val)->controlSequence);
  6191. ASN1Free_CmsSequence(&(val)->cmsSequence);
  6192. ASN1Free_OtherMsgSequence(&(val)->otherMsgSequence);
  6193. }
  6194. }
  6195. static int ASN1CALL ASN1Enc_TaggedRequest(ASN1encoding_t enc, ASN1uint32_t tag, TaggedRequest *val)
  6196. {
  6197. switch ((val)->choice) {
  6198. case 1:
  6199. if (!ASN1Enc_TaggedCertificationRequest(enc, 0x80000000, &(val)->u.tcr))
  6200. return 0;
  6201. break;
  6202. default:
  6203. /* impossible */
  6204. ASN1EncSetError(enc, ASN1_ERR_CHOICE);
  6205. return 0;
  6206. }
  6207. return 1;
  6208. }
  6209. static int ASN1CALL ASN1Dec_TaggedRequest(ASN1decoding_t dec, ASN1uint32_t tag, TaggedRequest *val)
  6210. {
  6211. ASN1uint32_t t;
  6212. if (!ASN1BERDecPeekTag(dec, &t))
  6213. return 0;
  6214. switch (t) {
  6215. case 0x80000000:
  6216. (val)->choice = 1;
  6217. if (!ASN1Dec_TaggedCertificationRequest(dec, 0x80000000, &(val)->u.tcr))
  6218. return 0;
  6219. break;
  6220. default:
  6221. ASN1DecSetError(dec, ASN1_ERR_CORRUPT);
  6222. return 0;
  6223. }
  6224. return 1;
  6225. }
  6226. static void ASN1CALL ASN1Free_TaggedRequest(TaggedRequest *val)
  6227. {
  6228. if (val) {
  6229. switch ((val)->choice) {
  6230. case 1:
  6231. ASN1Free_TaggedCertificationRequest(&(val)->u.tcr);
  6232. break;
  6233. }
  6234. }
  6235. }
  6236. static int ASN1CALL ASN1Enc_CmcStatusInfo(ASN1encoding_t enc, ASN1uint32_t tag, CmcStatusInfo *val)
  6237. {
  6238. ASN1uint32_t nLenOff;
  6239. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  6240. return 0;
  6241. if (!ASN1BEREncU32(enc, 0x2, (val)->cmcStatus))
  6242. return 0;
  6243. if (!ASN1Enc_BodyPartIDSequence(enc, 0, &(val)->bodyList))
  6244. return 0;
  6245. if ((val)->o[0] & 0x80) {
  6246. if (!ASN1DEREncUTF8String(enc, 0xc, ((val)->statusString).length, ((val)->statusString).value))
  6247. return 0;
  6248. }
  6249. if ((val)->o[0] & 0x40) {
  6250. if (!ASN1Enc_CmcStatusInfo_otherInfo(enc, 0, &(val)->otherInfo))
  6251. return 0;
  6252. }
  6253. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  6254. return 0;
  6255. return 1;
  6256. }
  6257. static int ASN1CALL ASN1Dec_CmcStatusInfo(ASN1decoding_t dec, ASN1uint32_t tag, CmcStatusInfo *val)
  6258. {
  6259. ASN1decoding_t dd;
  6260. ASN1octet_t *di;
  6261. ASN1uint32_t t;
  6262. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  6263. return 0;
  6264. ZeroMemory((val)->o, 1);
  6265. if (!ASN1BERDecU32Val(dd, 0x2, (ASN1uint32_t *) &(val)->cmcStatus))
  6266. return 0;
  6267. if (!ASN1Dec_BodyPartIDSequence(dd, 0, &(val)->bodyList))
  6268. return 0;
  6269. ASN1BERDecPeekTag(dd, &t);
  6270. if (t == 0xc) {
  6271. (val)->o[0] |= 0x80;
  6272. if (!ASN1BERDecUTF8String(dd, 0xc, &(val)->statusString))
  6273. return 0;
  6274. }
  6275. ASN1BERDecPeekTag(dd, &t);
  6276. if (t == 0x2 || t == 0x10) {
  6277. (val)->o[0] |= 0x40;
  6278. if (!ASN1Dec_CmcStatusInfo_otherInfo(dd, 0, &(val)->otherInfo))
  6279. return 0;
  6280. }
  6281. if (!ASN1BERDecEndOfContents(dec, dd, di))
  6282. return 0;
  6283. return 1;
  6284. }
  6285. static void ASN1CALL ASN1Free_CmcStatusInfo(CmcStatusInfo *val)
  6286. {
  6287. if (val) {
  6288. ASN1Free_BodyPartIDSequence(&(val)->bodyList);
  6289. if ((val)->o[0] & 0x80) {
  6290. ASN1utf8string_free(&(val)->statusString);
  6291. }
  6292. if ((val)->o[0] & 0x40) {
  6293. ASN1Free_CmcStatusInfo_otherInfo(&(val)->otherInfo);
  6294. }
  6295. }
  6296. }