locked
Cryptography API Next Generation: NCryptFinalizeKey() failed with error code 0x80090010 RRS feed

  • Question

  • Hi,

    This topic is related to using Cryptography API Next Generation (CNG) to create a persistent ECDH key in the Microsoft Key Storage Provider (KSP).

    When I created an ECDH key for the "current user" with

    Status = NCryptCreatePersistedKey(ProviderHandleA, &PrivKeyHandleA, NCRYPT_ECDH_P256_ALGORITHM, L"My Key", 0, 0);

    Status = NCryptFinalizeKey(PrivKeyHandleA, 0);

    It worked fine.

    However, when I created an ECDH for the "local machine" with

    Status = NCryptCreatePersistedKey(ProviderHandleA, &PrivKeyHandleA, NCRYPT_ECDH_P256_ALGORITHM, L"My Key", 0, NCRYPT_MACHINE_KEY_FLAG);

    Status = NCryptFinalizeKey(PrivKeyHandleA, 0);

    The function NCryptFinalizeKey() returned the error code 0x80090010.

    The only change was in NCryptCreatePersistedKey() where NCRYPT_MACHINE_KEY_FLAG was used to indicate the key is for the local machine.

    My PC is a work PC running Windows 7.

    I am using Visual Studio 2013 to the code development.

    Does anyone know why NCryptFinalizeKey() fails when a key is created for the local machine instead of the current user?

    Thanks,

    Goson Gu

    Friday, November 6, 2015 1:18 AM