
This is a simple implementation of SubtleCrypto.digest() using LibCrypto under the hood, so it supports all the required hash functions: SHA-1, SHA-256, SHA-384, SHA-512. Two FIXMEs remain: doing the hashing "in parallel", and supporting an object argument instead of a plain string.
37 lines
712 B
C++
37 lines
712 B
C++
/*
|
|
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibJS/Forward.h>
|
|
#include <LibWeb/Bindings/Wrappable.h>
|
|
|
|
namespace Web::Crypto {
|
|
|
|
class SubtleCrypto
|
|
: public Bindings::Wrappable
|
|
, public RefCounted<SubtleCrypto> {
|
|
public:
|
|
using WrapperType = Bindings::SubtleCryptoWrapper;
|
|
|
|
static NonnullRefPtr<SubtleCrypto> create()
|
|
{
|
|
return adopt_ref(*new SubtleCrypto());
|
|
}
|
|
|
|
JS::Promise* digest(String const& algorithm, JS::Handle<JS::Object> const& data);
|
|
|
|
private:
|
|
SubtleCrypto() = default;
|
|
};
|
|
|
|
}
|
|
|
|
namespace Web::Bindings {
|
|
|
|
SubtleCryptoWrapper* wrap(JS::GlobalObject&, Crypto::SubtleCrypto&);
|
|
|
|
}
|