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
เปรียบเทียบ len ไบต์แรกของพื้นที่หน่วยความจำ buf1 และพื้นที่หน่วยความจำ 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)
สร้างและเข้ารหัสลายเซ็น 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)
ยืนยันลายเซ็น HMAC ของ Weave
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

โหมด AES128CTR

CTRMode< Platform::Security::AES128BlockCipherEnc > AES128CTRMode

โหมด AES256CTR

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 ไบต์แรก

ในการใช้งานนี้ len ไบต์แรกของพื้นที่หน่วยความจำ buf จะเต็มไปด้วยเลข 0

รายละเอียด
พารามิเตอร์
[in] buf
ชี้ไปที่บัฟเฟอร์หน่วยความจำที่เก็บข้อมูลลับที่ควรล้าง
[in] len
ระบุขนาดข้อมูลลับเป็นไบต์

ConstantTimeCompare

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

เปรียบเทียบ len ไบต์แรกของพื้นที่หน่วยความจำ buf1 และพื้นที่หน่วยความจำ buf2

เวลาที่ฟังก์ชันนี้ใช้ไม่ขึ้นอยู่กับข้อมูลในพื้นที่หน่วยความจำ buf1 และ buf2

รายละเอียด
พารามิเตอร์
[in] buf1
ชี้ไปที่บล็อกหน่วยความจำ
[in] buf2
ชี้ไปที่บล็อกหน่วยความจำ
[in] len
ขนาดของพื้นที่หน่วยความจำเพื่อเปรียบเทียบเป็นไบต์
แสดงผลค่า
true
หากพื้นที่หน่วยความจำ len ไบต์แรก buf1 และ buf2 เท่ากัน
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
)

ถอดรหัส X962ECPoint

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

ถอดรหัส X962ECPoint

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
OID ของอัลกอริทึมที่จะใช้สร้างลายเซ็น HMAC
[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

ประมวลผลลายเซ็น RSA โดยใช้คีย์ส่วนตัวและแฮชข้อความที่เข้ารหัส X509 ที่เข้ารหัส X509 และเขียนลายเซ็นเป็นโครงสร้าง Weave RSASignature กับผู้เขียน TLV ที่ระบุพร้อมแท็กที่ระบุ

รายละเอียด
พารามิเตอร์
[in] sigAlgoOID
OID ของอัลกอริทึมที่จะใช้สร้างลายเซ็น RSA
[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
0 หาก Curve ที่ระบุไม่รองรับ Elliptic Curve มิฉะนั้น จะแสดงผลขนาดเส้นโค้งเป็นไบต์

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
)

ยืนยันลายเซ็น HMAC ของ Weave

ตรวจสอบลายเซ็น HMAC โดยใช้ข้อมูลที่ระบุและคีย์ลับที่จะใช้ยืนยันลายเซ็น

รายละเอียด
พารามิเตอร์
[in] sigAlgoOID
OID ของอัลกอริทึมที่จะใช้สร้างลายเซ็น HMAC
[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

ตรวจสอบลายเซ็น RSA โดยใช้แฮชข้อมูลที่ระบุและใบรับรอง RSA ที่เข้ารหัสแบบ X509 ที่มีคีย์สาธารณะที่จะใช้เพื่อยืนยันลายเซ็น

รายละเอียด
พารามิเตอร์
[in] sigAlgoOID
OID ของอัลกอริทึมที่จะใช้สร้างลายเซ็น RSA
[in] hash
บัฟเฟอร์ที่มีแฮชของข้อมูลที่จะลงนาม
[in] hashLen
ความยาวเป็นไบต์ของแฮชข้อมูล
[in] sig
ลายเซ็น RSA ที่เข้ารหัสไว้เพื่อการยืนยัน
[in] certDER
บัฟเฟอร์ที่มีใบรับรองพร้อมคีย์สาธารณะที่จะใช้เพื่อยืนยันลายเซ็น ใบรับรองควรเป็นแบบเข้ารหัส DER โดยใช้โครงสร้าง X509 RSA
[in] certDERLen
ความยาวเป็นไบต์ของใบรับรองที่เข้ารหัส
แสดงผลค่า
WEAVE_NO_ERROR
หากการดำเนินการสำเร็จ