mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-28 14:02:51 +00:00
LibWeb: Remove superfluous step in HKDF deriveBits operation
This corresponds to a recent change in the spec: https://github.com/w3c/webcrypto/pull/372 Inspired by the following review comment: https://github.com/LadybirdBrowser/ladybird/pull/1877#discussion_r1807648283
This commit is contained in:
parent
2c3531ab78
commit
ee3b86c3f8
Notes:
github-actions[bot]
2024-10-25 21:51:33 +00:00
Author: https://github.com/BenWiederhake
Commit: ee3b86c3f8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1970
1 changed files with 4 additions and 7 deletions
|
@ -1455,13 +1455,10 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::ArrayBuffer>> HKDF::derive_bits(Algorit
|
||||||
if (length == 0 || length % 8 != 0)
|
if (length == 0 || length % 8 != 0)
|
||||||
return WebIDL::OperationError::create(realm, "Length must be greater than 0 and divisible by 8"_string);
|
return WebIDL::OperationError::create(realm, "Length must be greater than 0 and divisible by 8"_string);
|
||||||
|
|
||||||
// 2. Let extractKey be a key equal to n zero bits where n is the size of the output of the hash function described by the hash member of normalizedAlgorithm.
|
// 2. Let keyDerivationKey be the secret represented by [[handle]] internal slot of key as the message.
|
||||||
// (However, this variable is never directly used, and therefore pointless.)
|
|
||||||
|
|
||||||
// 3. Let keyDerivationKey be the secret represented by [[handle]] internal slot of key as the message.
|
|
||||||
auto key_derivation_key = key->handle().get<ByteBuffer>();
|
auto key_derivation_key = key->handle().get<ByteBuffer>();
|
||||||
|
|
||||||
// 4. Let result be the result of performing the HKDF extract and then the HKDF expand step described in Section 2 of [RFC5869] using:
|
// 3. Let result be the result of performing the HKDF extract and then the HKDF expand step described in Section 2 of [RFC5869] using:
|
||||||
// * the hash member of normalizedAlgorithm as Hash,
|
// * the hash member of normalizedAlgorithm as Hash,
|
||||||
// * keyDerivationKey as the input keying material, IKM,
|
// * keyDerivationKey as the input keying material, IKM,
|
||||||
// * the contents of the salt member of normalizedAlgorithm as salt,
|
// * the contents of the salt member of normalizedAlgorithm as salt,
|
||||||
|
@ -1489,11 +1486,11 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::ArrayBuffer>> HKDF::derive_bits(Algorit
|
||||||
return WebIDL::NotSupportedError::create(m_realm, MUST(String::formatted("Invalid hash function '{}'", hash_algorithm)));
|
return WebIDL::NotSupportedError::create(m_realm, MUST(String::formatted("Invalid hash function '{}'", hash_algorithm)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. If the key derivation operation fails, then throw an OperationError.
|
// 4. If the key derivation operation fails, then throw an OperationError.
|
||||||
if (result.is_error())
|
if (result.is_error())
|
||||||
return WebIDL::OperationError::create(realm, "Failed to derive key"_string);
|
return WebIDL::OperationError::create(realm, "Failed to derive key"_string);
|
||||||
|
|
||||||
// 6. Return result
|
// 5. Return result
|
||||||
return JS::ArrayBuffer::create(realm, result.release_value());
|
return JS::ArrayBuffer::create(realm, result.release_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue