nl::Weave::Profiles::Security::Passcodes

此命名空间包含 Weave 内用于 Weave 安全配置文件中的 Weave 密码库的所有接口。

摘要

枚举

@278{
  kPasscode_Config1_TEST_ONLY = 0x01,
  kPasscode_Config2 = 0x02,
  kPasscodeConfig1_KeyId = WeaveKeyId::kNone
}
枚举
Weave 密码加密配置类型。
@279{
  kPasscodeEncryptionKeyLen = Platform::Security::AES128BlockCipher::kKeyLength,
  kPasscodeAuthenticationKeyLen = Platform::Security::SHA1::kHashLength,
  kPasscodeFingerprintKeyLen = Platform::Security::SHA1::kHashLength,
  kPasscodeTotalDerivedKeyLen = kPasscodeEncryptionKeyLen + kPasscodeAuthenticationKeyLen,
  kPasscodePaddedLen = Platform::Security::AES128BlockCipher::kBlockLength,
  kPasscodeAuthenticatorLen = 8,
  kPasscodeFingerprintLen = 8,
  kPasscodeMaxEncryptedLen = sizeof(uint8_t) + 2 * sizeof(uint32_t) + kPasscodePaddedLen + kPasscodeAuthenticatorLen + kPasscodeFingerprintLen,
  kPasscodeMaxLen = kPasscodePaddedLen,
  kPasscodeEncKeyDiversifierSize = sizeof(kPasscodeEncKeyDiversifier) + sizeof(uint8_t),
  kPasscodeFingerprintKeyDiversifierSize = sizeof(kPasscodeFingerprintKeyDiversifier)
}
枚举
Weave 密码加密协议的参数大小。

变量

kPasscodeEncKeyDiversifier = { 0x1A, 0x65, 0x5D, 0x96 }[]
const uint8_t
用于 Weave 密码加密密钥派生的密钥多样化器。
kPasscodeFingerprintKeyDiversifier = { 0xD1, 0xA1, 0xD9, 0x6C }[]
const uint8_t
用于 Weave 密码加密密钥派生的密钥多样化器。

函数

DecryptPasscode(const uint8_t *encPasscode, size_t encPasscodeLen, uint8_t *passcodeBuf, size_t passcodeBufSize, size_t & passcodeLen, GroupKeyStoreBase *groupKeyStore)
解密使用 Nest Passcode 加密方案加密的密码。
DecryptPasscode(const uint8_t *encPasscode, size_t encPasscodeLen, const uint8_t *encKey, const uint8_t *authKey, const uint8_t *fingerprintKey, uint8_t *passcodeBuf, size_t passcodeBufSize, size_t & passcodeLen)
解密使用 Nest Passcode 加密方案加密的密码。
EncryptPasscode(uint8_t config, uint32_t keyId, uint32_t nonce, const uint8_t *passcode, size_t passcodeLen, uint8_t *encPasscode, size_t encPasscodeBufSize, size_t & encPasscodeLen, GroupKeyStoreBase *groupKeyStore)
使用 Nest 密码加密方案对密码进行加密。
EncryptPasscode(uint8_t config, uint32_t keyId, uint32_t nonce, const uint8_t *passcode, size_t passcodeLen, const uint8_t *encKey, const uint8_t *authKey, const uint8_t *fingerprintKey, uint8_t *encPasscode, size_t encPasscodeBufSize, size_t & encPasscodeLen)
使用 Nest 密码加密方案对密码进行加密。
GetEncryptedPasscodeConfig(const uint8_t *encPasscode, size_t encPasscodeLen, uint8_t & config)
获取加密密码的配置类型。
GetEncryptedPasscodeFingerprint(const uint8_t *encPasscode, size_t encPasscodeLen, uint8_t *fingerprintBuf, size_t fingerprintBufSize, size_t & fingerprintLen)
获取与加密密码相关联的指纹值。
GetEncryptedPasscodeKeyId(const uint8_t *encPasscode, size_t encPasscodeLen, uint32_t & keyId)
获取用于加密加密密码的密钥的 ID。
GetEncryptedPasscodeNonce(const uint8_t *encPasscode, size_t encPasscodeLen, uint32_t & nonce)
获取与加密密码关联的 Nonce 值。
IsSupportedPasscodeEncryptionConfig(uint8_t config)
bool
如果密码加密/解密 API 支持所提供的密码加密配置,则返回 true。

