|
| 1 | +# CASK Secrets |
| 2 | +## Standard Backus-Naur Form (BNF) |
| 3 | +``` |
| 4 | +<key> ::= <sensitive-data> ; A sequence of security-sensitive bytes. |
| 5 | + <cask-signature> ; A fixed signature (`QJJQ`) that enables high-performance textual identification. |
| 6 | + <timestamp> ; The year, month, day, hour, and minute of secret allocation. |
| 7 | + <sensitive-data-size> ; A count of 16-byte segments encoded as sensitive data ('B' = 1 x 16 bytes = 128 bits, etc). |
| 8 | + <optional-data-size> ; A count of 3-byte optional data segments, 'A' = 0 = 0 bytes, 'B' = 1 = 3 bytes, etc. |
| 9 | + <provider-kind> ; A provider-defined key kind. |
| 10 | + [<optional-fields>] ; Optional fields comprising provider-defined data. |
| 11 | + <provider-signature> ; A fixed signature identifying the secret provider. |
| 12 | + <correlating-id> ; A 20-byte non-sensitive correlating identifier for the secret (see below). |
| 13 | +
|
| 14 | +<sensitive-data> ::= <128-bits-padded> | <256-bits-padded> ; The sensitive data is a secret generated for a security purpose, |
| 15 | + | <384-bits> | <512-bits-padded> ; such as random data generated by a cryptographically secure random |
| 16 | + ; number generator (RNG), a Hash Message Authentication Code (HMAC), |
| 17 | + ; an output of a Key Derivation Function (KDF), etc. CASK specifies |
| 18 | + ; a storage location and component size for this data but does not |
| 19 | + ; specify a particular cryptographic algorithm or method for |
| 20 | + ; generating it. The size of this component must conform to the |
| 21 | + ; encoded <sensitive-data-size> value. |
| 22 | +<128-bits-padded> ::= 21 * <base64url> <base64-four-zeros-suffix> 'AA' ; The total sensitive data comprises 128 bits encoded as 21 |
| 23 | + ; characters x 6 bits (126 bits) and 1 character providing |
| 24 | + ; 2 bits of sensitive data padded with 0000b. The final |
| 25 | + ; characters `AA` comprise 12 bits of additional padding |
| 26 | + ; that brings the component to a 3-byte boundary. |
| 27 | +<256-bits-padded> ::= 42 * <base64url> <base64-two-zeros-suffix> 'A' ; The total sensitive data comprises 256 bits encoded as 42 |
| 28 | + ; characters comprising 6 bits of sensitive data = 252 bits and |
| 29 | + ; The final characters `A` comprises 6 bits of additional |
| 30 | + ; padding that brings the component to a 3-byte boundary. |
| 31 | +<384-bits> ::= 64 * <base64url> ; The total sensitive data comprises 384 bits encoded as 64 |
| 32 | + ; 6-bit characters. No reserved padding is required, as |
| 33 | + ; 384 bits (48 bytes) aligns to a 3-byte boundary. |
| 34 | +<512-bits-padded> ::= 85 * <base64url> <base64-four-zeros-suffix> 'AA' ; The total sensitive data comprises 512 bits encoded as 85 |
| 35 | + ; characters x 6 bits (510 bits) and 1 character providing |
| 36 | + ; 2 bits of sensitive data padded with 0000b. The final |
| 37 | + ; characters `AA` comprise 12 bits of additional padding |
| 38 | + ; that brings the component to a 3-byte boundary. |
| 39 | +<base64url> ::= 'A'..'Z' | 'a'..'z' | '0'..'9' | '-' | '_' ; Base64 URL-safe printable characters. The '=' padding character is excluded. |
| 40 | +<base64-two-zeros-suffix> ::= 'A' | 'E' | 'I' | 'M' | 'Q' | 'U' | 'Y' | 'c' |
| 41 | + | 'g' | 'k' | 'o' | 's' | 'w' | '0' | '4' | '8' ; Base64 printable characters with two trailing zero bits. |
| 42 | +<base64-four-zeros-suffix> ::= 'A' | 'Q' | 'g' | 'w' ; Base64 printable characters with four trailing zero bits. |
| 43 | +<cask-signature> ::= 'QJJQ' ; Fixed signature identifying the CASK key. |
| 44 | +<timestamp> ::= <year> <month> <day> <hour> <minute> ; Time-of-allocation timestamp components. |
| 45 | +<year> ::= <base64url> ; Allocation year, 'A' (2025) to '_' (2088). |
| 46 | +<month> ::= 'A'..'L' ; Allocation month, 'A' (January) to 'L' (December). |
| 47 | +<day> ::= 'A'..'Z' | 'a'..'e' ; 'A' = day 1, 'B' = day 2, ... 'e' = day 31 |
| 48 | +<hour> ::= 'A'..'X' ; Represents hours 0-23. 'A' = hour 0 (midnight), ... 'X' = hour 23. |
| 49 | +<minute> ::= 'A'..'7' ; Represents minutes 0-59. |
| 50 | +<sensitive-data-size> ::= 'A' ; 'A' indicates a 128-bit sensitive data component, 'B' 256-bit, etc. |
| 51 | +<optional-data-size> ::= 'A' ; 'A' = zero 3-byte optional bytes, 'B' = one optional 3-byte segment, etc. |
| 52 | +<provider-kind> ::= <base64url> ; Provider-defined key kind. |
| 53 | +<provider-signature> ::= 4 * <base64url> ; Provider identifier (24 bits). |
| 54 | +<optional-fields> ::= { <optional-field> } ; Zero or more 4-character (24-bit) sequences of optional data. |
| 55 | +<optional-field> ::= 4 * <base64url> ; Each optional field is 4 characters (24 bits). This keeps data |
| 56 | + ; cleanly aligned along 3-byte/4-encoded character boundaries, |
| 57 | + ; facilitating readability of encoded form as well as byte-wise use. |
| 58 | +<correlating-id> ::= 20 * <base64url> ; 120 bits of unique, non-sensitive data generated by a cryptographically |
| 59 | + ; secure RNG. This data is not sensitive and is designed to correlate |
| 60 | + ; metadata for generated secrets with reports of exposure and other data. |
| 61 | + ; As a non-security-sensitive component, this data MUST NOT be used |
| 62 | + ; to drive security-sensitive operations. |
| 63 | +``` |
| 64 | + |
| 65 | +## Byte-wise Rendering Example for 256-bit Key (no optional data) |
| 66 | +|Byte Range|Decimal|Hex|Binary|Description| |
| 67 | +|-|-|-|-|-| |
| 68 | +|decodedKey[..31]|0...255|0x0...0xFF|00000000b...11111111b|256 bits of sensitive data produced by a cryptographically secure RNG, an HMAC, etc.| |
| 69 | +|decodedKey[32]|0|0x00|00000000b| 8 bits of reserved padding. |
| 70 | +|decodedKey[33..36]| 37, 4, 9 |0x40, 0x92, 0x50| 00100000b, 10010010b, 01010000b | Decoded 'QJJQ' signature. |
| 71 | +|decodedKey[36..39]||||Timestamp data encoded in 4 six-bit segments for YMDH. |
| 72 | +|decodedKey[39..42]||||Timestamp minutes, sensitive data size, optional-data-size, and provider kind data encoded in 4 six-bit segments. |
| 73 | +|decodedKey[42..45]|0...255|0x0...0xFF|00000000b...11111111b| Provider signature, e.g. , '0x4c', '0x44', '0x93' (base64-encoded as 'TEST') |
| 74 | +|decodedKey[45..60]||||16 byte non-sensitive, unique correlating id. |
| 75 | + |
| 76 | +## URL-Safe Base64-Encoded Rendering Example for 256-bit Key (no optional data) |
| 77 | +|String Range|Text Value|Description| |
| 78 | +|-|-|-| |
| 79 | +|encodedKey[..42] | 'A'...'_' | 252 bits of randomized data generated by cryptographically secure RNG |
| 80 | +|encodedKey[42] | <base64-two-zeros-suffix> | 4 bits of randomized data followed by 2 zero bits. See the <base64-two-zeros-suffix> definition for legal values. |
| 81 | +|encodedKey[43] | 'A' | The 6-bit encoded sensitive component size. |
| 82 | +|encodedKey[44..48]|'QJJQ'| Fixed CASK signature. |
| 83 | +|encodedKey[48]|'A'...'_'|Represents the year of allocation time, 'A' (2025) to '_' (2088)| |
| 84 | +|encodedKey[49|'A'...'L'|Represents the month of allocation time, 'A' (January) to 'L' (December)| |
| 85 | +|encodedKey[50]|'A'...'Z'\|'a'..'e'|Represents the day of allocation time, 'A' (0) to 'e' (31)| |
| 86 | +|encodedKey[51]|'A'...'X'|Represents the hour of allocation time, 'A' (hour 0 or midnight) to 'X' (hour 23). |
| 87 | +|encodedKey[52]|'A'...'7'| Represents the minute of allocation time. |
| 88 | +|encodedKey[53]|'A'...'D'| Sensitive component key size, 'A' (128-bit), 'B' (256-bit), 'C' (384-bit) or 'D' (512-bit). |
| 89 | +|encodedKey[54]|'A'...'?'| Count of optional 3-byte data segments, 'A' == 0 bytes, 'B' == 3 bytes, capped at ?? (maximum permissible would be 189 bytes, 63 * 3) |
| 90 | +|encodedKey[55]|'A'...'_'| Provider-defined key kind. |
| 91 | +|encodedKey[55..75]|'A'...'_'| Correlating id. |
| 92 | +``` |
0 commit comments