Key Storage and Retrieval - Win32 apps (2024)

  • Article
  • 4 minutes to read
  • Key Storage Architecture
  • Key Types
  • Supported Algorithms
  • Key Directories and Files

Key Storage Architecture

CNG provides a model for private key storage that allows adapting to the current and future demands of creating applications that use cryptography features such as public or private key encryption, as well as the demands of the storage of key material. The key storage router is the central routine in this model and is implemented in Ncrypt.dll. An application accesses the key storage providers (KSPs) on the system through the key storage router, which conceals details, such as key isolation, from both the application and the storage provider itself. The following illustration shows the design and function of the CNG key isolation architecture.

Key Storage and Retrieval - Win32 apps (1)

To comply with common criteria (CC) requirements, the long-lived keys must be isolated so that they are never present in the application process. CNG currently supports the storage of asymmetric private keys by using the Microsoft software KSP that is included with Windows Server 2008 and Windows Vista and installed by default.

Key isolation is enabled by default in Windows Server 2008 and Windows Vista. The key isolation feature is not available on platforms prior to these. Also, third party KSPs are not loaded in the key isolation service (LSA process). Only the Microsoft KSP is loaded in the key isolation service.

The LSA process is used as the key isolation process to maximize performance. All access to private keys goes through the key storage router, which exposes a comprehensive set of functions for managing and using private keys.

CNG stores the public portion of the stored key separately from the private portion. The public portion of a key pair is also maintained in the key isolation service and is accessed by using local remote procedure call (LRPC). The key storage router uses LRPC when calling into the key isolation process. All access to private keys goes through the private key router and is audited by CNG.

As described above, a wide range of hardware storage devices can be supported. In each case, the interface to all of these storage devices is identical. It includes functions to perform various private key operations as well as functions that pertain to key storage and management.

CNG provides a set of APIs that are used to create, store, and retrieve cryptographic keys. For a list of these APIs, see CNG Key Storage Functions.

Key Types

