You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 3. Let M be the result of performing the digest operation specified by hashAlgorithm using message.
2370
+
::Crypto::Hash::HashKind hash_kind;
2371
+
if (hash_algorithm == "SHA-1") {
2372
+
hash_kind = ::Crypto::Hash::HashKind::SHA1;
2373
+
} elseif (hash_algorithm == "SHA-256") {
2374
+
hash_kind = ::Crypto::Hash::HashKind::SHA256;
2375
+
} elseif (hash_algorithm == "SHA-384") {
2376
+
hash_kind = ::Crypto::Hash::HashKind::SHA384;
2377
+
} elseif (hash_algorithm == "SHA-512") {
2378
+
hash_kind = ::Crypto::Hash::HashKind::SHA512;
2379
+
} else {
2380
+
returnWebIDL::NotSupportedError::create(m_realm, MUST(String::formatted("Invalid hash function '{}'", hash_algorithm)));
2381
+
}
2382
+
::Crypto::Hash::Manager hash { hash_kind };
2383
+
hash.update(message);
2384
+
auto digest = hash.digest();
2385
+
2386
+
auto M = TRY_OR_THROW_OOM(vm, ByteBuffer::copy(digest.immutable_data(), hash.digest_size()));
2387
+
2388
+
// 4. Let d be the ECDSA private key associated with key.
2389
+
auto d = key->handle().get<::Crypto::PK::ECPrivateKey<>>();
2371
2390
2372
-
// NOTE: We dont have sign() on the SECPxxxr1 curves, so we can't implement this yet
2373
-
// FIXME: 3. Let M be the result of performing the digest operation specified by hashAlgorithm using message.
2374
-
// FIXME: 4. Let d be the ECDSA private key associated with key.
2375
2391
// FIXME: 5. Let params be the EC domain parameters associated with key.
2376
-
// FIXME: 6. If the namedCurve attribute of the [[algorithm]] internal slot of key is "P-256", "P-384" or "P-521":
2377
2392
2378
-
// FIXME: 1. Perform the ECDSA signing process, as specified in [RFC6090], Section 5.4, with M as the message, using params as the EC domain parameters, and with d as the private key.
2379
-
// FIXME: 2. Let r and s be the pair of integers resulting from performing the ECDSA signing process.
2380
-
// FIXME: 3. Let result be an empty byte sequence.
2381
-
// FIXME: 4. Let n be the smallest integer such that n * 8 is greater than the logarithm to base 2 of the order of the base point of the elliptic curve identified by params.
2382
-
// FIXME: 5. Convert r to an octet string of length n and append this sequence of bytes to result.
2383
-
// FIXME: 6. Convert s to an octet string of length n and append this sequence of bytes to result.
result = TRY_OR_THROW_OOM(vm, ByteBuffer::create_zeroed(coord_size * 2));
2432
+
2433
+
// 4. Let n be the smallest integer such that n * 8 is greater than the logarithm to base 2 of the order of the base point of the elliptic curve identified by params.
2434
+
// 5. Convert r to an octet string of length n and append this sequence of bytes to result.
2435
+
VERIFY(signature.r.byte_length() <= coord_size);
2436
+
(void)signature.r.export_data(result.span());
2437
+
2438
+
// 6. Convert s to an octet string of length n and append this sequence of bytes to result.
0 commit comments