nl::Weave::Crypto

Không gian tên này bao gồm tất cả các giao diện trong Weave dành cho việc hỗ trợ mật mã dùng chung.

Tóm tắt

Bảng liệt kê

X963EncodedPointFormat enum

Typedef

AES128CTRDRBG typedef
AES128CTRMode typedef
AES256CTRMode typedef
EntropyFunct)(uint8_t *buf, size_t bufSize) typedef
int(*
Chữ ký của một hàm dùng để thu thập dữ liệu ngẫu nhiên từ một nguồn entropy.
HKDFSHA1 typedef
HKDFSHA256 typedef
HMACSHA1 typedef
HMACSHA256 typedef

Hàm

ClearSecretData(uint8_t *buf, uint32_t len)
NL_DLL_EXPORT void
Xoá len byte đầu tiên của vùng bộ nhớ buf.
ConstantTimeCompare(const uint8_t *buf1, const uint8_t *buf2, uint16_t len)
bool
So sánh len byte đầu tiên của vùng bộ nhớ buf1 và vùng bộ nhớ buf2.
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)
Tạo và mã hoá chữ ký Weave HMAC.
GenerateAndEncodeWeaveRSASignature(OID sigAlgoOID, TLVWriter & writer, uint64_t tag, const uint8_t *hash, uint8_t hashLen, const uint8_t *keyDER, uint16_t keyDERLen)
Tạo và mã hoá chữ ký RSA của Weave.
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
Nhận kích thước Đường cong Elliptic (tính bằng byte).
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)
Xác minh chữ ký HMAC của Weave.
VerifyRSASignature(OID sigAlgoOID, const uint8_t *hash, uint8_t hashLen, const EncodedRSASignature & sig, const uint8_t *certDER, uint16_t certDERLen)
Xác minh chữ ký RSA của Weave.

Lớp

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

Bảng liệt kê

X963EncodedPointFormat

 X963EncodedPointFormat

Typedef

AES128CTRDRBG

CTR_DRBG< Platform::Security::AES128BlockCipherEnc > AES128CTRDRBG

Chế độ AES128CTR

CTRMode< Platform::Security::AES128BlockCipherEnc > AES128CTRMode

Chế độ AES256CTR

CTRMode< Platform::Security::AES256BlockCipherEnc > AES256CTRMode

EntropyFunct

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

Chữ ký của một hàm dùng để thu thập dữ liệu ngẫu nhiên từ một nguồn entropy.

HKDFSHA1

HKDF< Platform::Security::SHA1 > HKDFSHA1

HKDFSHA256

HKDF< Platform::Security::SHA256 > HKDFSHA256

HMACSHA1

HMAC< Platform::Security::SHA1 > HMACSHA1

HMACSHA256

HMAC< Platform::Security::SHA256 > HMACSHA256

Hàm

ClearSecretData

NL_DLL_EXPORT void ClearSecretData(
  uint8_t *buf,
  uint32_t len
)

Xoá len byte đầu tiên của vùng bộ nhớ buf.

Trong quá trình triển khai này, len byte đầu tiên của vùng bộ nhớ buf được điền bằng 0.

Thông tin chi tiết
Các tham số
[in] buf
Con trỏ đến vùng đệm bộ nhớ chứa dữ liệu bí mật cần được xoá.
[in] len
Chỉ định kích thước dữ liệu bí mật tính bằng byte.

ConstantTimeCompare

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

So sánh len byte đầu tiên của vùng bộ nhớ buf1 và vùng bộ nhớ buf2.

Thời gian mà hàm này thực hiện không phụ thuộc vào dữ liệu trong các khu vực bộ nhớ buf1buf2.

Thông tin chi tiết
Các tham số
[in] buf1
Con trỏ đến một khối bộ nhớ.
[in] buf2
Con trỏ đến một khối bộ nhớ.
[in] len
Kích thước của vùng bộ nhớ cần so sánh tính bằng byte.
Giá trị trả về
true
nếu len byte đầu tiên của vùng bộ nhớ buf1buf2 bằng nhau.
false
nếu không.

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
)

Tạo và mã hoá chữ ký Weave HMAC.

Tính toán chữ ký HMAC cho một dữ liệu đã cho bằng khoá bí mật và ghi chữ ký đó dưới dạng cấu trúc Weave HMACSignature cho trình ghi TLV được chỉ định bằng thẻ đã cho.

