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.

89 lines
1.8 KiB

  1. //=============================================================================
  2. //
  3. // MODULE: ASN1OctetString.cxx
  4. //
  5. // Description:
  6. //
  7. // Implementation of ASN.1 octet 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 octet string
  17. //
  18. DWORD
  19. ASN1ParserOctetString::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)utOctetString ))
  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 = utOctetString;
  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. //
  55. // Octet strings can be encoded other things, in highly situation-specific
  56. // context.
  57. //
  58. // Here we call into our derived class to get the value we just parsed out
  59. // interpreted as appropriate.
  60. //
  61. dw = ParseBlob( Value );
  62. if ( dw != ERROR_SUCCESS )
  63. {
  64. goto Cleanup;
  65. }
  66. Cleanup:
  67. if ( dw != ERROR_SUCCESS )
  68. {
  69. *Frame = FrameIn;
  70. }
  71. return dw;
  72. }