nl::Weave::Crypto

この名前空間には、共有暗号をサポートする Weave 内のすべてのインターフェースが含まれます。

概要

列挙型

X963EncodedPointFormat enum

Typedef

AES128CTRDRBG typedef
AES128CTRMode typedef
AES256CTRMode typedef
EntropyFunct)(uint8_t *buf, size_t bufSize) typedef
int(*
エントロピー ソースからランダム データを収集するために使用される関数のシグネチャ。
HKDFSHA1 typedef
HKDFSHA256 typedef
HMACSHA1 typedef
HMACSHA256 typedef

関数

ClearSecretData(uint8_t *buf, uint32_t len)
NL_DLL_EXPORT void
メモリ領域 buf の最初の len バイトをクリアします。
ConstantTimeCompare(const uint8_t *buf1, const uint8_t *buf2, uint16_t len)
bool
メモリ領域 buf1 とメモリ領域 buf2 の最初の len バイトを比較します。
DecodeBIGNUMValueLE(BIGNUM & val, uint16_t size, const uint8_t *& p)
DecodeECDSASignature(const EncodedECDSASignature & encodedSig, ECDSA_SIG *& sig)
DecodeECKey(OID curveOID, const EncodedECPrivateKey *encodedPrivKey, const EncodedECPublicKey *encodedPubKey, EC_KEY *& ecKey)
NL_DLL_EXPORT WEAVE_ERROR
DecodeX962ECPoint(const uint8_t *encodedPoint, uint16_t encodedPointLen, EC_GROUP *group, EC_POINT *& point)
NL_DLL_EXPORT WEAVE_ERROR
DecodeX962ECPoint(const uint8_t *encodedPoint, uint16_t encodedPointLen, BIGNUM *& x, BIGNUM *& y)
ECDHComputeSharedSecret(OID curveOID, const EC_GROUP *ecGroup, const EC_POINT *pubKeyPoint, const BIGNUM *privKeyBN, uint8_t *sharedSecretBuf, uint16_t sharedSecretBufSize, uint16_t & sharedSecretLen)
NL_DLL_EXPORT WEAVE_ERROR
ECDHComputeSharedSecret(OID curveOID, const EncodedECPublicKey & encodedPubKey, const EncodedECPrivateKey & encodedPrivKey, uint8_t *sharedSecretBuf, uint16_t sharedSecretBufSize, uint16_t & sharedSecretLen)
ECDSASigToFixedLenSig(OID curveOID, const ECDSA_SIG *ecSig, uint8_t *fixedLenSig)
ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps)
void
ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s)
int
EncodeBIGNUMValueLE(const BIGNUM & val, uint16_t size, uint8_t *& p)
EncodeECDSASignature(const ECDSA_SIG *sig, EncodedECDSASignature & encodedSig)
EncodeX962ECPoint(OID curveOID, EC_GROUP *ecGroup, const EC_POINT *point, uint8_t *buf, uint16_t bufSize, uint16_t & encodedPointLen)
NL_DLL_EXPORT WEAVE_ERROR
FixedLenSigToECDSASig(OID curveOID, const uint8_t *fixedLenSig, ECDSA_SIG *& ecSig)
GenerateAndEncodeWeaveHMACSignature(OID sigAlgoOID, TLVWriter & writer, uint64_t tag, const uint8_t *data, uint16_t dataLen, const uint8_t *key, uint16_t keyLen)
Weave の HMAC 署名を生成してエンコードします。
GenerateAndEncodeWeaveRSASignature(OID sigAlgoOID, TLVWriter & writer, uint64_t tag, const uint8_t *hash, uint8_t hashLen, const uint8_t *keyDER, uint16_t keyDERLen)
Weave の RSA 署名を生成してエンコードする。
GenerateECDHKey(OID curveOID, EncodedECPublicKey & encodedPubKey, EncodedECPrivateKey & encodedPrivKey)
GenerateECDSASignature(OID curveOID, const uint8_t *msgHash, uint8_t msgHashLen, const EncodedECPrivateKey & encodedPrivKey, EncodedECDSASignature & encodedSig)
GenerateECDSASignature(OID curveOID, const uint8_t *msgHash, uint8_t msgHashLen, const EncodedECPrivateKey & encodedPrivKey, uint8_t *fixedLenSig)
GetCurveG(OID curveOID, EncodedECPublicKey & encodedPubKey)
GetCurveSize(const OID curveOID, const EC_GROUP *ecGroup)
int
GetCurveSize(const OID curveOID)
int
楕円曲線のサイズ(バイト単位)を取得します。
GetECGroupForCurve(OID curveOID, EC_GROUP *& ecGroup)
NL_DLL_EXPORT WEAVE_ERROR
ReverseBytes(uint8_t *buf, size_t len)
void
ShaNIDFromSigAlgoOID(OID sigAlgoOID)
int
VerifyECDSASignature(OID curveOID, const uint8_t *msgHash, uint8_t msgHashLen, const EncodedECDSASignature & encodedSig, const EncodedECPublicKey & encodedPubKey)
VerifyECDSASignature(OID curveOID, const uint8_t *msgHash, uint8_t msgHashLen, const uint8_t *fixedLenSig, const EncodedECPublicKey & encodedPubKey)
VerifyHMACSignature(OID sigAlgoOID, const uint8_t *data, uint16_t dataLen, const EncodedHMACSignature & sig, const uint8_t *key, uint16_t keyLen)
Weave の HMAC 署名を検証します。
VerifyRSASignature(OID sigAlgoOID, const uint8_t *hash, uint8_t hashLen, const EncodedRSASignature & sig, const uint8_t *certDER, uint16_t certDERLen)
Weave の RSA 署名を検証します。

