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.

196 lines
7.0 KiB

  1. /* Copyright (C) Microsoft Corporation, 1996 - 1999 All rights reserved. */
  2. /* ASN.1 definitions for SET X509 v3 certificates */
  3. #include <windows.h>
  4. #include "x509.h"
  5. ASN1module_t X509_Module = NULL;
  6. static int ASN1CALL ASN1Enc_SETAccountAlias(ASN1encoding_t enc, ASN1uint32_t tag, SETAccountAlias *val);
  7. static int ASN1CALL ASN1Enc_SETHashedRootKey(ASN1encoding_t enc, ASN1uint32_t tag, SETHashedRootKey *val);
  8. static int ASN1CALL ASN1Enc_SETCertificateType(ASN1encoding_t enc, ASN1uint32_t tag, SETCertificateType *val);
  9. static int ASN1CALL ASN1Enc_SETMerchantData(ASN1encoding_t enc, ASN1uint32_t tag, SETMerchantData *val);
  10. static int ASN1CALL ASN1Dec_SETAccountAlias(ASN1decoding_t dec, ASN1uint32_t tag, SETAccountAlias *val);
  11. static int ASN1CALL ASN1Dec_SETHashedRootKey(ASN1decoding_t dec, ASN1uint32_t tag, SETHashedRootKey *val);
  12. static int ASN1CALL ASN1Dec_SETCertificateType(ASN1decoding_t dec, ASN1uint32_t tag, SETCertificateType *val);
  13. static int ASN1CALL ASN1Dec_SETMerchantData(ASN1decoding_t dec, ASN1uint32_t tag, SETMerchantData *val);
  14. static void ASN1CALL ASN1Free_SETHashedRootKey(SETHashedRootKey *val);
  15. static void ASN1CALL ASN1Free_SETCertificateType(SETCertificateType *val);
  16. static void ASN1CALL ASN1Free_SETMerchantData(SETMerchantData *val);
  17. typedef ASN1BerEncFun_t ASN1EncFun_t;
  18. static const ASN1EncFun_t encfntab[4] = {
  19. (ASN1EncFun_t) ASN1Enc_SETAccountAlias,
  20. (ASN1EncFun_t) ASN1Enc_SETHashedRootKey,
  21. (ASN1EncFun_t) ASN1Enc_SETCertificateType,
  22. (ASN1EncFun_t) ASN1Enc_SETMerchantData,
  23. };
  24. typedef ASN1BerDecFun_t ASN1DecFun_t;
  25. static const ASN1DecFun_t decfntab[4] = {
  26. (ASN1DecFun_t) ASN1Dec_SETAccountAlias,
  27. (ASN1DecFun_t) ASN1Dec_SETHashedRootKey,
  28. (ASN1DecFun_t) ASN1Dec_SETCertificateType,
  29. (ASN1DecFun_t) ASN1Dec_SETMerchantData,
  30. };
  31. static const ASN1FreeFun_t freefntab[4] = {
  32. (ASN1FreeFun_t) NULL,
  33. (ASN1FreeFun_t) ASN1Free_SETHashedRootKey,
  34. (ASN1FreeFun_t) ASN1Free_SETCertificateType,
  35. (ASN1FreeFun_t) ASN1Free_SETMerchantData,
  36. };
  37. static const ULONG sizetab[4] = {
  38. SIZE_X509_Module_PDU_0,
  39. SIZE_X509_Module_PDU_1,
  40. SIZE_X509_Module_PDU_2,
  41. SIZE_X509_Module_PDU_3,
  42. };
  43. /* forward declarations of values: */
  44. /* definitions of value components: */
  45. /* definitions of values: */
  46. void ASN1CALL X509_Module_Startup(void)
  47. {
  48. X509_Module = ASN1_CreateModule(0x10000, ASN1_BER_RULE_DER, ASN1FLAGS_NOASSERT, 4, (const ASN1GenericFun_t *) encfntab, (const ASN1GenericFun_t *) decfntab, freefntab, sizetab, 0x746573);
  49. }
  50. void ASN1CALL X509_Module_Cleanup(void)
  51. {
  52. ASN1_CloseModule(X509_Module);
  53. X509_Module = NULL;
  54. }
  55. static int ASN1CALL ASN1Enc_SETAccountAlias(ASN1encoding_t enc, ASN1uint32_t tag, SETAccountAlias *val)
  56. {
  57. if (!ASN1BEREncBool(enc, tag ? tag : 0x1, *val))
  58. return 0;
  59. return 1;
  60. }
  61. static int ASN1CALL ASN1Dec_SETAccountAlias(ASN1decoding_t dec, ASN1uint32_t tag, SETAccountAlias *val)
  62. {
  63. if (!ASN1BERDecBool(dec, tag ? tag : 0x1, val))
  64. return 0;
  65. return 1;
  66. }
  67. static int ASN1CALL ASN1Enc_SETHashedRootKey(ASN1encoding_t enc, ASN1uint32_t tag, SETHashedRootKey *val)
  68. {
  69. if (!ASN1DEREncOctetString(enc, tag ? tag : 0x4, (val)->length, (val)->value))
  70. return 0;
  71. return 1;
  72. }
  73. static int ASN1CALL ASN1Dec_SETHashedRootKey(ASN1decoding_t dec, ASN1uint32_t tag, SETHashedRootKey *val)
  74. {
  75. if (!ASN1BERDecOctetString2(dec, tag ? tag : 0x4, val))
  76. return 0;
  77. return 1;
  78. }
  79. static void ASN1CALL ASN1Free_SETHashedRootKey(SETHashedRootKey *val)
  80. {
  81. if (val) {
  82. }
  83. }
  84. static int ASN1CALL ASN1Enc_SETCertificateType(ASN1encoding_t enc, ASN1uint32_t tag, SETCertificateType *val)
  85. {
  86. if (!ASN1DEREncBitString(enc, tag ? tag : 0x3, (val)->length, (val)->value))
  87. return 0;
  88. return 1;
  89. }
  90. static int ASN1CALL ASN1Dec_SETCertificateType(ASN1decoding_t dec, ASN1uint32_t tag, SETCertificateType *val)
  91. {
  92. if (!ASN1BERDecBitString2(dec, tag ? tag : 0x3, val))
  93. return 0;
  94. return 1;
  95. }
  96. static void ASN1CALL ASN1Free_SETCertificateType(SETCertificateType *val)
  97. {
  98. if (val) {
  99. }
  100. }
  101. static int ASN1CALL ASN1Enc_SETMerchantData(ASN1encoding_t enc, ASN1uint32_t tag, SETMerchantData *val)
  102. {
  103. ASN1uint32_t nLenOff;
  104. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  105. return 0;
  106. if (!ASN1DEREncCharString(enc, 0x16, ((val)->merID).length, ((val)->merID).value))
  107. return 0;
  108. if (!ASN1DEREncCharString(enc, 0x12, ((val)->merAcquirerBIN).length, ((val)->merAcquirerBIN).value))
  109. return 0;
  110. if (!ASN1DEREncCharString(enc, 0x16, ((val)->merTermID).length, ((val)->merTermID).value))
  111. return 0;
  112. if (!ASN1DEREncCharString(enc, 0x16, ((val)->merName).length, ((val)->merName).value))
  113. return 0;
  114. if (!ASN1DEREncCharString(enc, 0x16, ((val)->merCity).length, ((val)->merCity).value))
  115. return 0;
  116. if (!ASN1DEREncCharString(enc, 0x16, ((val)->merStateProvince).length, ((val)->merStateProvince).value))
  117. return 0;
  118. if (!ASN1DEREncCharString(enc, 0x16, ((val)->merPostalCode).length, ((val)->merPostalCode).value))
  119. return 0;
  120. if (!ASN1DEREncCharString(enc, 0x16, ((val)->merCountry).length, ((val)->merCountry).value))
  121. return 0;
  122. if (!ASN1DEREncCharString(enc, 0x16, ((val)->merPhone).length, ((val)->merPhone).value))
  123. return 0;
  124. if (!ASN1BEREncBool(enc, 0x1, (val)->merPhoneRelease))
  125. return 0;
  126. if (!ASN1BEREncBool(enc, 0x1, (val)->merAuthFlag))
  127. return 0;
  128. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  129. return 0;
  130. return 1;
  131. }
  132. static int ASN1CALL ASN1Dec_SETMerchantData(ASN1decoding_t dec, ASN1uint32_t tag, SETMerchantData *val)
  133. {
  134. ASN1decoding_t dd;
  135. ASN1octet_t *di;
  136. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  137. return 0;
  138. if (!ASN1BERDecCharString(dd, 0x16, &(val)->merID))
  139. return 0;
  140. if (!ASN1BERDecCharString(dd, 0x12, &(val)->merAcquirerBIN))
  141. return 0;
  142. if (!ASN1BERDecCharString(dd, 0x16, &(val)->merTermID))
  143. return 0;
  144. if (!ASN1BERDecCharString(dd, 0x16, &(val)->merName))
  145. return 0;
  146. if (!ASN1BERDecCharString(dd, 0x16, &(val)->merCity))
  147. return 0;
  148. if (!ASN1BERDecCharString(dd, 0x16, &(val)->merStateProvince))
  149. return 0;
  150. if (!ASN1BERDecCharString(dd, 0x16, &(val)->merPostalCode))
  151. return 0;
  152. if (!ASN1BERDecCharString(dd, 0x16, &(val)->merCountry))
  153. return 0;
  154. if (!ASN1BERDecCharString(dd, 0x16, &(val)->merPhone))
  155. return 0;
  156. if (!ASN1BERDecBool(dd, 0x1, &(val)->merPhoneRelease))
  157. return 0;
  158. if (!ASN1BERDecBool(dd, 0x1, &(val)->merAuthFlag))
  159. return 0;
  160. if (!ASN1BERDecEndOfContents(dec, dd, di))
  161. return 0;
  162. return 1;
  163. }
  164. static void ASN1CALL ASN1Free_SETMerchantData(SETMerchantData *val)
  165. {
  166. if (val) {
  167. ASN1charstring_free(&(val)->merID);
  168. ASN1charstring_free(&(val)->merAcquirerBIN);
  169. ASN1charstring_free(&(val)->merTermID);
  170. ASN1charstring_free(&(val)->merName);
  171. ASN1charstring_free(&(val)->merCity);
  172. ASN1charstring_free(&(val)->merStateProvince);
  173. ASN1charstring_free(&(val)->merPostalCode);
  174. ASN1charstring_free(&(val)->merCountry);
  175. ASN1charstring_free(&(val)->merPhone);
  176. }
  177. }