CNG supports the following key types:

  • Diffie-Hellman public and private keys.
  • Digital Signature Algorithm (DSA, FIPS 186-2) public and private keys.
  • RSA (PKCS #1) public and private keys.
  • Several legacy (CryptoAPI) public and private keys.
  • Elliptic Curve Cryptography public and private keys.

Supported Algorithms

CNG supports the following key algorithms.

AlgorithmKey/hash length (bits)
RSA512 to 16384, in 64 bit increments
DH512 to 16384, in 64 bit increments
DSA512 to 1024, in 64 bit increments
ECDSAP-256, P-384, P-521 (NIST Curves)
ECDHP-256, P-384, P-521 (NIST Curves)
MD2128
MD4128
MD5128
SHA-1160
SHA-256256
SHA-384384
SHA-512512

Key Directories and Files

The Microsoft legacy CryptoAPI CSPs store private keys in the following directories.

Key typeDirectories
User private%APPDATA%\Microsoft\Crypto\RSA\User SID\
%APPDATA%\Microsoft\Crypto\DSS\User SID\
Local system private%ALLUSERSPROFILE%\Application Data\Microsoft\Crypto\RSA\S-1-5-18\
%ALLUSERSPROFILE%\Application Data\Microsoft\Crypto\DSS\S-1-5-18\
Local service private%ALLUSERSPROFILE%\Application Data\Microsoft\Crypto\RSA\S-1-5-19\
%ALLUSERSPROFILE%\Application Data\Microsoft\Crypto\DSS\S-1-5-19\
Network service private%ALLUSERSPROFILE%\Application Data\Microsoft\Crypto\RSA\S-1-5-20\
%ALLUSERSPROFILE%\Application Data\Microsoft\Crypto\DSS\S-1-5-20\
Shared private%ALLUSERSPROFILE%\Application Data\Microsoft\Crypto\RSA\MachineKeys
%ALLUSERSPROFILE%\Application Data\Microsoft\Crypto\DSS\MachineKeys

CNG stores private keys in the following directories.

Key typeDirectory
User private%APPDATA%\Microsoft\Crypto\Keys
Local system private%ALLUSERSPROFILE%\Application Data\Microsoft\Crypto\SystemKeys
Local service private%WINDIR%\ServiceProfiles\LocalService
Network service private%WINDIR%\ServiceProfiles\NetworkService
Shared private%ALLUSERSPROFILE%\Application Data\Microsoft\Crypto\Keys

The following are some of the differences between the CryptoAPI and CNG key containers.

  • CNG uses different file names for key files than key files that are created by the Rsaenh.dll and Dssenh.dll legacy CSPs. The legacy key files also have the .key extension, but CNG key files do not have the .key extension.
  • CNG fully supports Unicode key container names; CNG uses a hash of the Unicode container name, whereas CryptoAPI uses a hash of the ANSI container name.
  • CNG is more flexible with regard to RSA key pairs. For example, CNG supports public exponents larger than 32-bits in length, and it supports keys in which p and q are different lengths.
  • In CryptoAPI, the key container file is stored in a directory whose name is the textual equivalent of the user's SID. This is no longer the case in CNG, which removes the difficulty of moving users from one domain to another without losing all of their private keys.
  • The CNG KSP and key names are limited to MAX_PATH Unicode characters. The CryptoAPI CSP and key names are limited to MAX_PATH ANSI characters.
  • CNG offers the capability of user-defined key properties. Users can create and associate custom properties with keys, and have them stored with persisted keys.

When persisting a key, CNG can create two files. The first file contains the private key in the new CNG format and is always created. This file is not usable by the legacy CryptoAPI CSPs. The second file contains the same private key in the legacy CryptoAPI key container. The second file conforms to the format and location used by Rsaenh.dll. Creation of the second file only occurs if the NCRYPT_WRITE_KEY_TO_LEGACY_STORE_FLAG flag is specified when the NCryptFinalizeKey function is called to finalize an RSA key. This feature is not supported for DSA and DH keys.

When an application attempts to open an existing persisted key, CNG first attempts to open the native CNG file. If this file does not exist, then CNG attempts to locate a matching key in the legacy CryptoAPI key container.

When you move or copy CryptoAPI keys from a source machine to a target machine with Windows User State Migration Tool (USMT), CNG will fail to access the keys on the target machine. To access such migrated keys, you must use the CryptoAPI.

Key Storage and Retrieval - Win32 apps (2024)

FAQs

What is the default key storage provider? ›

The Microsoft Software Key Storage Provider comes as default with any new operating system and is usually enough for most use cases.

How does Windows store private keys? ›

All access to private keys goes through the key storage router, which exposes a comprehensive set of functions for managing and using private keys. CNG stores the public portion of the stored key separately from the private portion.

What is Microsoft key store? ›

Key store is used for private keys. Those can be used for applications that use cryptography features such as public or private key encryption. These types of keys are supported: Diffie-Hellman public and private keys.

What is Secure key Storage? ›

Secure Key Storage is a feature in Secure Vault High devices that allows for the protection of cryptographic keys by key wrap- ping. User keys are encrypted by the device's root key for non- volatile storage for later usage.

What is Windows default cryptographic service provider? ›

The Microsoft Strong Cryptographic Provider is used as the default RSA Full cryptographic service provider (CSP). It supports all of the algorithms of the Microsoft Enhanced Cryptographic Provider and all of the same key lengths.

Is Windows key permanently? ›

If you purchased the official genuine retail version, the key is permanently valid.

Where does the Windows key get stored? ›

The key for the version of Windows the PC comes with, is stored in the computer's UEFI firmware or BIOS. You don't even need to know it — assuming you're installing the same edition of Windows the PC came with, it should automatically activate and work without you needing to enter a key.

Where are private keys usually stored? ›

A CA's private key should be stored in hardware-based protection, such as a Hardware Security Module (HSM). This provides tamper-resistant secure storage. A Private key for an end entity could be stored in a Trusted Platform Module (TPM) chip or a USB tamper-resistant security token.

What is key vault secret? ›

Secrets Management - Azure Key Vault can be used to Securely store and tightly control access to tokens, passwords, certificates, API keys, and other secrets. Key Management - Azure Key Vault can be used as a Key Management solution.

Is Windows key same as Office key? ›

The Office product key shown on the Microsoft account, Services & subscriptions page will always be different than the product key that's shown on a product key card or email receipt. They are two different types of keys, even though they use the same format.

What is the difference between Windows Store and Microsoft Store? ›

The Microsoft Store – formerly called the Windows Store -- is an online marketplace for consumers to buy and download a variety of items. The store enables users to purchase hardware such as PCs, Surface products and Xbox consoles, or download software and digital content, including apps, games, movies or TV shows.

What are the 3 types of encryption keys? ›

3 Types of Encryption to Protect Your Data
  • Symmetric. The symmetric encryption method uses a single key both to encrypt and decrypt the data. ...
  • Asymmetric. The second major encryption method is asymmetric encryption, also sometimes known as public key encryption. ...
  • Hashing.

What are the risks of private key? ›

Private keys – the secret half of public/private key pairs used in public-key cryptography with asymmetric algorithms like RSA or ECDSA; anyone with the private key can impersonate the owner of the private key to decrypt private data, gain unauthorized access to systems or generate a fraudulent digital signature that ...

How can keys be compromised? ›

A private key is compromised when an unauthorized person obtains the private key or determines what the private key is that is used to encrypt and decrypt secret information. The compromised key can be used to decrypt encrypted data without the knowledge of the sender of the data.

What is the default authentication in Windows? ›

The Windows operating system implements a default set of authentication protocols, including Kerberos, NTLM, Transport Layer Security/Secure Sockets Layer (TLS/SSL), and Digest, as part of an extensible architecture.

What is CryptAcquireContext? ›

The CryptAcquireContext function is used to acquire a handle to a particular key container within a particular cryptographic service provider (CSP). This returned handle is used in calls to CryptoAPI functions that use the selected CSP.

What is Cryptographic Services used for? ›

Definition(s): A service that provides confidentiality, integrity, source authentication, entity authentication, non-repudiation support, access control and availability (e.g., encryption and decryption, and digital signature generation and verification).

Can someone use my Windows key? ›

If your Windows 10 came pre-installed on your PC, then that is an OEM licence and it is not transferable to another PC, therefore, the product key is absolutely no use to them . . . Or choose a local Phone Number: https://support.microsoft.com/en-us/help/13948/...

What do you get with a Windows key? ›

A function key found on PC keyboards. When pressed with no other key, the Windows key displays the Start menu/screen. When pressed in conjunction with another key, it provides shortcuts to several Windows functions (see below).

Is the Windows key stored on the motherboard? ›

For Windows 11, Windows 10, and Windows 8.1 the product key is "injected" onto the computer motherboard at the factory. Installation and activation of Windows see the information in the BIOS of the computer to verify authenticity. Owners of these computers do not need a physical key to input.

Is Windows product key stored on hard drive? ›

It's stored in the firmware of the device, so during installation, if it asks for product key, just click Skip or I don't have a product key so the installation will automatically read the product key from the firmware after setting up.

Can I use the same Windows product key on multiple computers? ›

Retail keys are the most flexible type of license. You're allowed to reuse such a key on different computers. (However, you can't use a single license on multiple computers simultaneously.) So if you build a whole new PC, you can move the license over to it with no hassle.

