1 | /* |
2 | * Copyright (C) 2016 Apple Inc. All rights reserved. |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * 1. Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. |
9 | * 2. Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
23 | * THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | #pragma once |
27 | |
28 | #include "CryptoAlgorithmIdentifier.h" |
29 | #include <wtf/TypeCasts.h> |
30 | #include <wtf/text/WTFString.h> |
31 | |
32 | #if ENABLE(WEB_CRYPTO) |
33 | |
34 | namespace WebCore { |
35 | |
36 | class CryptoAlgorithmParameters { |
37 | WTF_MAKE_FAST_ALLOCATED; |
38 | public: |
39 | enum class Class { |
40 | None, |
41 | AesCbcCfbParams, |
42 | AesCtrParams, |
43 | AesGcmParams, |
44 | AesKeyParams, |
45 | EcKeyParams, |
46 | EcdhKeyDeriveParams, |
47 | EcdsaParams, |
48 | HkdfParams, |
49 | HmacKeyParams, |
50 | Pbkdf2Params, |
51 | RsaHashedKeyGenParams, |
52 | RsaHashedImportParams, |
53 | RsaKeyGenParams, |
54 | RsaOaepParams, |
55 | RsaPssParams, |
56 | }; |
57 | |
58 | // FIXME: Consider merging name and identifier. |
59 | String name; |
60 | CryptoAlgorithmIdentifier identifier; |
61 | |
62 | virtual ~CryptoAlgorithmParameters() = default; |
63 | |
64 | virtual Class parametersClass() const { return Class::None; } |
65 | }; |
66 | |
67 | } // namespace WebCore |
68 | |
69 | #define SPECIALIZE_TYPE_TRAITS_CRYPTO_ALGORITHM_PARAMETERS(ToClassName) \ |
70 | SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::CryptoAlgorithm##ToClassName) \ |
71 | static bool isType(const WebCore::CryptoAlgorithmParameters& parameters) { return parameters.parametersClass() == WebCore::CryptoAlgorithmParameters::Class::ToClassName; } \ |
72 | SPECIALIZE_TYPE_TRAITS_END() |
73 | |
74 | #endif // ENABLE(WEB_CRYPTO) |
75 | |