结构体

nl::Weave::Profiles::Security::Passcodes::EncryptedPasscodeStruct

枚举

@278

 @278

Weave 密码加密配置类型。

属性
kPasscodeConfig1_KeyId

用于测试密码配置 1 的虚拟密钥 ID。

kPasscode_Config1_TEST_ONLY

密码加密配置 #1 未使用加密和私钥进行身份验证和指纹密码。

此配置应仅用于测试目的。

kPasscode_Config2

密码加密配置 #2 使用的是采用 8 字节 HMAC-SHA-1 完整性和 8 字节 HMAC-SHA-1 指纹的 AES-128-ECB 加密。

@279

 @279

Weave 密码加密协议的参数大小。

属性
kPasscodeAuthenticationKeyLen

密码身份验证 (SHA-1) 密钥长度。

kPasscodeAuthenticatorLen

密码身份验证器长度。

kPasscodeEncKeyDiversifierSize

密码加密应用密钥多样化器大小。

kPasscodeEncryptionKeyLen

密码加密 (AES-128) 密钥长度。

kPasscodeFingerprintKeyDiversifierSize

密码指纹密钥分隔符尺寸。

kPasscodeFingerprintKeyLen

密码指纹 (SHA-1) 密钥长度。

kPasscodeFingerprintLen

密码指纹长度。

kPasscodeMaxEncryptedLen

加密密码长度上限。

kPasscodeMaxLen

未加密密码长度上限。

kPasscodePaddedLen

密码长度(填充到 AES-128 分块长度中)。

kPasscodeTotalDerivedKeyLen

密码总(加密和完整性)密钥长度。

变量

kPasscodeEncKeyDiversifier

const uint8_t kPasscodeEncKeyDiversifier[] = { 0x1A, 0x65, 0x5D, 0x96 }

用于 Weave 密码加密密钥派生的密钥多样化器。

此值表示“Nest Passcode EK and AK”短语的 SHA-1 HASH 的前 4 个字节。

kPasscodeFingerprintKeyDiversifier

const uint8_t kPasscodeFingerprintKeyDiversifier[] = { 0xD1, 0xA1, 0xD9, 0x6C }

用于 Weave 密码加密密钥派生的密钥多样化器。

此值表示“Nest Passcode EK and AK”短语的 SHA-1 HASH 的前 4 个字节。

函数

DecryptPasscode

WEAVE_ERROR DecryptPasscode(
  const uint8_t *encPasscode,
  size_t encPasscodeLen,
  uint8_t *passcodeBuf,
  size_t passcodeBufSize,
  size_t & passcodeLen,
  GroupKeyStoreBase *groupKeyStore
)

解密使用 Nest Passcode 加密方案加密的密码。

具体说明
参数
[in] encPasscode
指向加密密码缓冲区的指针。
[in] encPasscodeLen
加密密码长度。
[in] passcodeBuf
指向用于接收解密密码的缓冲区的指针。
[in] passcodeBufSize
passcodeBuf 所指向的缓冲区的大小。
[out] passcodeLen
设为解密后的密码长度。
[in] groupKeyStore
指向组密钥库对象的指针。
返回值
WEAVE_NO_ERROR
成功时。
WEAVE_ERROR_UNSUPPORTED_PASSCODE_CONFIG
如果指定的密码配置不受支持。
WEAVE_ERROR_PASSCODE_AUTHENTICATION_FAILED
如果密码身份验证失败。
WEAVE_ERROR_PASSCODE_FINGERPRINT_FAILED
如果密码指纹检查失败。
WEAVE_ERROR_INVALID_KEY_ID
如果所请求的密钥包含无效的密钥 ID。
WEAVE_ERROR_BUFFER_TOO_SMALL
如果提供的密码缓冲区过小。
WEAVE_ERROR_INVALID_ARGUMENT
加密的密码太短或过长;或者未提供指向群组密钥库的指针或平台密钥库返回无效的键参数。
other
由平台密钥库 API 返回的其他平台特定错误。