クラス

nl::Weave::Crypto::CTRMode
nl::Weave::Crypto::CTR_DRBG
nl::Weave::Crypto::EncodedECDSASignature
nl::Weave::Crypto::EncodedECPrivateKey
nl::Weave::Crypto::EncodedECPublicKey
nl::Weave::Crypto::EncodedHMACSignature
nl::Weave::Crypto::EncodedRSAKey
nl::Weave::Crypto::EncodedRSASignature
nl::Weave::Crypto::HKDF
nl::Weave::Crypto::HKDFSHA1Or256
nl::Weave::Crypto::HMAC

列挙型

X963EncodedPointFormat

 X963EncodedPointFormat

Typedef

AES128CTRDRBG

CTR_DRBG< Platform::Security::AES128BlockCipherEnc > AES128CTRDRBG

AES128CTRMode

CTRMode< Platform::Security::AES128BlockCipherEnc > AES128CTRMode

AES256CTRMode

CTRMode< Platform::Security::AES256BlockCipherEnc > AES256CTRMode

EntropyFunct

int(* EntropyFunct)(uint8_t *buf, size_t bufSize)

エントロピー ソースからランダム データを収集するために使用される関数のシグネチャ。

HKDFSHA1

HKDF< Platform::Security::SHA1 > HKDFSHA1

HKDFSHA256

HKDF< Platform::Security::SHA256 > HKDFSHA256

HMACSHA1

HMAC< Platform::Security::SHA1 > HMACSHA1

HMACSHA256

HMAC< Platform::Security::SHA256 > HMACSHA256

関数

ClearSecretData

NL_DLL_EXPORT void ClearSecretData(
  uint8_t *buf,
  uint32_t len
)

メモリ領域 buf の最初の len バイトをクリアします。

この実装では、メモリ領域 buf の最初の len バイトにゼロが埋め込まれます。

詳細
パラメータ
[in] buf
クリアする必要があるシークレット データを保持するメモリバッファへのポインタ。
[in] len
シークレット データのサイズをバイト単位で指定します。

ConstantTimeCompare

bool ConstantTimeCompare(
  const uint8_t *buf1,
  const uint8_t *buf2,
  uint16_t len
)

メモリ領域 buf1 とメモリ領域 buf2 の最初の len バイトを比較します。

この関数の所要時間は、メモリ領域 buf1buf2 のデータに依存しません。

詳細
パラメータ
[in] buf1
メモリブロックへのポインタ。
[in] buf2
メモリブロックへのポインタ。
[in] len
比較するメモリ領域のサイズ(バイト単位)。
戻り値
true
メモリ領域 buf1buf2 の最初の len バイトが等しい場合。
false
一致しない場合。

DecodeBIGNUMValueLE

WEAVE_ERROR DecodeBIGNUMValueLE(
  BIGNUM & val,
  uint16_t size,
  const uint8_t *& p
)

DecodeECDSASignature

WEAVE_ERROR DecodeECDSASignature(
  const EncodedECDSASignature & encodedSig,
  ECDSA_SIG *& sig
)

DecodeECKey

NL_DLL_EXPORT WEAVE_ERROR DecodeECKey(
  OID curveOID,
  const EncodedECPrivateKey *encodedPrivKey,
  const EncodedECPublicKey *encodedPubKey,
  EC_KEY *& ecKey
)

DecodeX962ECPoint

NL_DLL_EXPORT WEAVE_ERROR DecodeX962ECPoint(
  const uint8_t *encodedPoint,
  uint16_t encodedPointLen,
  EC_GROUP *group,
  EC_POINT *& point
)

DecodeX962ECPoint

WEAVE_ERROR DecodeX962ECPoint(
  const uint8_t *encodedPoint,
  uint16_t encodedPointLen,
  BIGNUM *& x,
  BIGNUM *& y
)

ECDHComputeSharedSecret

