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.

79 lines
2.5 KiB

  1. /* Copyright (C) Microsoft Corporation, 1996-1999. All rights reserved. */
  2. /* ASN.1 definitions for GlobalDirectives */
  3. #include <windows.h>
  4. #include "cepasn.h"
  5. ASN1module_t CEPASN_Module = NULL;
  6. static int ASN1CALL ASN1Enc_IssuerAndSerialNumber(ASN1encoding_t enc, ASN1uint32_t tag, IssuerAndSerialNumber *val);
  7. static int ASN1CALL ASN1Dec_IssuerAndSerialNumber(ASN1decoding_t dec, ASN1uint32_t tag, IssuerAndSerialNumber *val);
  8. static void ASN1CALL ASN1Free_IssuerAndSerialNumber(IssuerAndSerialNumber *val);
  9. typedef ASN1BerEncFun_t ASN1EncFun_t;
  10. static const ASN1EncFun_t encfntab[1] = {
  11. (ASN1EncFun_t) ASN1Enc_IssuerAndSerialNumber,
  12. };
  13. typedef ASN1BerDecFun_t ASN1DecFun_t;
  14. static const ASN1DecFun_t decfntab[1] = {
  15. (ASN1DecFun_t) ASN1Dec_IssuerAndSerialNumber,
  16. };
  17. static const ASN1FreeFun_t freefntab[1] = {
  18. (ASN1FreeFun_t) ASN1Free_IssuerAndSerialNumber,
  19. };
  20. static const ULONG sizetab[1] = {
  21. SIZE_CEPASN_Module_PDU_0,
  22. };
  23. /* forward declarations of values: */
  24. /* definitions of value components: */
  25. /* definitions of values: */
  26. void ASN1CALL CEPASN_Module_Startup(void)
  27. {
  28. CEPASN_Module = ASN1_CreateModule(0x10000, ASN1_BER_RULE_DER, ASN1FLAGS_NOASSERT, 1, (const ASN1GenericFun_t *) encfntab, (const ASN1GenericFun_t *) decfntab, freefntab, sizetab, 0x61706563);
  29. }
  30. void ASN1CALL CEPASN_Module_Cleanup(void)
  31. {
  32. ASN1_CloseModule(CEPASN_Module);
  33. CEPASN_Module = NULL;
  34. }
  35. static int ASN1CALL ASN1Enc_IssuerAndSerialNumber(ASN1encoding_t enc, ASN1uint32_t tag, IssuerAndSerialNumber *val)
  36. {
  37. ASN1uint32_t nLenOff;
  38. if (!ASN1BEREncExplicitTag(enc, tag ? tag : 0x10, &nLenOff))
  39. return 0;
  40. if (!ASN1BEREncOpenType(enc, &(val)->issuer))
  41. return 0;
  42. if (!ASN1BEREncSX(enc, 0x2, &(val)->serialNumber))
  43. return 0;
  44. if (!ASN1BEREncEndOfContents(enc, nLenOff))
  45. return 0;
  46. return 1;
  47. }
  48. static int ASN1CALL ASN1Dec_IssuerAndSerialNumber(ASN1decoding_t dec, ASN1uint32_t tag, IssuerAndSerialNumber *val)
  49. {
  50. ASN1decoding_t dd;
  51. ASN1octet_t *di;
  52. if (!ASN1BERDecExplicitTag(dec, tag ? tag : 0x10, &dd, &di))
  53. return 0;
  54. if (!ASN1BERDecOpenType(dd, &(val)->issuer))
  55. return 0;
  56. if (!ASN1BERDecSXVal(dd, 0x2, &(val)->serialNumber))
  57. return 0;
  58. if (!ASN1BERDecEndOfContents(dec, dd, di))
  59. return 0;
  60. return 1;
  61. }
  62. static void ASN1CALL ASN1Free_IssuerAndSerialNumber(IssuerAndSerialNumber *val)
  63. {
  64. if (val) {
  65. ASN1open_free(&(val)->issuer);
  66. ASN1intx_free(&(val)->serialNumber);
  67. }
  68. }