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.

77 lines
1.5 KiB

  1. //=============================================================================
  2. //
  3. // MODULE: ASN1GString.cxx
  4. //
  5. // Description:
  6. //
  7. // Implementation of ASN.1 general string parsing logic
  8. //
  9. // Modification History
  10. //
  11. // Mark Pustilnik Date: 06/09/02 - created
  12. //
  13. //=============================================================================
  14. #include "ASN1Parser.hxx"
  15. //
  16. // Retrieve the value of an ASN.1-encoded general string
  17. //
  18. DWORD
  19. ASN1ParserGeneralString::GetValue(
  20. IN OUT ASN1FRAME * Frame,
  21. OUT ASN1VALUE * Value
  22. )
  23. {
  24. DWORD dw;
  25. ASN1FRAME FrameIn = *Frame;
  26. DWORD DLength = DataLength( Frame );
  27. ULPBYTE Address = Frame->Address;
  28. if ( *Frame->Address != BuildDescriptor(
  29. ctUniversal,
  30. pcPrimitive,
  31. (BYTE)utGeneralString ))
  32. {
  33. dw = ERROR_INVALID_USER_BUFFER;
  34. goto Cleanup;
  35. }
  36. //
  37. // Skip over the the descriptor
  38. //
  39. Address++;
  40. //
  41. // Skip over the length header
  42. //
  43. Address += HeaderLength( Address );
  44. Value->Address = Address;
  45. Value->Length = DLength;
  46. Value->ut = utGeneralString;
  47. Value->string.s = Address;
  48. Value->string.l = DLength;
  49. //
  50. // Move the frame beyond the octet string
  51. //
  52. Address += DLength;
  53. Frame->Address = Address;
  54. dw = ERROR_SUCCESS;
  55. Cleanup:
  56. if ( dw != ERROR_SUCCESS )
  57. {
  58. *Frame = FrameIn;
  59. }
  60. return dw;
  61. }