NCryptEnumKeys freeing ppEnumState RRS feed

  • Question

  • It's not entirely clear to me when you're supposed to call NCryptFreeBuffer on the pointer you receive from NCryptEnumKeys in ppEnumState. I would assume that if you receive an output from NCryptEnumKeys in ppEnumState, you need to either pass it back into NCryptEnumKeys or pass it into NCryptFreeBuffer. However, the SampleKSP that comes with the CNG development kit returns a pointer in ppEnumState that has already been freed in the case of an error. Is this a bug in the SampleKSP or are you supposed to ignore any out parameters when the function returns an error code?


    • Edited by JethroGB Wednesday, April 26, 2017 5:40 PM
    Wednesday, April 26, 2017 5:40 PM

All replies

  • So it seems even at MS there is confusion about how this is supposed to work. As mentioned, SampleKSP EnumKeys will always free the buffer when returning an error. The certutil.exe utility will always call FreeBuffer once it has obtained a pointer from EnumKeys regardless of the error code returned.

    • Edited by JethroGB Monday, May 8, 2017 7:11 PM
    Monday, May 8, 2017 7:11 PM