Protection Descriptors
A protection descriptor rule string contains a sequential list of one or more protectors. There must be at least one protector. If there is more than one, the protectors must be separated in the string by AND or OR. These values must be capitalized. The following syntax shows the string format of a protection descriptor.
Descriptor = [ Protector-or
*( OR-separator Protector-or ) ]
Protector-or = Protector-and
*( AND-separator Protector-and )
OR-separator = "OR"
AND-separator = "AND"
Protector-and = providerName EQUALS providerAttributes
providerName = descr
providerAttribute = string | hexstring
; The following characters are to be escaped when they appear
; in the value to be encoded: ESC, one of <escaped>, leading
; SHARP or SPACE, trailing SPACE, and NULL.
string = [ ( leadchar / pair ) [ *( stringchar / pair )
( trailchar / pair ) ] ]
leadchar = LUTF1 / UTFMB
LUTF1 = %x01-1F / %x21 / %x24-2A / %x2D-3A / %x3D / %x3F-5B / %x5D-7F
trailchar = TUTF1 / UTFMB
TUTF1 = %x01-1F / %x21 / %x23-2A / %x2D-3A / %x3D / %x3F-5B / %x5D-7F
stringchar = SUTF1 / UTFMB
SUTF1 = %x01-21 / %x23-2A / %x2D-3A / %x3D / %x3F-5B / %x5D-7F
pair = ESC ( ESC / special / hexpair )
special = escaped / SPACE / SHARP / EQUALS
escaped = DQUOTE / PLUS / COMMA / SEMI / LANGLE / RANGLE
hexstring = SHARP 1*hexpair
hexpair = HEX HEX
descr = leadkeychar *keychar
leadkeychar = ALPHA
keychar = ALPHA / DIGIT / HYPHEN
number = DIGIT / ( LDIGIT 1*DIGIT )
ALPHA = %x41-5A / %x61-7A ; "A"-"Z" / "a"-"z"
DIGIT = %x30 / LDIGIT ; "0"-"9"
LDIGIT = %x31-39 ; "1"-"9"
HEX = DIGIT / %x41-46 / %x61-66 ; "0"-"9" / "A"-"F" / "a"-"f"
NULL = %x00 ; null (0)
SPACE = %x20 ; space (" ")
DQUOTE = %x22 ; quote (""")
SHARP = %x23 ; octothorpe (or sharp sign) ("#")
DOLLAR = %x24 ; dollar sign ("$")
SQUOTE = %x27 ; single quote ("'")
LPAREN = %x28 ; left paren ("(")
RPAREN = %x29 ; right paren (")")
PLUS = %x2B ; plus sign ("+")
COMMA = %x2C ; comma (",")
HYPHEN = %x2D ; hyphen ("-")
DOT = %x2E ; period (".")
SEMI = %x3B ; semicolon (";")
LANGLE = %x3C ; left angle bracket ("<")
EQUALS = %x3D ; equals sign ("=")
RANGLE = %x3E ; right angle bracket (">")
ESC = %x5C ; backslash ("\")
USCORE = %x5F ; underscore ("_")
LCURLY = %x7B ; left curly brace "{"
RCURLY = %x7D ; right curly brace "}"
; Any UTF-8 [RFC3629] encoded Unicode [Unicode] character
UTF8 = UTF1 / UTFMB
UTFMB = UTF2 / UTF3 / UTF4
UTF0 = %x80-BF
UTF1 = %x00-7F
UTF2 = %xC2-DF UTF0
UTF3 = %xE0 %xA0-BF UTF0 / %xE1-EC 2(UTF0) /
%xED %x80-9F UTF0 / %xEE-EF 2(UTF0)
UTF4 = %xF0 %x90-BF 2(UTF0) / %xF1-F3 3(UTF0) /
%xF4 %x80-8F 2(UTF0)
OCTET = %x00-FF ; Any octet (8-bit data unit)
Protection descriptors can currently be defined for the following types of authorization:
- A group in an Active Directory forest.
- A set of web credentials.
- A certificate in the user's certificate store.
Examples of protection descriptor rule strings for an Active Directory group include the following:
- "SID=S-1-5-21-4392301 AND SID=S-1-5-21-3101812"
- "SDDL=O:S-1-5-5-0-290724G:SYD:(A;;CCDC;;;S-1-5-5-0-290724)(A;;DC;;;WD)"
- "LOCAL=user"
- "LOCAL=machine"
Examples of protection descriptor rule strings for a set of web credentials include the following:
- "WEBCREDENTIALS=MyPasswordName"
- "WEBCREDENTIALS=MyPasswordName,myweb.com"
Examples of protection descriptor rule strings for a certificate include the following:
- "CERTIFICATE=HashID:sha1_hash_of_certificate"
- "CERTIFICATE=CertBlob:base64String"
The protection descriptor you specify automatically determines which key protection provider is used. For more information, see Protection Providers.
Note that the left side of the equals sign (=) must be SID, SDDL, LOCAL, WEBCREDENTIALS, or CERTIFICATE. These values are not case sensitive.
You must specify a rule string (or a display name associated with a rule string) when you call the NCryptCreateProtectionDescriptor function. Alternatively, because protection descriptor rule strings are somewhat cumbersome to use and remember, you can associate a display name with the rule string and register both by using the NCryptRegisterProtectionDescriptorName function. Then you can use the display name in NCryptCreateProtectionDescriptor.
Related topics