Error while trying to set key ID (NCRYPT_NAME_PROPERTY) - 0x80090027 - Invalid parameter

0

I am trying to change key ID (Key name), I am using NCrypt: First I am calling NCryptOpenStorageProvider to initialize provider handle, after that I am calling NcryptOpenKey to initialize key handle this functions works well without errors.

After that I call NCryptSetProperty

string name = "keyName"; 
byte[] nameBytes = System.Text.Encoding.UTF8.GetBytes(name);

uint ret = NCryptSetProperty(Key Handle, NCRYPT_NAME_PROPERTY, nameBytes, (uint)nameBytes.Length,0);

If(ret != ERROR_SUCCESS) 
{ 
 Console.WriteLine(ret.toString());
} 

I got error 0x80090027 INVALID Parameter.

Do you have any idea? I suspect in the convertion from string to byte array, but I tried using also ascii and got same error.

c#
cryptography
cng
asked on Stack Overflow May 19, 2020 by Sagir

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0