DecryptPasscode

WEAVE_ERROR DecryptPasscode(
  const uint8_t *encPasscode,
  size_t encPasscodeLen,
  const uint8_t *encKey,
  const uint8_t *authKey,
  const uint8_t *fingerprintKey,
  uint8_t *passcodeBuf,
  size_t passcodeBufSize,
  size_t & passcodeLen
)

解密使用 Nest Passcode 加密方案加密的密码。

具体说明
参数
[in] encPasscode
指向加密密码缓冲区的指针。
[in] encPasscodeLen
加密密码长度。
[in] encKey
指向要用于加密密码的密钥的指针。密钥的长度必须与指定配置相关联的加密算法相符。
[in] authKey
指向用于对密码进行身份验证的密钥的指针。密钥的长度必须与指定配置相关联的身份验证算法相符。
[in] fingerprintKey
指向要用于生成密码指纹的密钥的指针。密钥的长度必须与指定配置所关联的指纹算法相符。
[in] passcodeBuf
指向用于接收解密密码的缓冲区的指针。
[in] passcodeBufSize
passcodeBuf 所指向的缓冲区的大小。
[out] passcodeLen
设为解密后的密码长度。
返回值
WEAVE_NO_ERROR
成功时。
WEAVE_ERROR_UNSUPPORTED_PASSCODE_CONFIG
如果指定的密码配置不受支持。
WEAVE_ERROR_PASSCODE_AUTHENTICATION_FAILED
如果密码身份验证失败。
WEAVE_ERROR_PASSCODE_FINGERPRINT_FAILED
如果密码指纹检查失败。
WEAVE_ERROR_BUFFER_TOO_SMALL
如果提供的密码缓冲区过小。
WEAVE_ERROR_INVALID_ARGUMENT
加密的密码太短或太长。

EncryptPasscode

WEAVE_ERROR EncryptPasscode(
  uint8_t config,
  uint32_t keyId,
  uint32_t nonce,
  const uint8_t *passcode,
  size_t passcodeLen,
  uint8_t *encPasscode,
  size_t encPasscodeBufSize,
  size_t & encPasscodeLen,
  GroupKeyStoreBase *groupKeyStore
)

使用 Nest 密码加密方案对密码进行加密。

具体说明
参数
[in] config
要使用的密码加密配置。
[in] keyId
请求的密码加密密钥 ID。
[in] nonce
分配给加密密码的唯一值。
[in] passcode
指向要加密的密码的指针。
[in] passcodeLen
密码长度。
[out] encPasscode
指向用于存储加密密码的缓冲区的指针。
[in] encPasscodeBufSize
用于加密密码存储的缓冲区大小。
[out] encPasscodeLen
加密密码长度。
[in] groupKeyStore
指向组密钥库对象的指针。
返回值
WEAVE_NO_ERROR
成功时。
WEAVE_ERROR_UNSUPPORTED_PASSCODE_CONFIG
如果指定的密码配置不受支持。
WEAVE_ERROR_BUFFER_TOO_SMALL
如果提供的输出缓冲区对于加密密码来说过小。
WEAVE_ERROR_INVALID_KEY_ID
如果所请求的密钥包含无效的密钥 ID。
WEAVE_ERROR_INVALID_ARGUMENT
如果提供的密码过短或过长;或者未提供指向组密钥库的指针,或平台密钥库返回无效的键参数。
other
由平台密钥库 API 返回的其他平台特定错误。

EncryptPasscode

