Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions builtins/web/crypto/crypto-algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1358,14 +1358,16 @@ JSObject *CryptoAlgorithmHMAC_Import::importKey(JSContext *cx, CryptoKeyFormat f
return nullptr;
}

std::unique_ptr<std::span<uint8_t>> data;
std::unique_ptr<std::vector<uint8_t>> data;
// 3. Let hash be a new KeyAlgorithm.
// 4.
switch (format) {
// 5. If format is "raw":
case CryptoKeyFormat::Raw: {
// 5.1 Let data be the octet string contained in keyData.
data = std::make_unique<std::span<uint8_t>>(std::get<std::span<uint8_t>>(key_data));
// keyData is a view of the caller's buffer, which can change after import, so copy it.
auto key_bytes = std::get<std::span<uint8_t>>(key_data);
data = std::make_unique<std::vector<uint8_t>>(key_bytes.begin(), key_bytes.end());
if (!data) {
DOMException::raise(cx, "Supplied keyData must be either an ArrayBuffer, TypedArray, or DataView.", "DataError");
return nullptr;
Expand Down Expand Up @@ -1400,10 +1402,7 @@ JSObject *CryptoAlgorithmHMAC_Import::importKey(JSContext *cx, CryptoKeyFormat f
return nullptr;
}
auto data_string = dataResult.unwrap();
auto ddd = std::vector<uint8_t>(data_string.begin(), data_string.end());
data = std::make_unique<std::span<uint8_t>>(
ddd
);
data = std::make_unique<std::vector<uint8_t>>(data_string.begin(), data_string.end());
// 6.7 Set the hash to equal the hash member of normalizedAlgorithm.
CryptoAlgorithmIdentifier hash = this->hashIdentifier;
switch(hash) {
Expand Down
2 changes: 1 addition & 1 deletion builtins/web/crypto/crypto-key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ EvpPkeyPtr create_rsa_key_from_parts(
} // namespace

JSObject *CryptoKey::createHMAC(JSContext *cx, CryptoAlgorithmHMAC_Import *algorithm,
std::unique_ptr<std::span<uint8_t>> data, unsigned long length,
std::unique_ptr<std::vector<uint8_t>> data, unsigned long length,
bool extractable, CryptoKeyUsages usages) {
MOZ_ASSERT(cx);
MOZ_ASSERT(algorithm);
Expand Down
2 changes: 1 addition & 1 deletion builtins/web/crypto/crypto-key.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class CryptoKey : public BuiltinNoConstructor<CryptoKey> {
static bool init_class(JSContext *cx, JS::HandleObject global);

static JSObject *createHMAC(JSContext *cx, CryptoAlgorithmHMAC_Import *algorithm,
std::unique_ptr<std::span<uint8_t>> data, unsigned long length,
std::unique_ptr<std::vector<uint8_t>> data, unsigned long length,
bool extractable, CryptoKeyUsages usages);
static JSObject *createRSA(JSContext *cx, CryptoAlgorithmRSASSA_PKCS1_v1_5_Import *algorithm,
std::unique_ptr<CryptoKeyRSAComponents> keyData, bool extractable,
Expand Down
Loading