/* * Copyright (C) 2017-2019 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ #pragma once #include "CryptoKey.h" #include "CryptoKeyPair.h" #include "ExceptionOr.h" #if ENABLE(WEB_CRYPTO) #if 0 #include "CommonCryptoUtilities.h" typedef CCECCryptorRef PlatformECKey; namespace WebCore { struct CCECCryptorRefDeleter { void operator()(CCECCryptorRef key) const { CCECCryptorRelease(key); } }; } typedef std::unique_ptr::type, WebCore::CCECCryptorRefDeleter> PlatformECKeyContainer; #endif #if USE(GCRYPT) #include typedef gcry_sexp_t PlatformECKey; typedef std::unique_ptr::type, PAL::GCrypt::HandleDeleter> PlatformECKeyContainer; #endif #if USE(OPENSSL) #include "OpenSSLCryptoUniquePtr.h" typedef EVP_PKEY* PlatformECKey; typedef WebCore::EvpPKeyPtr PlatformECKeyContainer; #endif namespace WebCore { struct JsonWebKey; class CryptoKeyEC final : public CryptoKey { public: enum class NamedCurve { P256, P384, P521, }; static Ref create(CryptoAlgorithmIdentifier identifier, NamedCurve curve, CryptoKeyType type, PlatformECKeyContainer&& platformKey, bool extractable, CryptoKeyUsageBitmap usages) { return adoptRef(*new CryptoKeyEC(identifier, curve, type, WTFMove(platformKey), extractable, usages)); } virtual ~CryptoKeyEC() = default; WEBCORE_EXPORT static ExceptionOr generatePair(CryptoAlgorithmIdentifier, const String& curve, bool extractable, CryptoKeyUsageBitmap); WEBCORE_EXPORT static RefPtr importRaw(CryptoAlgorithmIdentifier, const String& curve, Vector&& keyData, bool extractable, CryptoKeyUsageBitmap); static RefPtr importJwk(CryptoAlgorithmIdentifier, const String& curve, JsonWebKey&&, bool extractable, CryptoKeyUsageBitmap); static RefPtr importSpki(CryptoAlgorithmIdentifier, const String& curve, Vector&& keyData, bool extractable, CryptoKeyUsageBitmap); static RefPtr importPkcs8(CryptoAlgorithmIdentifier, const String& curve, Vector&& keyData, bool extractable, CryptoKeyUsageBitmap); WEBCORE_EXPORT ExceptionOr> exportRaw() const; ExceptionOr exportJwk() const; ExceptionOr> exportSpki() const; ExceptionOr> exportPkcs8() const; size_t keySizeInBits() const; size_t keySizeInBytes() const { return std::ceil(keySizeInBits() / 8.); } NamedCurve namedCurve() const { return m_curve; } String namedCurveString() const; PlatformECKey platformKey() const { return m_platformKey.get(); } static bool isValidECAlgorithm(CryptoAlgorithmIdentifier); private: CryptoKeyEC(CryptoAlgorithmIdentifier, NamedCurve, CryptoKeyType, PlatformECKeyContainer&&, bool extractable, CryptoKeyUsageBitmap); CryptoKeyClass keyClass() const final { return CryptoKeyClass::EC; } KeyAlgorithm algorithm() const final; static bool platformSupportedCurve(NamedCurve); static std::optional platformGeneratePair(CryptoAlgorithmIdentifier, NamedCurve, bool extractable, CryptoKeyUsageBitmap); static RefPtr platformImportRaw(CryptoAlgorithmIdentifier, NamedCurve, Vector&& keyData, bool extractable, CryptoKeyUsageBitmap); static RefPtr platformImportJWKPublic(CryptoAlgorithmIdentifier, NamedCurve, Vector&& x, Vector&& y, bool extractable, CryptoKeyUsageBitmap); static RefPtr platformImportJWKPrivate(CryptoAlgorithmIdentifier, NamedCurve, Vector&& x, Vector&& y, Vector&& d, bool extractable, CryptoKeyUsageBitmap); static RefPtr platformImportSpki(CryptoAlgorithmIdentifier, NamedCurve, Vector&& keyData, bool extractable, CryptoKeyUsageBitmap); static RefPtr platformImportPkcs8(CryptoAlgorithmIdentifier, NamedCurve, Vector&& keyData, bool extractable, CryptoKeyUsageBitmap); Vector platformExportRaw() const; bool platformAddFieldElements(JsonWebKey&) const; Vector platformExportSpki() const; Vector platformExportPkcs8() const; PlatformECKeyContainer m_platformKey; NamedCurve m_curve; }; } // namespace WebCore SPECIALIZE_TYPE_TRAITS_CRYPTO_KEY(CryptoKeyEC, CryptoKeyClass::EC) #endif // ENABLE(WEB_CRYPTO) /option> Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
AgeCommit message (Expand)AuthorFilesLines
2022-08-28Update README.mdGravatar Jarred Sumner 1-1/+6
2022-08-28Update package.jsonGravatar Jarred Sumner 1-1/+1
2022-08-28Remove code that doesn't workGravatar Jarred Sumner 12-632/+41
2022-08-28More reliable macOS event loop (#1166)Gravatar Jarred Sumner 13-144/+607
2022-08-28feat: hack in support for tsconfig `extends` (#1147)Gravatar yepitschunked 2-14/+47
2022-08-28support pass null as NULL ptr (#1160)Gravatar Zilin Zhu 6-1/+27
2022-08-28[bun:ffi] Fix crash with uint64_tGravatar Jarred Sumner 3-9/+8
2022-08-28[bun:ffi] Fix int16 / uin16 maxGravatar Jarred Sumner 1-3/+6
2022-08-27Update WebKit (#1165)Gravatar Jarred Sumner 67-1083/+1210
2022-08-27Fix crash in `os` module on macOSGravatar Jarred Sumner 2-74/+108
2022-08-27Update MakefileGravatar Jarred Sumner 1-1/+1
2022-08-27Update MakefileGravatar Jarred Sumner 1-0/+2
2022-08-27Fix ffi uint64_t parameter (#1158)Gravatar Zilin Zhu 4-39/+63
2022-08-27fix compile error (#1157)Gravatar Zilin Zhu 3-5/+7
2022-08-27added shell to STRIP variable definition (#1156)Gravatar Dylan Conway 1-1/+1
2022-08-26Update napi.zigGravatar Jarred Sumner 1-1/+3
2022-08-26Remove pointer to stack buffer in `os` module and fix build issueGravatar Jarred Sumner 3-23/+19
2022-08-26Implement `napi_add_finalizer`Gravatar Jarred Sumner 1-0/+13
2022-08-26Fix debug build cacheGravatar Jarred Sumner 1-1/+4
2022-08-26fix: Update broken README links (#1148)Gravatar Max Thomson 1-3/+3
2022-08-26Update node_fs.zigGravatar Jarred Sumner 1-1/+1
2022-08-26fix mkdtemp (#1151)Gravatar Zilin Zhu 1-3/+3
2022-08-25Add native BufferList (#1146)Gravatar Zilin Zhu 8-167/+500
2022-08-25feat: implement native os module (#1115)Gravatar Hyro 27-15/+1820
2022-08-25Fix `Request` and `Response` in macrosGravatar Jarred Sumner 1-19/+31
2022-08-25Faster way to lookup mimetypeGravatar Jarred Sumner 1-7/+8
2022-08-25Fix incorrect `indexOfNotChar` causing sourcemaps bugsGravatar Jarred Sumner 1-7/+9
2022-08-24Fix clearTimeout and linux timeout (#1138)Gravatar Zilin Zhu 2-5/+11
2022-08-24Add pad back to base64 (#1140)Gravatar Zilin Zhu 1-4/+4
2022-08-23updated minified url polyfill (#1132)Gravatar Sam 1-1/+1
2022-08-23add SlowBuffer (#1133)Gravatar Zilin Zhu 3-1/+15
2022-08-22Remove response poolGravatar Jarred Sumner 3-47/+8
2022-08-22Fix build errorGravatar Jarred Sumner 3-2/+16
2022-08-22woopsGravatar Jarred Sumner 1-1/+0
2022-08-22[node:http] speed up assigning headersGravatar Jarred Sumner 3-75/+58
2022-08-22reduce usage of protectGravatar Jarred Sumner 1-1/+11
2022-08-22Update mime_type.zigGravatar Jarred Sumner 1-0/+6
2022-08-22Improve error message when port is already in useGravatar Jarred Sumner 1-2/+12
2022-08-22Update server.zigGravatar Jarred Sumner 1-2/+2
2022-08-22Support emit Symbol events in EventEmitter (#1129)Gravatar Zilin Zhu 7-122/+278
2022-08-22faster way to read content-typeGravatar Jarred Sumner 1-1/+1
2022-08-22Fix `Buffer.isEncoding`Gravatar Jarred Sumner 1-1/+3
2022-08-22Add some optimizations to FetchHeadersGravatar Jarred Sumner 3-16/+188
2022-08-22Fix import pathGravatar Jarred Sumner 1-1/+1
2022-08-2238% faster `node:http`Gravatar Jarred Sumner 1-77/+203