NL_DLL_EXPORT WEAVE_ERROR ECDHComputeSharedSecret(
  OID curveOID,
  const EC_GROUP *ecGroup,
  const EC_POINT *pubKeyPoint,
  const BIGNUM *privKeyBN,
  uint8_t *sharedSecretBuf,
  uint16_t sharedSecretBufSize,
  uint16_t & sharedSecretLen
)

ECDHComputeSharedSecret

WEAVE_ERROR ECDHComputeSharedSecret(
  OID curveOID,
  const EncodedECPublicKey & encodedPubKey,
  const EncodedECPrivateKey & encodedPrivKey,
  uint8_t *sharedSecretBuf,
  uint16_t sharedSecretBufSize,
  uint16_t & sharedSecretLen
)

ECDSASigToFixedLenSig

WEAVE_ERROR ECDSASigToFixedLenSig(
  OID curveOID,
  const ECDSA_SIG *ecSig,
  uint8_t *fixedLenSig
)

ECDSA_SIG_get0

void ECDSA_SIG_get0(
  const ECDSA_SIG *sig,
  const BIGNUM **pr,
  const BIGNUM **ps
)

ECDSA_SIG_set0

int ECDSA_SIG_set0(
  ECDSA_SIG *sig,
  BIGNUM *r,
  BIGNUM *s
)

EncodeBIGNUMValueLE

WEAVE_ERROR EncodeBIGNUMValueLE(
  const BIGNUM & val,
  uint16_t size,
  uint8_t *& p
)

EncodeECDSASignature

WEAVE_ERROR EncodeECDSASignature(
  const ECDSA_SIG *sig,
  EncodedECDSASignature & encodedSig
)

EncodeX962ECPoint

NL_DLL_EXPORT WEAVE_ERROR EncodeX962ECPoint(
  OID curveOID,
  EC_GROUP *ecGroup,
  const EC_POINT *point,
  uint8_t *buf,
  uint16_t bufSize,
  uint16_t & encodedPointLen
)

FixedLenSigToECDSASig

WEAVE_ERROR FixedLenSigToECDSASig(
  OID curveOID,
  const uint8_t *fixedLenSig,
  ECDSA_SIG *& ecSig
)

GenerateAndEncodeWeaveHMACSignature

WEAVE_ERROR GenerateAndEncodeWeaveHMACSignature(
  OID sigAlgoOID,
  TLVWriter & writer,
  uint64_t tag,
  const uint8_t *data,
  uint16_t dataLen,
  const uint8_t *key,
  uint16_t keyLen
)

Weave の HMAC 署名を生成してエンコードします。

秘密鍵を使用して特定のデータの HMAC 署名を計算し、その署名を Weave HMACSignature 構造として、指定されたタグを使用して指定された TLV ライターに書き込みます。

詳細
パラメータ
[in] sigAlgoOID
HMAC 署名の生成に使用されるアルゴリズム OID。
[in] writer
エンコードされた署名を書き込む TLVWriter オブジェクト。
[in] tag
エンコードされた署名構造に関連付ける TLV タグ。
[in] data
署名されるデータを含むバッファ。
[in] dataLen
データの長さ(バイト単位)。
[in] key
HMAC 署名の生成に使用される秘密鍵を含むバッファ。
[in] keyLen
秘密鍵の長さ(バイト単位)。
戻り値
WEAVE_NO_ERROR
オペレーションが成功したかどうか。
other
署名エンコードに関連するその他の Weave エラーコード。

GenerateAndEncodeWeaveRSASignature

WEAVE_ERROR GenerateAndEncodeWeaveRSASignature(
  OID sigAlgoOID,
  TLVWriter & writer,
  uint64_t tag,
  const uint8_t *hash,
  uint8_t hashLen,
  const uint8_t *keyDER,
  uint16_t keyDERLen
)

Weave の RSA 署名を生成してエンコードする。

指定された X509 でエンコードされた RSA 秘密鍵とメッセージ ハッシュを使用して RSA 署名を計算し、その署名を Weave RSASignature 構造として、指定されたタグを使って指定された TLV ライターに書き込みます。

詳細
パラメータ
[in] sigAlgoOID
RSA 署名の生成に使用されるアルゴリズム OID。
[in] writer
エンコードされた署名を書き込む TLVWriter オブジェクト。
[in] tag
エンコードされた署名構造に関連付ける TLV タグ。
[in] hash
署名されるデータのハッシュを格納するバッファ。
[in] hashLen
データハッシュの長さ(バイト単位)。
[in] keyDER
署名の生成に使用される秘密鍵を含むバッファ。秘密鍵は、X509 RSA 秘密鍵構造としてエンコードされることが想定されています。
[in] keyDERLen
エンコードされた秘密鍵の長さ(バイト単位)。
戻り値
WEAVE_NO_ERROR
オペレーションが成功したかどうか。
other
秘密鍵のデコード、署名の生成、署名のエンコードに関連するその他の Weave エラーコード。

