| 1 |
/* |
| 2 |
* constants.go - Some metadata constants used throughout fscrypt |
| 3 |
* |
| 4 |
* Copyright 2017 Google Inc. |
| 5 |
* Author: Joe Richey ([email protected]) |
| 6 |
* |
| 7 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 8 |
* use this file except in compliance with the License. You may obtain a copy of |
| 9 |
* the License at |
| 10 |
* |
| 11 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 12 |
* |
| 13 |
* Unless required by applicable law or agreed to in writing, software |
| 14 |
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 15 |
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 16 |
* License for the specific language governing permissions and limitations under |
| 17 |
* the License. |
| 18 |
*/ |
| 19 |
|
| 20 |
package metadata |
| 21 |
|
| 22 |
import ( |
| 23 |
"crypto/sha256" |
| 24 |
|
| 25 |
"golang.org/x/sys/unix" |
| 26 |
) |
| 27 |
|
| 28 |
// Lengths for our keys, buffers, and strings used in fscrypt. |
| 29 |
const ( |
| 30 |
// Length of policy descriptor (in hex chars) for v1 encryption policies |
| 31 |
PolicyDescriptorLenV1 = 2 * unix.FSCRYPT_KEY_DESCRIPTOR_SIZE |
| 32 |
// Length of protector descriptor (in hex chars) |
| 33 |
ProtectorDescriptorLen = PolicyDescriptorLenV1 |
| 34 |
// Length of policy descriptor (in hex chars) for v2 encryption policies |
| 35 |
PolicyDescriptorLenV2 = 2 * unix.FSCRYPT_KEY_IDENTIFIER_SIZE |
| 36 |
// We always use 256-bit keys internally (compared to 512-bit policy keys). |
| 37 |
InternalKeyLen = 32 |
| 38 |
IVLen = 16 |
| 39 |
SaltLen = 16 |
| 40 |
// We use SHA256 for the HMAC, and len(HMAC) == len(hash size). |
| 41 |
HMACLen = sha256.Size |
| 42 |
// PolicyKeyLen is the length of all keys passed directly to the Keyring |
| 43 |
PolicyKeyLen = unix.FSCRYPT_MAX_KEY_SIZE |
| 44 |
) |
| 45 |
|
| 46 |
var ( |
| 47 |
// DefaultOptions use the supported encryption modes, max padding, and |
| 48 |
// policy version 1. |
| 49 |
DefaultOptions = &EncryptionOptions{ |
| 50 |
Padding: 32, |
| 51 |
Contents: EncryptionOptions_AES_256_XTS, |
| 52 |
Filenames: EncryptionOptions_AES_256_CTS, |
| 53 |
PolicyVersion: 1, |
| 54 |
} |
| 55 |
// DefaultSource is the source we use if none is specified. |
| 56 |
DefaultSource = SourceType_custom_passphrase |
| 57 |
) |