nl::Weave::Profiles::Security::密码

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

摘要

枚举

@278{
  kPasscode_Config1_TEST_ONLY = 0x01,
  kPasscode_Config2 = 0x02,
  kPasscodeConfig1_KeyId = WeaveKeyId::kNone
}
枚举
编织密码加密配置类型。
@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 Passcode 加密方案加密密码。
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 Passcode 加密方案加密密码。
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::Password:::EncryptedPasscodeStruct

枚举

278 @

 @278

编织密码加密配置类型。

属性
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 和 AK”短语的 SHA-1 HASH 的前 4 个字节。

kPasscodeFingerprintKeyDiversifier

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

用于计算 Weave 密码加密密钥的密钥密钥分流器。

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

函数

解密密码

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 返回的其他针对特定平台的错误。

解密密码

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
加密的密码太短或太长。

加密密码

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 Passcode 加密方案加密密码。

详细信息
参数
[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 返回的其他针对特定平台的错误。

加密密码

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 Passcode 加密方案加密密码。

详细信息
参数
[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。