GenerateECDHKey

WEAVE_ERROR GenerateECDHKey(
  OID curveOID,
  EncodedECPublicKey & encodedPubKey,
  EncodedECPrivateKey & encodedPrivKey
)

GenerateECDSASignature

WEAVE_ERROR GenerateECDSASignature(
  OID curveOID,
  const uint8_t *msgHash,
  uint8_t msgHashLen,
  const EncodedECPrivateKey & encodedPrivKey,
  EncodedECDSASignature & encodedSig
)

GenerateECDSASignature

WEAVE_ERROR GenerateECDSASignature(
  OID curveOID,
  const uint8_t *msgHash,
  uint8_t msgHashLen,
  const EncodedECPrivateKey & encodedPrivKey,
  uint8_t *fixedLenSig
)

GetCurveG

WEAVE_ERROR GetCurveG(
  OID curveOID,
  EncodedECPublicKey & encodedPubKey
)

GetCurveSize

int GetCurveSize(
  const OID curveOID,
  const EC_GROUP *ecGroup
)

GetCurveSize

int GetCurveSize(
  const OID curveOID
)

楕円曲線のサイズ(バイト単位)を取得します。

詳細
パラメータ
[in] curveOID
指定された楕円曲線 OID。
戻り値
Returns
指定された CurveOID が楕円曲線に対応していない場合は 0 になります。それ以外の場合は、曲線サイズをバイト単位で返します。

GetECGroupForCurve

NL_DLL_EXPORT WEAVE_ERROR GetECGroupForCurve(
  OID curveOID,
  EC_GROUP *& ecGroup
)

ReverseBytes

void ReverseBytes(
  uint8_t *buf,
  size_t len
)

ShaNIDFromSigAlgoOID

int ShaNIDFromSigAlgoOID(
  OID sigAlgoOID
)

VerifyECDSASignature

WEAVE_ERROR VerifyECDSASignature(
  OID curveOID,
  const uint8_t *msgHash,
  uint8_t msgHashLen,
  const EncodedECDSASignature & encodedSig,
  const EncodedECPublicKey & encodedPubKey
)

VerifyECDSASignature

WEAVE_ERROR VerifyECDSASignature(
  OID curveOID,
  const uint8_t *msgHash,
  uint8_t msgHashLen,
  const uint8_t *fixedLenSig,
  const EncodedECPublicKey & encodedPubKey
)

VerifyHMACSignature

WEAVE_ERROR VerifyHMACSignature(
  OID sigAlgoOID,
  const uint8_t *data,
  uint16_t dataLen,
  const EncodedHMACSignature & sig,
  const uint8_t *key,
  uint16_t keyLen
)

Weave の HMAC 署名を検証します。

指定されたデータと、署名の検証に使用する秘密鍵を使用して、HMAC 署名を検証します。

詳細
パラメータ
[in] sigAlgoOID
HMAC 署名の生成に使用されるアルゴリズム OID。
[in] data
署名されるデータを含むバッファ。
[in] dataLen
データの長さ(バイト単位)。
[in] sig
検証対象のエンコードされた HMAC 署名。
[in] key
HMAC 署名の生成に使用される秘密鍵を含むバッファ。
[in] keyLen
秘密鍵の長さ(バイト単位)。
戻り値
WEAVE_NO_ERROR
HMAC 署名検証が成功したかどうか。
WEAVE_ERROR_INVALID_SIGNATURE
HMAC 署名検証に失敗した場合。

VerifyRSASignature

WEAVE_ERROR VerifyRSASignature(
  OID sigAlgoOID,
  const uint8_t *hash,
  uint8_t hashLen,
  const EncodedRSASignature & sig,
  const uint8_t *certDER,
  uint16_t certDERLen
)

Weave の RSA 署名を検証します。

指定されたデータハッシュと、署名の検証に使用される公開鍵を含む X509 エンコードされた RSA 証明書を使用して、RSA 署名を検証します。

詳細
パラメータ
[in] sigAlgoOID
RSA 署名の生成に使用されるアルゴリズム OID。
[in] hash
署名されるデータのハッシュを格納するバッファ。
[in] hashLen
データハッシュの長さ(バイト単位)。
[in] sig
検証対象のエンコードされた RSA 署名。
[in] certDER
署名の検証に使用される公開鍵を含む証明書を含むバッファ。証明書は、DER 形式で X509 RSA 構造でエンコードされることが想定されています。
[in] certDERLen
エンコードされた証明書の長さ(バイト単位)。
戻り値
WEAVE_NO_ERROR
オペレーションが成功したかどうか。