nl::Weave::Crypto

تشمل مساحة الاسم هذه جميع الواجهات داخل Weave لدعم التشفير المشترك.

ملخّص

عمليات التعداد

X963EncodedPointFormat تعداد

تحديدات النوع

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
يؤدي هذا الإجراء إلى محو أول len بايت من مساحة الذاكرة buf.
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)
إنشاء وترميز توقيع HMAC من Weave.
GenerateAndEncodeWeaveRSASignature(OID sigAlgoOID, TLVWriter & writer, uint64_t tag, const uint8_t *hash, uint8_t hashLen, const uint8_t *keyDER, uint16_t keyDERLen)
إنشاء وترميز توقيع RSA في 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
الحصول على حجم المنحنى البيضاوي (بالبايت)
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)
تحقَّق من توقيع RSA في Weave.

صفوف

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

تحديدات النوع

معيار 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
)

يؤدي هذا الإجراء إلى محو أول len بايت من مساحة الذاكرة buf.

في هذه العملية، تتم تعبئة أول len بايت من مساحة الذاكرة buf بالأصفار.

التفاصيل
المَعلمات
[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
)

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
)

إنشاء وترميز توقيع HMAC من Weave.

احتساب توقيع 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
)

إنشاء وترميز توقيع RSA في Weave.

تحسب توقيع RSA باستخدام مفتاح خاص بترميز RSA مرمّز 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 إذا كان معرف المنحنى المحدد غير متوافق مع منحنى Elliptic. وإلا، سيتم عرض حجم المنحنى بالبايت.

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
)

تحقَّق من توقيع RSA في Weave.

يتم التحقق من توقيع RSA باستخدام تجزئة بيانات محددة وشهادة RSA بترميز X509 تحتوي على المفتاح العام المراد استخدامه للتحقق من التوقيع.

التفاصيل
المَعلمات
[in] sigAlgoOID
معرّف OID للخوارزمية الذي سيتم استخدامه لإنشاء توقيع RSA
[in] hash
يشير ذلك المصطلح إلى مخزن مؤقت يحتوي على تجزئة البيانات المطلوب توقيعها.
[in] hashLen
يشير ذلك المصطلح إلى الطول بالبايت من تجزئة البيانات.
[in] sig
توقيع RSA مشفّر المراد التحقق منه.
[in] certDER
يشير هذا المصطلح إلى مخزن مؤقت يحتوي على الشهادة التي تتضمّن مفتاحًا عامًا ويُستخدَم للتحقّق من التوقيع. من المتوقع أن تكون الشهادة بترميز DER ببنية RSA X509.
[in] certDERLen
الطول بالبايت للشهادة المشفرة.
قيم الإرجاع
WEAVE_NO_ERROR
إذا نجحت العملية.