@@ -1112,24 +1112,25 @@ class Spake2p
1112
1112
/* *
1113
1113
* @brief Return the hash.
1114
1114
*
1115
- * @param out Output buffer. The size is implicit and is determined by the hash used.
1115
+ * @param out_span Output buffer. The size available must be >= the hash size. It gets resized
1116
+ * to hash size on success.
1116
1117
*
1117
1118
* @return Returns a CHIP_ERROR on error, CHIP_NO_ERROR otherwise
1118
1119
**/
1119
- virtual CHIP_ERROR HashFinalize (uint8_t * out ) = 0;
1120
+ virtual CHIP_ERROR HashFinalize (MutableByteSpan & out_span ) = 0;
1120
1121
1121
1122
/* *
1122
1123
* @brief Generate a message authentication code.
1123
1124
*
1124
- * @param key The MAC key buffer.
1125
- * @param key_len The size of the MAC key in bytes.
1126
- * @param in The input buffer.
1127
- * @param in_len The size of the input data to MAC in bytes.
1128
- * @param out The output MAC buffer. Size is implicit and is determined by the hash used .
1125
+ * @param key The MAC key buffer.
1126
+ * @param key_len The size of the MAC key in bytes.
1127
+ * @param in The input buffer.
1128
+ * @param in_len The size of the input data to MAC in bytes.
1129
+ * @param out_span The output MAC buffer span . Size must be >= the hash_size. Output size is updated to fit on success .
1129
1130
*
1130
1131
* @return Returns a CHIP_ERROR on error, CHIP_NO_ERROR otherwise
1131
1132
**/
1132
- virtual CHIP_ERROR Mac (const uint8_t * key, size_t key_len, const uint8_t * in, size_t in_len, uint8_t * out ) = 0;
1133
+ virtual CHIP_ERROR Mac (const uint8_t * key, size_t key_len, const uint8_t * in, size_t in_len, MutableByteSpan & out_span ) = 0;
1133
1134
1134
1135
/* *
1135
1136
* @brief Verify a message authentication code.
@@ -1192,7 +1193,7 @@ class Spake2p_P256_SHA256_HKDF_HMAC : public Spake2p
1192
1193
~Spake2p_P256_SHA256_HKDF_HMAC () override { Spake2p_P256_SHA256_HKDF_HMAC::Clear (); }
1193
1194
1194
1195
void Clear () override ;
1195
- CHIP_ERROR Mac (const uint8_t * key, size_t key_len, const uint8_t * in, size_t in_len, uint8_t * out ) override ;
1196
+ CHIP_ERROR Mac (const uint8_t * key, size_t key_len, const uint8_t * in, size_t in_len, MutableByteSpan & out_span ) override ;
1196
1197
CHIP_ERROR MacVerify (const uint8_t * key, size_t key_len, const uint8_t * mac, size_t mac_len, const uint8_t * in,
1197
1198
size_t in_len) override ;
1198
1199
CHIP_ERROR FELoad (const uint8_t * in, size_t in_len, void * fe) override ;
@@ -1212,7 +1213,7 @@ class Spake2p_P256_SHA256_HKDF_HMAC : public Spake2p
1212
1213
protected:
1213
1214
CHIP_ERROR InitImpl () override ;
1214
1215
CHIP_ERROR Hash (const uint8_t * in, size_t in_len) override ;
1215
- CHIP_ERROR HashFinalize (uint8_t * out ) override ;
1216
+ CHIP_ERROR HashFinalize (MutableByteSpan & out_span ) override ;
1216
1217
CHIP_ERROR KDF (const uint8_t * secret, size_t secret_length, const uint8_t * salt, size_t salt_length, const uint8_t * info,
1217
1218
size_t info_length, uint8_t * out, size_t out_length) override ;
1218
1219
0 commit comments