What does the Windows key look like? ›

The Windows key has the Microsoft logo on it and is found between the left Ctrl and Alt keys on the keyboard. Pressing the Windows key by itself opens the Start menu that also displays the search box. Holding down the Windows key and pressing another key, to trigger a keyboard shortcut, can speed up common tasks.

What is an example of a secret key? ›

The secret key method of encryption, which involves the use of a single key, is used to encrypt and decrypt the information and is sometimes referred to as symmetric key cryptography. An excellent example of secret key encryption is the decoder ring you may have had as a child.

What does private key look like? ›

What does a private Bitcoin key look like? A private Bitcoin key is a 64-character string of letters and numbers. It might look something like this: E9873D79C6D87DC0FB6A5778633389F4453213303DA61F20BD67FC233AA33262.

What is the difference between a secret key and a private key? ›

A private key, also known as a secret key, is a variable in cryptography that is used with an algorithm to encrypt and decrypt data. Secret keys should only be shared with the key's generator or parties authorized to decrypt the data.

What is the difference between KSP and CSP? ›

In general, KSP and CSP are similar in terms of their purpose. CSP refers to legacy CryptoAPI 1.0 and KSP refers to CNG or CAPI2.

What is Microsoft platform crypto provider? ›

Microsoft Platform Crypto Provider (CNG) Generates and stores keys in Trusted Platform Modules. Supports Key Attestation to allow CA to ensure key is created in TPM/Virtual smart card. Key Exchange. Digital Signature.

