Skip to content

Commit

Permalink
Another fix for PKISolutions/PSPKI#56
Browse files Browse the repository at this point in the history
  • Loading branch information
Crypt32 committed Oct 19, 2018
1 parent fad3f5c commit cb82418
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions PKI/Structs/nCrypt2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ static class nCrypt2 {
public const UInt32 NCRYPT_ASYMMETRIC_ENCRYPTION_OPERATION = 0x00000004;
public const UInt32 NCRYPT_SECRET_AGREEMENT_OPERATION = 0x00000008;
public const UInt32 NCRYPT_SIGNATURE_OPERATION = 0x00000010;
public const UInt32 NCRYPT_MACHINE_KEY_FLAG = 0x00000020;

// Key Storage Property Identifiers
public const String NCRYPT_NAME_PROPERTY = "Name";
Expand Down
6 changes: 5 additions & 1 deletion PKI/Tools/MessageOperations/MessageSigner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,11 @@ void acquirePrivateKeyFromKeyBuilder() {
openLegacyPrivateKey();
return;
}
hresult = NCrypt.NCryptOpenKey(phProv, out phPrivKey, _keyInfo.KeyContainerName, (UInt32)_keyInfo.KeySpec, 0);
UInt32 dwFlags = 0;
if (_keyInfo.MachineContext) {
dwFlags = nCrypt2.NCRYPT_MACHINE_KEY_FLAG;
}
hresult = NCrypt.NCryptOpenKey(phProv, out phPrivKey, _keyInfo.KeyContainerName, (UInt32)_keyInfo.KeySpec, dwFlags);
if (hresult != 0) {
throw new CryptographicException(hresult);
}
Expand Down

0 comments on commit cb82418

Please sign in to comment.