OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, | 61 WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, |
62 WebCryptoAlgorithmIdSha1, | 62 WebCryptoAlgorithmIdSha1, |
63 WebCryptoAlgorithmIdSha256, | 63 WebCryptoAlgorithmIdSha256, |
64 WebCryptoAlgorithmIdSha384, | 64 WebCryptoAlgorithmIdSha384, |
65 WebCryptoAlgorithmIdSha512, | 65 WebCryptoAlgorithmIdSha512, |
66 WebCryptoAlgorithmIdAesGcm, | 66 WebCryptoAlgorithmIdAesGcm, |
67 WebCryptoAlgorithmIdRsaOaep, | 67 WebCryptoAlgorithmIdRsaOaep, |
68 WebCryptoAlgorithmIdAesCtr, | 68 WebCryptoAlgorithmIdAesCtr, |
69 WebCryptoAlgorithmIdAesKw, | 69 WebCryptoAlgorithmIdAesKw, |
70 WebCryptoAlgorithmIdRsaPss, | 70 WebCryptoAlgorithmIdRsaPss, |
| 71 WebCryptoAlgorithmIdEcdsa, |
71 #if INSIDE_BLINK | 72 #if INSIDE_BLINK |
72 WebCryptoAlgorithmIdLast = WebCryptoAlgorithmIdRsaPss, | 73 WebCryptoAlgorithmIdLast = WebCryptoAlgorithmIdEcdsa, |
73 #endif | 74 #endif |
74 }; | 75 }; |
75 | 76 |
| 77 enum WebCryptoNamedCurve { |
| 78 WebCryptoNamedCurveP256, |
| 79 WebCryptoNamedCurveP384, |
| 80 WebCryptoNamedCurveP521, |
| 81 #if INSIDE_BLINK |
| 82 WebCryptoNamedCurveLast = WebCryptoNamedCurveP521, |
| 83 #endif |
| 84 }; |
| 85 |
76 enum WebCryptoAlgorithmParamsType { | 86 enum WebCryptoAlgorithmParamsType { |
77 WebCryptoAlgorithmParamsTypeNone, | 87 WebCryptoAlgorithmParamsTypeNone, |
78 WebCryptoAlgorithmParamsTypeAesCbcParams, | 88 WebCryptoAlgorithmParamsTypeAesCbcParams, |
79 WebCryptoAlgorithmParamsTypeAesKeyGenParams, | 89 WebCryptoAlgorithmParamsTypeAesKeyGenParams, |
80 WebCryptoAlgorithmParamsTypeHmacImportParams, | 90 WebCryptoAlgorithmParamsTypeHmacImportParams, |
81 WebCryptoAlgorithmParamsTypeHmacKeyGenParams, | 91 WebCryptoAlgorithmParamsTypeHmacKeyGenParams, |
82 WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams, | 92 WebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams, |
83 WebCryptoAlgorithmParamsTypeRsaHashedImportParams, | 93 WebCryptoAlgorithmParamsTypeRsaHashedImportParams, |
84 WebCryptoAlgorithmParamsTypeAesGcmParams, | 94 WebCryptoAlgorithmParamsTypeAesGcmParams, |
85 WebCryptoAlgorithmParamsTypeRsaOaepParams, | 95 WebCryptoAlgorithmParamsTypeRsaOaepParams, |
86 WebCryptoAlgorithmParamsTypeAesCtrParams, | 96 WebCryptoAlgorithmParamsTypeAesCtrParams, |
87 WebCryptoAlgorithmParamsTypeRsaPssParams, | 97 WebCryptoAlgorithmParamsTypeRsaPssParams, |
| 98 WebCryptoAlgorithmParamsTypeEcdsaParams, |
| 99 WebCryptoAlgorithmParamsTypeEcKeyGenParams, |
| 100 WebCryptoAlgorithmParamsTypeEcKeyImportParams, |
88 }; | 101 }; |
89 | 102 |
90 struct WebCryptoAlgorithmInfo { | 103 struct WebCryptoAlgorithmInfo { |
91 typedef char ParamsTypeOrUndefined; | 104 typedef char ParamsTypeOrUndefined; |
92 static const ParamsTypeOrUndefined Undefined = -1; | 105 static const ParamsTypeOrUndefined Undefined = -1; |
93 | 106 |
94 // The canonical (case-sensitive) name for the algorithm as a | 107 // The canonical (case-sensitive) name for the algorithm as a |
95 // null-terminated C-string literal. | 108 // null-terminated C-string literal. |
96 const char* name; | 109 const char* name; |
97 | 110 |
98 // A map from the operation to the expected parameter type of the algorithm. | 111 // A map from the operation to the expected parameter type of the algorithm. |
99 // If an operation is not applicable for the algorithm, set to Undefined. | 112 // If an operation is not applicable for the algorithm, set to Undefined. |
100 const ParamsTypeOrUndefined operationToParamsType[WebCryptoOperationLast + 1
]; | 113 const ParamsTypeOrUndefined operationToParamsType[WebCryptoOperationLast + 1
]; |
101 }; | 114 }; |
102 | 115 |
103 | 116 |
104 class WebCryptoAesCbcParams; | 117 class WebCryptoAesCbcParams; |
105 class WebCryptoAesKeyGenParams; | 118 class WebCryptoAesKeyGenParams; |
106 class WebCryptoHmacImportParams; | 119 class WebCryptoHmacImportParams; |
107 class WebCryptoHmacKeyGenParams; | 120 class WebCryptoHmacKeyGenParams; |
108 class WebCryptoAesGcmParams; | 121 class WebCryptoAesGcmParams; |
109 class WebCryptoRsaOaepParams; | 122 class WebCryptoRsaOaepParams; |
110 class WebCryptoAesCtrParams; | 123 class WebCryptoAesCtrParams; |
111 class WebCryptoRsaHashedKeyGenParams; | 124 class WebCryptoRsaHashedKeyGenParams; |
112 class WebCryptoRsaHashedImportParams; | 125 class WebCryptoRsaHashedImportParams; |
113 class WebCryptoRsaPssParams; | 126 class WebCryptoRsaPssParams; |
| 127 class WebCryptoEcdsaParams; |
| 128 class WebCryptoEcKeyGenParams; |
| 129 class WebCryptoEcKeyImportParams; |
114 | 130 |
115 class WebCryptoAlgorithmParams; | 131 class WebCryptoAlgorithmParams; |
116 class WebCryptoAlgorithmPrivate; | 132 class WebCryptoAlgorithmPrivate; |
117 | 133 |
118 // The WebCryptoAlgorithm represents a normalized algorithm and its parameters. | 134 // The WebCryptoAlgorithm represents a normalized algorithm and its parameters. |
119 // * Immutable | 135 // * Immutable |
120 // * Threadsafe | 136 // * Threadsafe |
121 // * Copiable (cheaply) | 137 // * Copiable (cheaply) |
122 // | 138 // |
123 // If WebCryptoAlgorithm "isNull()" then it is invalid to call any of the other | 139 // If WebCryptoAlgorithm "isNull()" then it is invalid to call any of the other |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 BLINK_PLATFORM_EXPORT const WebCryptoAesCbcParams* aesCbcParams() const; | 173 BLINK_PLATFORM_EXPORT const WebCryptoAesCbcParams* aesCbcParams() const; |
158 BLINK_PLATFORM_EXPORT const WebCryptoAesKeyGenParams* aesKeyGenParams() cons
t; | 174 BLINK_PLATFORM_EXPORT const WebCryptoAesKeyGenParams* aesKeyGenParams() cons
t; |
159 BLINK_PLATFORM_EXPORT const WebCryptoHmacImportParams* hmacImportParams() co
nst; | 175 BLINK_PLATFORM_EXPORT const WebCryptoHmacImportParams* hmacImportParams() co
nst; |
160 BLINK_PLATFORM_EXPORT const WebCryptoHmacKeyGenParams* hmacKeyGenParams() co
nst; | 176 BLINK_PLATFORM_EXPORT const WebCryptoHmacKeyGenParams* hmacKeyGenParams() co
nst; |
161 BLINK_PLATFORM_EXPORT const WebCryptoAesGcmParams* aesGcmParams() const; | 177 BLINK_PLATFORM_EXPORT const WebCryptoAesGcmParams* aesGcmParams() const; |
162 BLINK_PLATFORM_EXPORT const WebCryptoRsaOaepParams* rsaOaepParams() const; | 178 BLINK_PLATFORM_EXPORT const WebCryptoRsaOaepParams* rsaOaepParams() const; |
163 BLINK_PLATFORM_EXPORT const WebCryptoAesCtrParams* aesCtrParams() const; | 179 BLINK_PLATFORM_EXPORT const WebCryptoAesCtrParams* aesCtrParams() const; |
164 BLINK_PLATFORM_EXPORT const WebCryptoRsaHashedImportParams* rsaHashedImportP
arams() const; | 180 BLINK_PLATFORM_EXPORT const WebCryptoRsaHashedImportParams* rsaHashedImportP
arams() const; |
165 BLINK_PLATFORM_EXPORT const WebCryptoRsaHashedKeyGenParams* rsaHashedKeyGenP
arams() const; | 181 BLINK_PLATFORM_EXPORT const WebCryptoRsaHashedKeyGenParams* rsaHashedKeyGenP
arams() const; |
166 BLINK_PLATFORM_EXPORT const WebCryptoRsaPssParams* rsaPssParams() const; | 182 BLINK_PLATFORM_EXPORT const WebCryptoRsaPssParams* rsaPssParams() const; |
| 183 BLINK_PLATFORM_EXPORT const WebCryptoEcdsaParams* ecdsaParams() const; |
| 184 BLINK_PLATFORM_EXPORT const WebCryptoEcKeyGenParams* ecKeyGenParams() const; |
| 185 BLINK_PLATFORM_EXPORT const WebCryptoEcKeyImportParams* ecKeyImportParams()
const; |
167 | 186 |
168 // Returns true if the provided algorithm ID is for a hash (in other words,
SHA-*) | 187 // Returns true if the provided algorithm ID is for a hash (in other words,
SHA-*) |
169 BLINK_PLATFORM_EXPORT static bool isHash(WebCryptoAlgorithmId); | 188 BLINK_PLATFORM_EXPORT static bool isHash(WebCryptoAlgorithmId); |
170 | 189 |
171 private: | 190 private: |
172 BLINK_PLATFORM_EXPORT void assign(const WebCryptoAlgorithm& other); | 191 BLINK_PLATFORM_EXPORT void assign(const WebCryptoAlgorithm& other); |
173 BLINK_PLATFORM_EXPORT void reset(); | 192 BLINK_PLATFORM_EXPORT void reset(); |
174 | 193 |
175 WebPrivatePtr<WebCryptoAlgorithmPrivate> m_private; | 194 WebPrivatePtr<WebCryptoAlgorithmPrivate> m_private; |
176 }; | 195 }; |
177 | 196 |
178 } // namespace blink | 197 } // namespace blink |
179 | 198 |
180 #endif | 199 #endif |
OLD | NEW |