How many types of storage keys are there for authentication? ›

It is basically of two types namely SSH Key Based Authentication and Access Key Based Authentication.

What is Microsoft enhanced RSA and AES cryptographic provider? ›

The Microsoft Enhanced RSA and AES Cryptographic Provider supports the same capabilities as the Microsoft Base Cryptographic Provider, called the Base Provider. The AES Provider supports stronger security through longer keys and additional algorithms. It can be used with all versions of CryptoAPI.

What CSP is best? ›

Top 10 Cloud IaaS Providers: CSP Review & Ranking
  • 1and1.
  • OVH.
  • DigitalOcean.
  • Google Cloud Platform.
  • Rackspace.
  • CenturyLink.
  • Microsoft Azure.
  • Amazon Web Services.
Feb 24, 2017

What is the difference between KSP and IP? ›

Solution. Condition of precipitation: The ionic product (IP) of an electrolyte is defined in the same way as solubility product (Ksp). The only difference is that the ionic product expression contains a concentration of ions under any condition whereas the expression of Ksp contains only equilibrium concentrations.

Why choose Microsoft CSP? ›

Your CSP can help you from being over charged for services you don't need.. Subscription provisioning and management. Save your IT department time in and let the CSP advice and provision your subscriptions. You'll have the same control and features in the subscriptions.

What crypto is backed by Microsoft? ›

In the beta version of its Edge web browser, software giant Microsoft has added a cryptocurrency wallet based on Ethereum that acts like a Metamask clone, enabling users to store and trade Ethereum and Ethereum-based tokens.

What is CNG key vs legacy key? ›

CNG (Certificate Next Generation) creates v3 certificates while the Legacy option generates v2 certificates. Practically, they mostly deal with how the private key is stored and accessed. Common Microsoft apps (like IIS) work with CNG. Legacy works with almost everything, so choose that if you need to guess.

What is an example of a private key cryptography? ›

Public and private keys: an example

Bob wants to send Alice an encrypted email. To do this, Bob takes Alice's public key and encrypts his message to her. Then, when Alice receives the message, she takes the private key that is known only to her in order to decrypt the message from Bob.

What are the 3 types of computer authentication? ›

Authentication factors can be classified into three groups: something you know: a password or personal identification number (PIN); something you have: a token, such as bank card; something you are: biometrics, such as fingerprints and voice recognition.

What are the 3 types of keys used in network security? ›

There are three different kinds of network security keys: WEP, WPA, and WPA2, each more secure than the last. The type of security key you choose, along with how strong your password is, determines how safe your network is from hackers.

What is Microsoft Cryptoapi user agent? ›

It is a set of dynamically linked libraries that provides an abstraction layer which isolates programmers from the code used to encrypt the data. The Crypto API was first introduced in Windows NT 4.0 and enhanced in subsequent versions.

What is public key encryption service? ›

What is public key cryptography? Public key cryptography is a method of encrypting or signing data with two different keys and making one of the keys, the public key, available for anyone to use. The other key is known as the private key. Data encrypted with the public key can only be decrypted with the private key.

What is advanced office message encryption? ›

With Advanced Message Encryption in Office 365, you can control sensitive emails shared outside the organization with automatic policies and track those activities through the encrypted message portal access logs.

Top Articles
Latest Posts
Article information

Author: Francesca Jacobs Ret

Last Updated:

Views: 5480

Rating: 4.8 / 5 (48 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Francesca Jacobs Ret

Birthday: 1996-12-09

Address: Apt. 141 1406 Mitch Summit, New Teganshire, UT 82655-0699

Phone: +2296092334654

Job: Technology Architect

Hobby: Snowboarding, Scouting, Foreign language learning, Dowsing, Baton twirling, Sculpting, Cabaret

Introduction: My name is Francesca Jacobs Ret, I am a innocent, super, beautiful, charming, lucky, gentle, clever person who loves writing and wants to share my knowledge and understanding with you.