WEAVE_ERROR EncryptPasscode(
  uint8_t config,
  uint32_t keyId,
  uint32_t nonce,
  const uint8_t *passcode,
  size_t passcodeLen,
  const uint8_t *encKey,
  const uint8_t *authKey,
  const uint8_t *fingerprintKey,
  uint8_t *encPasscode,
  size_t encPasscodeBufSize,
  size_t & encPasscodeLen
)

使用 Nest 密码加密方案对密码进行加密。

具体说明
参数
[in] config
要使用的 Weave 密码加密配置。
[in] keyId
请求的密码加密密钥 ID。
[in] nonce
分配给密码的唯一值。
[in] passcode
指向要加密的密码的指针。
[in] passcodeLen
密码长度。
[in] encKey
指向要用于加密密码的密钥的指针。密钥的长度必须与指定配置相关联的加密算法相符。
[in] authKey
指向用于对密码进行身份验证的密钥的指针。密钥的长度必须与指定配置相关联的身份验证算法相符。
[in] fingerprintKey
指向要用于生成密码指纹的密钥的指针。密钥的长度必须与指定配置所关联的指纹算法相符。
[out] encPasscode
指向将存储加密密码的缓冲区的指针。此缓冲区的大小必须至少为 kPasscodeMaxEncryptedLen。
[in] encPasscodeBufSize
encPasscode 所指向的缓冲区的大小。
[out] encPasscodeLen
加密密码长度。
返回值
WEAVE_NO_ERROR
成功时。
WEAVE_ERROR_UNSUPPORTED_PASSCODE_CONFIG
如果指定的密码配置不受支持。
WEAVE_ERROR_BUFFER_TOO_SMALL
如果提供的输出缓冲区对于加密密码来说过小。
WEAVE_ERROR_INVALID_ARGUMENT
如果提供的密码过短或过长。

GetEncryptedPasscodeConfig

WEAVE_ERROR GetEncryptedPasscodeConfig(
  const uint8_t *encPasscode,
  size_t encPasscodeLen,
  uint8_t & config
)

获取加密密码的配置类型。

具体说明
参数
[in] encPasscode
指向包含加密密码的缓冲区的指针。
[in] encPasscodeLen
加密密码的长度。
[out] config
加密密码使用的 Weave 密码加密配置。

GetEncryptedPasscodeFingerprint

WEAVE_ERROR GetEncryptedPasscodeFingerprint(
  const uint8_t *encPasscode,
  size_t encPasscodeLen,
  uint8_t *fingerprintBuf,
  size_t fingerprintBufSize,
  size_t & fingerprintLen
)

获取与加密密码相关联的指纹值。

具体说明
参数
[in] encPasscode
指向包含加密密码的缓冲区的指针。
[in] encPasscodeLen
加密密码的长度。
[in] fingerprintBuf
用于接收指纹值的缓冲区。
[in] fingerprintBufSize
由 FingerprintBuf 所指向的缓冲区的大小。
[out] fingerprintLen
返回的指纹值的长度。

GetEncryptedPasscodeKeyId

WEAVE_ERROR GetEncryptedPasscodeKeyId(
  const uint8_t *encPasscode,
  size_t encPasscodeLen,
  uint32_t & keyId
)

获取用于加密加密密码的密钥的 ID。

具体说明
参数
[in] encPasscode
指向包含加密密码的缓冲区的指针。
[in] encPasscodeLen
加密密码的长度。
[out] keyId
用于加密加密密码的密钥的 ID。

GetEncryptedPasscodeNonce

WEAVE_ERROR GetEncryptedPasscodeNonce(
  const uint8_t *encPasscode,
  size_t encPasscodeLen,
  uint32_t & nonce
)

获取与加密密码关联的 Nonce 值。

具体说明
参数
[in] encPasscode
指向包含加密密码的缓冲区的指针。
[in] encPasscodeLen
加密密码的长度。
[out] nonce
与加密密码相关联的 Nonce 值。

IsSupportedPasscodeEncryptionConfig

bool IsSupportedPasscodeEncryptionConfig(
  uint8_t config
)

如果密码加密/解密 API 支持所提供的密码加密配置,则返回 true。