Merge "hwcrypto: Moving hwcrypto files out of staging" into main

This commit is contained in:
Orlando Arbildo
2024-11-28 17:56:05 +00:00
committed by Gerrit Code Review
76 changed files with 578 additions and 378 deletions

View File

@@ -507,6 +507,14 @@
<instance>nonsecure</instance>
</interface>
</hal>
<hal format="aidl">
<name>android.hardware.security.see.hwcrypto</name>
<version>1</version>
<interface>
<name>IHwCryptoKey</name>
<instance>default</instance>
</interface>
</hal>
<hal format="aidl" updatable-via-apex="true">
<name>android.hardware.security.secureclock</name>
<version>1</version>

View File

@@ -156,6 +156,7 @@ bool ShouldCheckMissingAidlHalsInFcm(const std::string& packageAndVersion) {
// Fastboot HAL is only used by recovery. Recovery is owned by OEM. Framework
// does not depend on this HAL, hence it is not declared in any manifests or matrices.
"android.hardware.fastboot@",
"android.hardware.security.see.hwcrypto.types",
"android.hardware.security.see.storage",
};

View File

@@ -8,10 +8,8 @@ package {
}
aidl_interface {
name: "android.hardware.security.see",
unstable: false,
// TODO Remove this owner field when this interface is moved out of /staging
owner: "google_while_staging",
name: "android.hardware.security.see.hwcrypto",
stability: "vintf",
host_supported: true,
srcs: [
"android/hardware/security/see/hwcrypto/*.aidl",
@@ -22,11 +20,15 @@ aidl_interface {
enabled: false,
},
cpp: {
enabled: false,
enabled: true,
},
rust: {
enabled: true,
},
ndk: {
enabled: true,
},
},
frozen: false,
system_ext_specific: true,
}

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto;
@VintfStability
union CryptoOperation {
android.hardware.security.see.hwcrypto.MemoryBufferParameter setMemoryBuffer;
android.hardware.security.see.hwcrypto.OperationParameters setOperationParameters;

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto;
@VintfStability
parcelable CryptoOperationErrorAdditionalInfo {
long failingCommandIndex;
}

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto;
@VintfStability
parcelable CryptoOperationResult {
@nullable android.hardware.security.see.hwcrypto.ICryptoOperationContext context;
}

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto;
@VintfStability
parcelable CryptoOperationSet {
@nullable android.hardware.security.see.hwcrypto.ICryptoOperationContext context;
android.hardware.security.see.hwcrypto.CryptoOperation[] operations;

View File

@@ -32,5 +32,6 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto;
@VintfStability
interface ICryptoOperationContext {
}

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto;
@VintfStability
interface IHwCryptoKey {
android.hardware.security.see.hwcrypto.IHwCryptoKey.DiceCurrentBoundKeyResult deriveCurrentDicePolicyBoundKey(in android.hardware.security.see.hwcrypto.IHwCryptoKey.DiceBoundDerivationKey derivationKey);
android.hardware.security.see.hwcrypto.IHwCryptoKey.DiceBoundKeyResult deriveDicePolicyBoundKey(in android.hardware.security.see.hwcrypto.IHwCryptoKey.DiceBoundDerivationKey derivationKey, in byte[] dicePolicyForKeyVersion);

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto;
@VintfStability
interface IHwCryptoOperations {
android.hardware.security.see.hwcrypto.CryptoOperationResult[] processCommandList(inout android.hardware.security.see.hwcrypto.CryptoOperationSet[] operations, out android.hardware.security.see.hwcrypto.CryptoOperationErrorAdditionalInfo additionalErrorInfo);
}

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto;
@VintfStability
interface IOpaqueKey {
byte[] exportWrappedKey(in android.hardware.security.see.hwcrypto.IOpaqueKey wrappingKey);
android.hardware.security.see.hwcrypto.KeyPolicy getKeyPolicy();

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto;
@VintfStability
parcelable KeyPolicy {
android.hardware.security.see.hwcrypto.types.KeyUse usage;
android.hardware.security.see.hwcrypto.types.KeyLifetime keyLifetime = android.hardware.security.see.hwcrypto.types.KeyLifetime.EPHEMERAL;

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto;
@VintfStability
parcelable MemoryBufferParameter {
android.hardware.security.see.hwcrypto.MemoryBufferParameter.MemoryBuffer bufferHandle;
int sizeBytes;

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto;
@VintfStability
union OperationParameters {
android.hardware.security.see.hwcrypto.types.SymmetricAuthOperationParameters symmetricAuthCrypto;
android.hardware.security.see.hwcrypto.types.SymmetricOperationParameters symmetricCrypto;

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto;
@VintfStability
parcelable PatternParameters {
long numberBlocksProcess;
long numberBlocksCopy;

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
union AesCipherMode {
android.hardware.security.see.hwcrypto.types.CipherModeParameters cbc;
android.hardware.security.see.hwcrypto.types.CipherModeParameters ctr;

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
union AesGcmMode {
android.hardware.security.see.hwcrypto.types.AesGcmMode.AesGcmModeParameters gcmTag16;
parcelable AesGcmModeParameters {

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
union AesKey {
byte[16] aes128 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
byte[32] aes256;

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
parcelable CipherModeParameters {
byte[16] nonce;
}

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
union ExplicitKeyMaterial {
android.hardware.security.see.hwcrypto.types.AesKey aes;
android.hardware.security.see.hwcrypto.types.HmacKey hmac;

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
parcelable HalErrorCode {
const int NO_ERROR = 0;
const int GENERIC_ERROR = (-1) /* -1 */;

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
union HmacKey {
byte[32] sha256 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
byte[64] sha512;

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
parcelable HmacOperationParameters {
android.hardware.security.see.hwcrypto.IOpaqueKey key;
}

View File

@@ -32,7 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@Backing(type="byte")
@Backing(type="byte") @VintfStability
enum KeyLifetime {
EPHEMERAL,
HARDWARE,

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
enum KeyPermissions {
ALLOW_EPHEMERAL_KEY_WRAPPING,
ALLOW_HARDWARE_KEY_WRAPPING,

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
enum KeyType {
AES_128_CBC_NO_PADDING,
AES_128_CBC_PKCS7_PADDING,

View File

@@ -32,7 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@Backing(type="int")
@Backing(type="int") @VintfStability
enum KeyUse {
ENCRYPT = 1,
DECRYPT = 2,

View File

@@ -32,7 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@RustDerive(Clone=true, Copy=true)
@RustDerive(Clone=true, Copy=true) @VintfStability
parcelable MemoryBufferReference {
int startOffset;
int sizeBytes;

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
parcelable OpaqueKeyToken {
byte[] keyToken;
}

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
union OperationData {
android.hardware.security.see.hwcrypto.types.MemoryBufferReference memoryBufferReference;
byte[] dataBuffer;

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
enum OperationType {
READ,
WRITE,

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
enum ProtectionId {
WIDEVINE_OUTPUT_BUFFER = 1,
}

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
union SymmetricAuthCryptoParameters {
android.hardware.security.see.hwcrypto.types.AesGcmMode aes;
}

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
parcelable SymmetricAuthOperationParameters {
android.hardware.security.see.hwcrypto.IOpaqueKey key;
android.hardware.security.see.hwcrypto.types.SymmetricOperation direction;

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
union SymmetricCryptoParameters {
android.hardware.security.see.hwcrypto.types.AesCipherMode aes;
}

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
enum SymmetricOperation {
ENCRYPT,
DECRYPT,

View File

@@ -32,6 +32,7 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
parcelable SymmetricOperationParameters {
android.hardware.security.see.hwcrypto.IOpaqueKey key;
android.hardware.security.see.hwcrypto.types.SymmetricOperation direction;

View File

@@ -32,5 +32,6 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.security.see.hwcrypto.types;
@VintfStability
parcelable Void {
}

View File

@@ -25,6 +25,7 @@ import android.hardware.security.see.hwcrypto.types.Void;
* Type that describes the different operations that can be performed along with its required
* parameters. It will be used to construct a vector of operation that are executed sequentially.
*/
@VintfStability
union CryptoOperation {
/*
* Sets a memory buffer to operate on. References to positions of this memory buffer can be used

View File

@@ -18,6 +18,7 @@ package android.hardware.security.see.hwcrypto;
/*
* Type that provides more information about failures when processing a list of commands.
*/
@VintfStability
parcelable CryptoOperationErrorAdditionalInfo {
/*
* Index indicating the first step of <code>CryptoOperationSet::operations</code> that failed

View File

@@ -20,6 +20,7 @@ import android.hardware.security.see.hwcrypto.ICryptoOperationContext;
/*
* Type that describes the result of a set of crypto operations.
*/
@VintfStability
parcelable CryptoOperationResult {
/*
* Token that can be passed on a CryptoOperationSet to issue more operations on the same context

View File

@@ -21,6 +21,7 @@ import android.hardware.security.see.hwcrypto.ICryptoOperationContext;
/*
* Type that describes a set of crypto operations to execute
*/
@VintfStability
parcelable CryptoOperationSet {
/*
* Token to be used to issue the operations. If NULL, a new context will be created and

View File

@@ -22,4 +22,5 @@ package android.hardware.security.see.hwcrypto;
* operation in progress context includes any memory buffer previously mapped by a
* <code>CryptoOperation::SetMemoryBuffer</code> call.
*/
@VintfStability
interface ICryptoOperationContext {}

View File

@@ -0,0 +1,298 @@
/*
* Copyright 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.security.see.hwcrypto;
import android.hardware.security.see.hwcrypto.IHwCryptoOperations;
import android.hardware.security.see.hwcrypto.IOpaqueKey;
import android.hardware.security.see.hwcrypto.KeyPolicy;
import android.hardware.security.see.hwcrypto.types.ExplicitKeyMaterial;
import android.hardware.security.see.hwcrypto.types.OpaqueKeyToken;
/*
* Higher level interface to access and generate keys.
*/
@VintfStability
interface IHwCryptoKey {
/*
* Identifier for the requested device provided key. The currently supported identifiers are:
*
*/
enum DeviceKeyId {
/*
* This is a key unique to the device.
*/
DEVICE_BOUND_KEY,
/*
* This is a shared by a set of devices.
*/
BATCH_KEY,
}
/*
* Identifier for the requested key slot. The currently supported identifiers are:
*
*/
enum KeySlot {
/*
* This is the shared HMAC key that will now be computed by HwCryptoKey after participating
* in the ISharedSecret protocol that can be shared with KeyMint and authenticators. See
* ISharedSecret.aidl for more information.
*/
KEYMINT_SHARED_HMAC_KEY,
}
union DiceBoundDerivationKey {
/*
* Opaque to be used to derive the DICE bound key.
*/
IOpaqueKey opaqueKey;
/*
* Device provided key to be used to derive the DICE bound key.
*/
DeviceKeyId keyId;
}
parcelable DiceCurrentBoundKeyResult {
/*
* Key cryptographically bound to a DICE policy.
*/
IOpaqueKey diceBoundKey;
/*
* Current dice policy which was used to generate the returned key. This policy is opaque
* from this service perspective (it will be sent to an Authentication Manager Service to be
* verified). It follows the structure defined on DicePolicy.cddl, located under
* hardware/interfaces/security/authgraph/aidl/android/hardware/security/authgraph/ with the
* caveat that it could be encrypted if the client does not have enough permissions to see
* the device dice policy information.
*/
byte[] dicePolicyForKeyVersion;
}
parcelable DiceBoundKeyResult {
/*
* Key cryptographically bound to a DICE policy.
*/
IOpaqueKey diceBoundKey;
/*
* Indicates if the diceBoundKey returned was created using a current DICE policy. The
* caller can use this to detect if an old policy was provided and rotate its keys if so
* desired. Old, valid policies remain usable, but care needs to be taken to not continue to
* use a potentially compromised key.
*/
boolean dicePolicyWasCurrent;
}
parcelable ClearKeyPolicy {
/*
* Indicates the desired key size. It will be used to calculate how many bytes of key
* material should be returned.
*/
int keySizeBytes;
}
union DerivedKeyPolicy {
/*
* If used we will derive a clear key and pass it back as an array of bytes on
* <code>HwCryptoKeyMaterial::explicitKey</code>.
*/
ClearKeyPolicy clearKey;
/*
* Policy for the newly derived opaque key. Defines how the key can be used and its type.
*/
byte[] opaqueKey;
}
parcelable DerivedKeyParameters {
/*
* Key to be used to derive the new key using HKDF.
*/
IOpaqueKey derivationKey;
/*
* Policy for the newly derived key. Depending on its type, either a clear or opaque key
* will be derived.
*/
DerivedKeyPolicy keyPolicy;
/*
* An arbitrary set of bytes incorporated into the key derivation. May have an
* implementation-specific maximum length, but it is guaranteed to accept at least 32 bytes.
*/
byte[] context;
}
union DerivedKey {
/*
* Derived key in clear format.
*/
byte[] explicitKey = {};
/*
* Derived key as a key token to be used only through the HWCrypto service.
*/
IOpaqueKey opaque;
}
/*
* Derives a versioned key tied to the caller's current DICE policy. It will return this current
* policy back to the caller along with the generated key.
*
* @param derivationKey:
* Key to be used to derive the new key using HKDF.
*
* @return:
* A DiceCurrentBoundKeyResult containint the versioned key tied the current client version
* on success.
*
* @throws:
* ServiceSpecificException based on <code>HalErrorCode</code> if any error occurs.
*/
DiceCurrentBoundKeyResult deriveCurrentDicePolicyBoundKey(
in DiceBoundDerivationKey derivationKey);
/*
* Derive a versioned key by checking the provided DICE policy against the caller and then using
* it as a context for deriving the returned key.
*
* @param derivationKey:
* Key to be used to derive the new key using HKDF.
*
* @param dicePolicyForKeyVersion:
* Policy used to derive keys tied to specific versions. Using this parameter the caller can
* tie a derived key to a minimum version of itself, so in the future only itself or a more
* recent version can derive the same key. This parameter is opaque to the caller and it
* could be encrypted in the case the client doesn't have permission to know the dice chain.
* When implementing this function, this parameter shall be one of the components fed to the
* KDF context and it needs to be checked against the caller DICE certificate before being
* used.
*
* @return:
* A DiceBoundKeyResult containing the versioned key tied to the provided DICE policy on
* success.
*
* @throws:
* ServiceSpecificException based on <code>HalErrorCode</code> if any error occurs.
*/
DiceBoundKeyResult deriveDicePolicyBoundKey(
in DiceBoundDerivationKey derivationKey, in byte[] dicePolicyForKeyVersion);
/*
* Derive a new key based on the given key, policy and context.
*
* @param parameters:
* Parameters used for the key derivation. See <code>DerivedKeyParameters</code> on this
* file for more information.
*
* @return:
* A HwCryptoKeyMaterial containing the derived key on success.
*
* @throws:
* ServiceSpecificException based on <code>HalErrorCode</code> if any error occurs.
*/
DerivedKey deriveKey(in DerivedKeyParameters parameters);
/*
* Returns an interface used to work on opaque keys. This interface can also be used to operate
* on any opaque key generated by hwkeyDeriveVersioned, even if this key has been generated
* after retrieving a IHwCryptoOperations binder object, as long as the parent
* IHwCryptoDeviceKeyAccess is not dropped between retrieving the IHwCryptoOperations binder
* object and deriving the key. IHwCryptoOperations can also be used to create opaque keys that
* are not bound to the device.
*
* @return:
* IHwCryptoOperations on success
*/
IHwCryptoOperations getHwCryptoOperations();
/*
* Imports a SW clear key into the secure environment.
*
* @param keyMaterial:
* key to be imported.
*
* @param newKeyPolicy:
* Policy of the new key. Defines how the newly created key can be used. Because any clear
* key imported into the system is considered to have a <code>KeyLifetime::PORTABLE</code>
* lifetime, a call to this function will return an error if
* <code>newKeyPolicy.newKeyPolicy</code> is not set to portable.
*
* @return:
* IOpaqueKey on success.
*
* @throws:
* ServiceSpecificException based on <code>HalErrorCode</code> if any error occurs.
*/
IOpaqueKey importClearKey(in ExplicitKeyMaterial keyMaterial, in KeyPolicy newKeyPolicy);
/*
* Returns the client current DICE policy. This policy is encrypted and considered opaque from
* the client perspective. This policy is the same used to create DICE bound keys and will also
* be used to seal secrets that can only be retrieved by the DICE policy owner. The first use of
* this seal operation will be <code>IOpaqueKey::getShareableToken</code> and will call this
* <code>IHwCryptoKey::keyTokenImport</code>. To start this process, the intended key receiver
* function and then pass the generated DICE policy to the owner of the key that the receiver
* wants to import. The key owner will then call <code>IOpaqueKey::getShareableToken</code>
* passing the receiver DICE policy to insure that only that receiver can import the key.
*
* @return:
* byte[] on success, which is the caller encrypted DICE policy.
*/
byte[] getCurrentDicePolicy();
/*
* Imports a key from a different client service instance. Because IOpaqueKey are binder objects
* that cannot be directly shared between binder rpc clients, this method provide a way to send
* a key to another client. Keys to be imported by the receiver are represented by a token
* created using <code>IOpaqueKey::getShareableToken</code>. The flow to create this token is
* described in <code>IHwCryptoKey::getCurrentDicePolicy</code>.
*
* @param requested_key:
* Handle to the key to be imported to the caller service.
*
* @param sealingDicePolicy:
* DICE policy used to seal the exported key.
*
* @return:
* An IOpaqueKey that can be directly be used on the local HWCrypto service on success.
*
* @throws:
* ServiceSpecificException based on <code>HalErrorCode</code> if any error occurs.
*/
IOpaqueKey keyTokenImport(in OpaqueKeyToken requestedKey, in byte[] sealingDicePolicy);
/*
* Gets the keyslot key material referenced by slotId. This interface is used to access device
* specific keys with known types and uses. Because the returned key is opaque, it can only be
* used through the different HwCrypto interfaces. Because the keys live in a global namespace
* the identity of the caller needs to be checked to verify that it has permission to access the
* requested key.
*
* @param slotId:
* Identifier for the requested keyslot
*
* @return:
* An IOpaqueKey corresponding to the requested key slot on success.
*
* @throws:
* ServiceSpecificException <code>UNAUTHORIZED</code> if the caller cannot access the
* requested key, another specific error based on <code>HalErrorCode</code> otherwise.
*/
IOpaqueKey getKeyslotData(KeySlot slotId);
}

View File

@@ -24,20 +24,25 @@ import android.hardware.security.see.hwcrypto.CryptoOperationSet;
* cryptographic keys. Interactions with this interface are done through a command-base API,
* which allow callers to execute a large set of operations on a single call.
*/
@VintfStability
interface IHwCryptoOperations {
/*
* processCommandList() - Executes a list of cryptographic commands in order
* Executes a list of cryptographic commands in order
*
* @operations:
* @param operations:
* Parameter containing 1 or more set of commands to execute. Additionally, each set can
* also contain a context on which the commands will be executed.
* @additionalErrorInfo:
*
* @param additionalErrorInfo:
* Structure containing additional info when errors are encountered. Only valid if the
* function failed its execution.
* Return:
*
* @return:
* CryptoOperationResult[] on success, which can contain a context to continue executing
* each of the provided operations sets, service specific error based on
* <code>HalErrorCode</code> otherwise.
* each of the provided operations sets.
*
* @throws:
* ServiceSpecificException based on <code>HalErrorCode</code> if any error occurs.
*/
CryptoOperationResult[] processCommandList(inout CryptoOperationSet[] operations,
out CryptoOperationErrorAdditionalInfo additionalErrorInfo);

View File

@@ -20,71 +20,80 @@ import android.hardware.security.see.hwcrypto.types.OpaqueKeyToken;
import android.hardware.security.see.hwcrypto.types.OperationType;
import android.hardware.security.see.hwcrypto.types.ProtectionId;
@VintfStability
interface IOpaqueKey {
/*
* exportWrappedKey() - Exports this key as a wrapped (encrypted) blob.
* Exports this key as a wrapped (encrypted) blob.
*
* @wrapping_key:
* @param wrapping_key:
* wrapping key. It needs to be an opaque key and its policy needs to indicate that it can
* be used for key wrapping.
*
* Return:
* @return:
* Wrapped key blob as a byte array on success. Format of the blob is opaque to the service
* but has to match the command accepted by
* <code>IHwCryptoKeyGeneration::importWrappedKey</code>, service specific error based on
* <code>HalErrorCode</code> otherwise.
* <code>IHwCryptoKeyGeneration::importWrappedKey</code>
*
* @throws:
* ServiceSpecificException based on <code>HalErrorCode</code> if any error occurs.
*/
byte[] exportWrappedKey(in IOpaqueKey wrappingKey);
/*
* getKeyPolicy() - Returns the key policy.
* Returns the key policy.
*
* Return:
* A <code>KeyPolicy</code> on success, service specific error based on
* <code>HalErrorCode</code> otherwise.
* @return:
* A <code>KeyPolicy</code> on success
*
* @throws:
* ServiceSpecificException based on <code>HalErrorCode</code> if any error occurs.
*/
KeyPolicy getKeyPolicy();
/*
* getPublicKey() - Returns the public key portion of this OpaqueKey. This operation is only
* valid for asymmetric keys
* Returns the public key portion of this OpaqueKey. This operation is only valid for asymmetric
* keys.
*
* Return:
* public key as a byte array on success, service specific error based on
* <code>HalErrorCode</code> otherwise. Format used for the returned public key is COSE.
* @return:
* public key as a byte array on success. Format used for the returned public key is COSE.
*
* @throws:
* ServiceSpecificException based on <code>HalErrorCode</code> if any error occurs.
*/
byte[] getPublicKey();
/*
* getShareableToken() - Returns a token that can shared with another HWCrypto client.
* Returns a token that can shared with another HWCrypto client.
*
* @sealingDicePolicy:
* @param sealingDicePolicy:
* Token to be used to protect the returned OpaqueKeyToken. It will be used so only
* the owner of the sealingDicePolicy can import the key.
* Return:
* <code>OpaqueKeyMaterial</code> token on success, service specific error based on
* <code>HalErrorCode</code> otherwise.
*
* @return:
* <code>OpaqueKeyMaterial</code> token on success.
*
* @throws:
* ServiceSpecificException based on <code>HalErrorCode</code> if any error occurs.
*/
OpaqueKeyToken getShareableToken(in byte[] sealingDicePolicy);
/*
* setProtectionId() - Sets the protectionID associated with the buffers where the operation
* will be performed. A protection ID serves as a limitation on the key so
* it can only operate on buffers with a matching protection ID.
* The client calling this functions needs to have the necessary permissions
* to read and/or write to this buffer. Setting this parameter means that
* if the key is shared with a different client, the client receiving the
* key will be limited in which buffers can be used to read/write data for
* this operation.
* Sets the protectionID associated with the buffers where the operation will be performed. A
* protection ID serves as a limitation on the key so it can only operate on buffers with a
* matching protection ID. The client calling this functions needs to have the necessary
* permissions to read and/or write to this buffer. Setting this parameter means that if the key
* is shared with a different client, the client receiving the key will be limited in which
* buffers can be used to read/write data for this operation.
*
* @protectionId:
* @param protectionId:
* ID of the given use case to provide protection for. The method of protecting the buffer
* will be platform dependent.
* @allowedOperations:
*
* @param allowedOperations:
* array of allowed operations. Allowed operations are either READ or WRITE.
*
* Return:
* service specific error based on <code>HalErrorCode</code> on failure.
* @throws:
* ServiceSpecificException based on <code>HalErrorCode</code> if any error occurs.
*/
void setProtectionId(in ProtectionId protectionId, in OperationType[] allowedOperations);
}

View File

@@ -23,6 +23,7 @@ import android.hardware.security.see.hwcrypto.types.KeyUse;
/*
* Parcelable that specified how a key can be used.
*/
@VintfStability
parcelable KeyPolicy {
/*
* Enum specifying the operations the key can perform (encryption, decryption, etc.).

View File

@@ -18,6 +18,7 @@ package android.hardware.security.see.hwcrypto;
/*
* Parcelable representing a memory buffer.
*/
@VintfStability
parcelable MemoryBufferParameter {
union MemoryBuffer {
ParcelFileDescriptor input;

View File

@@ -22,6 +22,7 @@ import android.hardware.security.see.hwcrypto.types.SymmetricOperationParameters
/*
* Type that describes the parameters for the different operations that can be performed.
*/
@VintfStability
union OperationParameters {
/*
* Parameters for authenticated symmetric cryptography (AES GCM).

View File

@@ -18,6 +18,7 @@ package android.hardware.security.see.hwcrypto;
/*
* Parcelable that specifies a pattern to process data.
*/
@VintfStability
parcelable PatternParameters {
/*
* Number of blocks that will be processed. The size of the block matches the size of the

View File

@@ -21,6 +21,7 @@ import android.hardware.security.see.hwcrypto.types.Void;
/*
* Type used for the parameters needed to run a non-authenticated AES operation.
*/
@VintfStability
union AesCipherMode {
/*
* Cipher Block Chaining mode. Padding will either be none or PKCS#7 depending on the key policy

View File

@@ -18,6 +18,7 @@ package android.hardware.security.see.hwcrypto.types;
/*
* Type used for the parameters needed to run an authenticated AES operation (GCM).
*/
@VintfStability
union AesGcmMode {
parcelable AesGcmModeParameters {
/*

View File

@@ -18,6 +18,7 @@ package android.hardware.security.see.hwcrypto.types;
/*
* Type that represents an AES key.
*/
@VintfStability
union AesKey {
/*
* Raw AES 128 bit key material.

View File

@@ -19,6 +19,10 @@ package android.hardware.security.see.hwcrypto.types;
/*
* Type encapsulating nonce used on non-authenticated AES symmetric encryption.
*/
@VintfStability
parcelable CipherModeParameters {
/*
* nonce to be used as IV for AES-CBC or as the nonce in AES-CTR
*/
byte[16] nonce;
}

View File

@@ -21,7 +21,15 @@ import android.hardware.security.see.hwcrypto.types.HmacKey;
/*
* Type encapsulating a clear key.
*/
@VintfStability
union ExplicitKeyMaterial {
/*
* AES key in clear format.
*/
AesKey aes;
/*
* HMAC key in clear format.
*/
HmacKey hmac;
}

View File

@@ -18,6 +18,7 @@ package android.hardware.security.see.hwcrypto.types;
/*
* Service error codes. Will be returned as service specific errors.
*/
@VintfStability
parcelable HalErrorCode {
/* Success */
const int NO_ERROR = 0;

View File

@@ -18,6 +18,7 @@ package android.hardware.security.see.hwcrypto.types;
/*
* Type that represents an Hmac key.
*/
@VintfStability
union HmacKey {
/*
* Raw Hmac key for use with sha256.

View File

@@ -19,6 +19,7 @@ import android.hardware.security.see.hwcrypto.IOpaqueKey;
/*
* Data needed to perform HMAC operations.
*/
@VintfStability
parcelable HmacOperationParameters {
/*
* Key to be used for the HMAC operation.

View File

@@ -20,6 +20,7 @@ package android.hardware.security.see.hwcrypto.types;
* represented as a bitmask to allow us to internally combine them on a single property to describe
* a set of allowed lifetimes.
*/
@VintfStability
@Backing(type="byte")
enum KeyLifetime {
/*

View File

@@ -18,6 +18,7 @@ package android.hardware.security.see.hwcrypto.types;
/*
* Additional characteristics and permissions of the key.
*/
@VintfStability
enum KeyPermissions {
/*
* Key can be wrapped by an ephemeral key.

View File

@@ -0,0 +1,120 @@
/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.security.see.hwcrypto.types;
/*
* Enum describing all supported key types. Key types are strongly bound to the algorithm to
* prevent reusing the same key on different algorithms (e.g. using the same key for 2 different AES
* 128 Cipher modes).
*/
@VintfStability
enum KeyType {
/*
* AES with key size 128 bits using CBC mode of operation and no padding.
*/
AES_128_CBC_NO_PADDING,
/*
* AES with key size 128 bits using CBC mode of operation and PKCS7 padding.
*/
AES_128_CBC_PKCS7_PADDING,
/*
* AES with key size 128 bits using counter mode.
*/
AES_128_CTR,
/*
* AES with key size 128 bits using GCM mode for authenticated encryption.
*/
AES_128_GCM,
/*
* AES with key size 128 bits for CMAC calculation.
*/
AES_128_CMAC,
/*
* AES with key size 256 bits using CBC mode of operation and no padding.
*/
AES_256_CBC_NO_PADDING,
/*
* AES with key size 256 bits using CBC mode of operation and PKCS7 padding.
*/
AES_256_CBC_PKCS7_PADDING,
/*
* AES with key size 128 bits using counter mode.
*/
AES_256_CTR,
/*
* AES with key size 128 bits using GCM mode for authenticated encryption.
*/
AES_256_GCM,
/*
* AES with key size 128 bits for CMAC calculation.
*/
AES_256_CMAC,
/*
* Key of length of 32 bytes for HMAC operations using SHA256.
*/
HMAC_SHA256,
/*
* Key of length of 64 bytes for HMAC operations using SHA512.
*/
HMAC_SHA512,
/*
* RSA of key size of 2048 bits for signing using PSS.
*/
RSA2048_PSS_SHA256,
/*
* RSA of key size of 2048 bits for signing with padding PKCS 1.5 and SHA256 as the digest
* algorithm.
*/
RSA2048_PKCS1_5_SHA256,
/*
* ECC key for signing using curve P-256 and no padding.
*/
ECC_NIST_P256_SIGN_NO_PADDING,
/*
* ECC key for signing using curve P-256 and SHA256 as hashing algorithm.
*/
ECC_NIST_P256_SIGN_SHA256,
/*
* ECC key for signing using curve P-521 and no padding.
*/
ECC_NIST_P521_SIGN_NO_PADDING,
/*
* ECC key for signing using curve P-512 and SHA512 as hashing algorithm.
*/
ECC_NIST_P521_SIGN_SHA512,
/*
* ECC key for signing using EdDSA.
*/
ECC_ED25519_SIGN,
}

View File

@@ -18,12 +18,24 @@ package android.hardware.security.see.hwcrypto.types;
/*
* Enum describing the allowed operations that can be performed with the given key.
*/
@VintfStability
@Backing(type="int")
enum KeyUse {
/* Key can be used to encrypt */
ENCRYPT = 1,
/* Key can be used to decrypt */
DECRYPT = 2,
/* Key can be used to encrypt or decrypt */
ENCRYPT_DECRYPT = ENCRYPT | DECRYPT,
/* Key can be used to sign */
SIGN = 4,
/* Key can be used to derive other keys */
DERIVE = 8,
/* Key can be used to wrap other keys */
WRAP = 16,
}

View File

@@ -18,6 +18,7 @@ package android.hardware.security.see.hwcrypto.types;
/*
* Structure representing a section of a memory buffer.
*/
@VintfStability
@RustDerive(Copy=true, Clone=true)
parcelable MemoryBufferReference {
/*

View File

@@ -20,6 +20,7 @@ package android.hardware.security.see.hwcrypto.types;
* valid on the current boot, and its reuse after a session is closed (or between sessions) is not
* guaranteed.
*/
@VintfStability
parcelable OpaqueKeyToken {
/*
* Opaque type used to send IOpaqueKeys keys to different clients. Its format is implementation

View File

@@ -20,6 +20,7 @@ import android.hardware.security.see.hwcrypto.types.MemoryBufferReference;
/*
* Union holding buffers to be used by the cryptographic operation.
*/
@VintfStability
union OperationData {
/*
* Reference (offset, size) to the active operations' MemoryBuffer.

View File

@@ -18,7 +18,11 @@ package android.hardware.security.see.hwcrypto.types;
/*
* Enum describing the different types of operations allowed on a buffer.
*/
@VintfStability
enum OperationType {
/* Read operations allowed*/
READ,
/* Write operations allowed*/
WRITE,
}

View File

@@ -19,6 +19,7 @@ package android.hardware.security.see.hwcrypto.types;
* Enum describing the different types of protected buffers. Protected buffers are named by its
* corresponding use case and its underlaying implementation is platform dependant.
*/
@VintfStability
enum ProtectionId {
/*
* ProtectionID used by HwCrypto to enable Keys that can be used for Widevine video buffers.

View File

@@ -20,6 +20,7 @@ import android.hardware.security.see.hwcrypto.types.AesGcmMode;
/*
* Data needed to perform authenticated symmetric cryptographic operations.
*/
@VintfStability
union SymmetricAuthCryptoParameters {
/*
* AES (Advanced Encryption Standard) GCM parameters.

View File

@@ -23,6 +23,7 @@ import android.hardware.security.see.hwcrypto.types.SymmetricOperation;
* Parameters needed to perform an authenticated symmetric cryptographic operation. Currently only
* AES-GCM is supported.
*/
@VintfStability
parcelable SymmetricAuthOperationParameters {
/*
* Key to be used on the operation.

View File

@@ -20,6 +20,7 @@ import android.hardware.security.see.hwcrypto.types.AesCipherMode;
/*
* Data needed to perform non-authenticated symmetric cryptographic operations.
*/
@VintfStability
union SymmetricCryptoParameters {
/*
* AES (Advanced Encryption Standard) parameters.

View File

@@ -18,4 +18,4 @@ package android.hardware.security.see.hwcrypto.types;
/*
* Enum describing the type of symmetric operation desired.
*/
enum SymmetricOperation { ENCRYPT, DECRYPT }
@VintfStability enum SymmetricOperation { ENCRYPT, DECRYPT }

View File

@@ -22,6 +22,7 @@ import android.hardware.security.see.hwcrypto.types.SymmetricOperation;
/*
* Parameters needed to perform a non-authenticated symmetric cryptographic operation.
*/
@VintfStability
parcelable SymmetricOperationParameters {
/*
* Key to be used on the operation.

View File

@@ -15,4 +15,8 @@
*/
package android.hardware.security.see.hwcrypto.types;
/*
* Type used to represent no data.
*/
@VintfStability
parcelable Void {}

View File

@@ -1,289 +0,0 @@
/*
* Copyright 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.security.see.hwcrypto;
import android.hardware.security.see.hwcrypto.IHwCryptoOperations;
import android.hardware.security.see.hwcrypto.IOpaqueKey;
import android.hardware.security.see.hwcrypto.KeyPolicy;
import android.hardware.security.see.hwcrypto.types.ExplicitKeyMaterial;
import android.hardware.security.see.hwcrypto.types.OpaqueKeyToken;
/*
* Higher level interface to access and generate keys.
*/
interface IHwCryptoKey {
/*
* Identifier for the requested device provided key. The currently supported identifiers are:
*
* DEVICE_BOUND_KEY:
* This is a key unique to the device.
* BATCH_KEY:
* This is a shared by a set of devices.
*/
enum DeviceKeyId {
DEVICE_BOUND_KEY,
BATCH_KEY,
}
/*
* Identifier for the requested key slot. The currently supported identifiers are:
*
* KEYMINT_SHARED_HMAC_KEY:
* This is the shared HMAC key that will now be computed by HwCryptoKey after participating
* in the ISharedSecret protocol that can be shared with KeyMint and authenticators. See
* ISharedSecret.aidl for more information.
*/
enum KeySlot {
KEYMINT_SHARED_HMAC_KEY,
}
union DiceBoundDerivationKey {
/*
* Opaque to be used to derive the DICE bound key.
*/
IOpaqueKey opaqueKey;
/*
* Device provided key to be used to derive the DICE bound key.
*/
DeviceKeyId keyId;
}
parcelable DiceCurrentBoundKeyResult {
/*
* Key cryptographically bound to a DICE policy.
*/
IOpaqueKey diceBoundKey;
/*
* Current dice policy which was used to generate the returned key. This policy is
* opaque from this service perspective (it will be sent to an Authentication Manager
* Service to be verified). It follows the structure defined on DicePolicy.cddl, located
* under hardware/interfaces/security/authgraph/aidl/android/hardware/security/authgraph/
* with the caveat that it could be encrypted if the client does not have enough permissions
* to see the device dice policy information.
*/
byte[] dicePolicyForKeyVersion;
}
parcelable DiceBoundKeyResult {
/*
* Key cryptographically bound to a DICE policy.
*/
IOpaqueKey diceBoundKey;
/*
* Indicates if the diceBoundKey returned was created using a current DICE policy. The
* caller can use this to detect if an old policy was provided and rotate its keys if so
* desired. Old, valid policies remain usable, but care needs to be taken to not continue to
* use a potentially compromised key.
*/
boolean dicePolicyWasCurrent;
}
parcelable ClearKeyPolicy {
/*
* Indicates the desired key size. It will be used to calculate how many bytes of key
* material should be returned.
*/
int keySizeBytes;
}
union DerivedKeyPolicy {
/*
* If used we will derive a clear key and pass it back as an array of bytes on
* <code>HwCryptoKeyMaterial::explicitKey</code>.
*/
ClearKeyPolicy clearKey;
/*
* Policy for the newly derived opaque key. Defines how the key can be used and its type.
*/
byte[] opaqueKey;
}
parcelable DerivedKeyParameters {
/*
* Key to be used to derive the new key using HKDF.
*/
IOpaqueKey derivationKey;
/*
* Policy for the newly derived key. Depending on its type, either a clear or opaque key
* will be derived.
*/
DerivedKeyPolicy keyPolicy;
/*
* An arbitrary set of bytes incorporated into the key derivation. May have
* an implementation-specific maximum length, but it is guaranteed to accept
* at least 32 bytes.
*/
byte[] context;
}
union DerivedKey {
/*
* Derived key in clear format.
*/
byte[] explicitKey = {};
/*
* Derived key as a key token to be used only through the HWCrypto service.
*/
IOpaqueKey opaque;
}
/*
* deriveCurrentDicePolicyBoundKey() - Derives a versioned key tied to the caller's current DICE
* policy. It will return this current policy back to the caller
* along with the generated key.
*
* @derivationKey:
* Key to be used to derive the new key using HKDF.
*
* Return:
* Ok(DiceCurrentBoundKeyResult) on success, service specific error based on
* <code>HalErrorCode</code> otherwise.
*/
DiceCurrentBoundKeyResult deriveCurrentDicePolicyBoundKey(
in DiceBoundDerivationKey derivationKey);
/*
* deriveDicePolicyBoundKey() - Derive a versioned key by checking the provided DICE policy
* against the caller and then using it as a context for deriving
* the returned key.
*
* @derivationKey:
* Key to be used to derive the new key using HKDF.
*
* @dicePolicyForKeyVersion:
* Policy used to derive keys tied to specific versions. Using this parameter
* the caller can tie a derived key to a minimum version of itself, so in the future only
* itself or a more recent version can derive the same key. This parameter is opaque to the
* caller and it could be encrypted in the case the client doesn't have permission to know
* the dice chain.
* When implementing this function, this parameter shall be one of the components fed
* to the KDF context and it needs to be checked against the caller DICE certificate before
* being used.
*
* Return:
* Ok(DiceBoundKeyResult) on success, service specific error based on
* <code>HalErrorCode</code> otherwise.
*/
DiceBoundKeyResult deriveDicePolicyBoundKey(
in DiceBoundDerivationKey derivationKey, in byte[] dicePolicyForKeyVersion);
/*
* deriveKey() - Derive a new key based on the given key, policy and context.
*
* @parameters:
* Parameters used for the key derivation. See <code>DerivedKeyParameters</code> on this
* file for more information.
*
* Return:
* Ok(HwCryptoKeyMaterial) on success, service specific error based on
* <code>HalErrorCode</code> otherwise.
*/
DerivedKey deriveKey(in DerivedKeyParameters parameters);
/*
* getHwCryptoOperations() - Returns an interface used to work on opaque keys. This interface
* can also be used to operate on any opaque key generated by
* hwkeyDeriveVersioned, even if this key has been generated after
* retrieving a IHwCryptoOperations binder object, as long as the
* parent IHwCryptoDeviceKeyAccess is not dropped between retrieving
* the IHwCryptoOperations binder object and deriving the key.
* IHwCryptoOperations can also be used to create opaque keys that
* are not bound to the device.
*
* Return:
* IHwCryptoOperations on success
*/
IHwCryptoOperations getHwCryptoOperations();
/*
* importClearKey() - Imports a SW clear key into the secure environment.
*
* @keyMaterial:
* key to be imported.
* @newKeyPolicy:
* Policy of the new key. Defines how the newly created key can be used. Because any
* clear key imported into the system is considered to have a
* <code>KeyLifetime::PORTABLE</code> lifetime, a call to this function will return an
* error if <code>newKeyPolicy.newKeyPolicy</code> is not set to portable.
*
* Return:
* IOpaqueKey on success, service specific error based on <code>HalErrorCode</code>
* otherwise.
*/
IOpaqueKey importClearKey(in ExplicitKeyMaterial keyMaterial, in KeyPolicy newKeyPolicy);
/*
* getCurrentDicePolicy() - Returns the client current DICE policy. This policy is encrypted and
* considered opaque from the client perspective. This policy is the
* same used to create DICE bound keys and will also be used to seal
* secrets that can only be retrieved by the DICE policy owner. The
* first use of this seal operation will be
* <code>IOpaqueKey::getShareableToken</code> and
* <code>IHwCryptoKey::keyTokenImport</code>. To start this process,
* the intended key receiver will call this function and then pass the
* generated DICE policy to the owner of the key that the receiver
* wants to import. The key owner will then call
* <code>IOpaqueKey::getShareableToken</code> passing the receiver DICE
* policy to insure that only that receiver can import the key.
*
* Return:
* byte[] on success, which is the caller encrypted DICE policy.
*/
byte[] getCurrentDicePolicy();
/*
* key_token_import() - Imports a key from a different client service instance. Because
* IOpaqueKey are binder objects that cannot be directly shared between
* binder rpc clients, this method provide a way to send a key to another
* client. Keys to be imported by the receiver are represented by a token
* created using <code>IOpaqueKey::getShareableToken</code>. The flow
* to create this token is described in
* <code>IHwCryptoKey::getCurrentDicePolicy</code>.
*
* @requested_key:
* Handle to the key to be imported to the caller service.
* @sealingDicePolicy:
* DICE policy used to seal the exported key.
* Return:
* A IOpaqueKey that can be directly be used on the local HWCrypto service on
* success, service specific error based on <code>HalErrorCode</code> otherwise.
*/
IOpaqueKey keyTokenImport(in OpaqueKeyToken requestedKey, in byte[] sealingDicePolicy);
/*
* getKeyslotData() - Gets the keyslot key material referenced by slotId.
*
* @slotId:
* Identifier for the requested keyslot
*
* This interface is used to access device specific keys with known types and uses. Because the
* returned key is opaque, it can only be used through the different HwCrypto interfaces.
* Because the keys live in a global namespace the identity of the caller needs to be
* checked to verify that it has permission to accesses the requested key.
*
* Return:
* Ok(IOpaqueKey) on success, UNAUTHORIZED if the caller cannot access the requested key,
* another specific error code otherwise.
*/
IOpaqueKey getKeyslotData(KeySlot slotId);
}

View File

@@ -1,43 +0,0 @@
/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.security.see.hwcrypto.types;
/*
* Enum describing all supported key types. Key types are strongly bound to the algorithm to
* prevent reusing the same key on different algorithms (e.g. using the same key for 2 different AES
* 128 Cipher modes).
*/
enum KeyType {
AES_128_CBC_NO_PADDING,
AES_128_CBC_PKCS7_PADDING,
AES_128_CTR,
AES_128_GCM,
AES_128_CMAC,
AES_256_CBC_NO_PADDING,
AES_256_CBC_PKCS7_PADDING,
AES_256_CTR,
AES_256_GCM,
AES_256_CMAC,
HMAC_SHA256,
HMAC_SHA512,
RSA2048_PSS_SHA256,
RSA2048_PKCS1_5_SHA256,
ECC_NIST_P256_SIGN_NO_PADDING,
ECC_NIST_P256_SIGN_SHA256,
ECC_NIST_P521_SIGN_NO_PADDING,
ECC_NIST_P521_SIGN_SHA512,
ECC_ED25519_SIGN,
}