Thông tin chi tiết
Các tham số
[in] sigAlgoOID
OID thuật toán được dùng để tạo chữ ký HMAC.
[in] writer
Đối tượng TLVWriter mà chữ ký mã hoá cần được ghi vào đó.
[in] tag
TLV để được liên kết với cấu trúc chữ ký đã mã hoá.
[in] data
Vùng đệm chứa dữ liệu cần ký.
[in] dataLen
Độ dài tính bằng byte của dữ liệu.
[in] key
Vùng đệm chứa khoá bí mật dùng để tạo chữ ký HMAC.
[in] keyLen
Độ dài tính bằng byte của khoá bí mật.
Giá trị trả về
WEAVE_NO_ERROR
Nếu thao tác thành công.
other
Các mã lỗi Weave khác liên quan đến mã hoá chữ ký.

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
)

Tạo và mã hoá chữ ký RSA của Weave.

Tính toán chữ ký RSA bằng cách sử dụng hàm băm thư và khoá cá nhân RSA được mã hoá X509 nhất định, đồng thời ghi chữ ký dưới dạng cấu trúc Weave RSASignature cho người ghi TLV được chỉ định bằng thẻ đã cho.

Thông tin chi tiết
Các tham số
[in] sigAlgoOID
OID thuật toán được dùng để tạo chữ ký RSA.
[in] writer
Đối tượng TLVWriter mà chữ ký mã hoá cần được ghi vào đó.
[in] tag
TLV để được liên kết với cấu trúc chữ ký đã mã hoá.
[in] hash
Vùng đệm chứa hàm băm của dữ liệu cần ký.
[in] hashLen
Độ dài tính bằng byte của hàm băm dữ liệu.
[in] keyDER
Vùng đệm chứa khoá riêng tư dùng để tạo chữ ký. Khoá riêng tư dự kiến được mã hoá dưới dạng cấu trúc khoá cá nhân RSA X509.
[in] keyDERLen
Độ dài tính bằng byte của khoá riêng tư đã mã hoá.
Giá trị trả về
WEAVE_NO_ERROR
Nếu thao tác thành công.
other
Các mã lỗi Weave khác liên quan đến việc giải mã khoá riêng tư, tạo chữ ký hoặc mã hoá chữ ký.

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
)

Nhận kích thước Đường cong Elliptic (tính bằng byte).

Thông tin chi tiết
Các tham số
[in] curveOID
OID đường cong elip đã chỉ định.
Giá trị trả về
Returns
0 nếu đường cong OID được chỉ định không được hỗ trợ Đường cong elip. Nếu không, hãy trả về kích thước đường cong tính bằng byte.

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
)

Xác minh chữ ký HMAC của Weave.

Xác minh chữ ký HMAC bằng dữ liệu đã cho và khoá bí mật dùng để xác minh chữ ký.

Thông tin chi tiết
Các tham số
[in] sigAlgoOID
OID thuật toán được dùng để tạo chữ ký HMAC.
[in] data
Vùng đệm chứa dữ liệu cần ký.
[in] dataLen
Độ dài tính bằng byte của dữ liệu.
[in] sig
Cần xác minh chữ ký HMAC đã mã hoá.
[in] key
Vùng đệm chứa khoá bí mật dùng để tạo chữ ký HMAC.
[in] keyLen
Độ dài tính bằng byte của khoá bí mật.
Giá trị trả về
WEAVE_NO_ERROR
Trường hợp xác minh chữ ký HMAC thành công.
WEAVE_ERROR_INVALID_SIGNATURE
Nếu không xác minh được chữ ký HMAC.

VerifyRSASignature

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

Xác minh chữ ký RSA của Weave.

Xác minh chữ ký RSA bằng hàm băm dữ liệu đã cho và một chứng chỉ RSA được mã hoá X509 có chứa khoá công khai sẽ dùng để xác minh chữ ký.

Thông tin chi tiết
Các tham số
[in] sigAlgoOID
OID thuật toán được dùng để tạo chữ ký RSA.
[in] hash
Vùng đệm chứa hàm băm của dữ liệu cần ký.
[in] hashLen
Độ dài tính bằng byte của hàm băm dữ liệu.
[in] sig
Chữ ký RSA đã mã hoá cần được xác minh.
[in] certDER
Vùng đệm chứa chứng chỉ có khoá công khai dùng để xác minh chữ ký. Chứng chỉ phải được mã hoá DER theo cấu trúc RSA X509.
[in] certDERLen
Độ dài tính bằng byte của chứng chỉ được mã hoá.
Giá trị trả về
WEAVE_NO_ERROR
Nếu thao tác thành công.