@@ -11,6 +11,8 @@ const {
1111 DataViewPrototypeGetByteOffset,
1212 FunctionPrototypeBind,
1313 Number,
14+ ObjectDefineProperty,
15+ ObjectEntries,
1416 ObjectKeys,
1517 ObjectPrototypeHasOwnProperty,
1618 Promise,
@@ -63,6 +65,7 @@ const { Buffer } = require('buffer');
6365
6466const {
6567 cachedResult,
68+ emitExperimentalWarning,
6669 filterDuplicateStrings,
6770 lazyDOMException,
6871} = require ( 'internal/util' ) ;
@@ -195,26 +198,18 @@ const kSupportedAlgorithms = {
195198 'AES-GCM' : 'AesKeyGenParams' ,
196199 'AES-KW' : 'AesKeyGenParams' ,
197200 'HMAC' : 'HmacKeyGenParams' ,
198- 'X25519' : null ,
199- 'Ed25519' : null ,
200- 'X448' : null ,
201- 'Ed448' : null ,
202201 } ,
203202 'sign' : {
204203 'RSASSA-PKCS1-v1_5' : null ,
205204 'RSA-PSS' : 'RsaPssParams' ,
206205 'ECDSA' : 'EcdsaParams' ,
207206 'HMAC' : null ,
208- 'Ed25519' : null ,
209- 'Ed448' : 'Ed448Params' ,
210207 } ,
211208 'verify' : {
212209 'RSASSA-PKCS1-v1_5' : null ,
213210 'RSA-PSS' : 'RsaPssParams' ,
214211 'ECDSA' : 'EcdsaParams' ,
215212 'HMAC' : null ,
216- 'Ed25519' : null ,
217- 'Ed448' : 'Ed448Params' ,
218213 } ,
219214 'importKey' : {
220215 'RSASSA-PKCS1-v1_5' : 'RsaHashedImportParams' ,
@@ -229,17 +224,11 @@ const kSupportedAlgorithms = {
229224 'AES-CBC' : null ,
230225 'AES-GCM' : null ,
231226 'AES-KW' : null ,
232- 'Ed25519' : null ,
233- 'X25519' : null ,
234- 'Ed448' : null ,
235- 'X448' : null ,
236227 } ,
237228 'deriveBits' : {
238229 'HKDF' : 'HkdfParams' ,
239230 'PBKDF2' : 'Pbkdf2Params' ,
240231 'ECDH' : 'EcdhKeyDeriveParams' ,
241- 'X25519' : 'EcdhKeyDeriveParams' ,
242- 'X448' : 'EcdhKeyDeriveParams' ,
243232 } ,
244233 'encrypt' : {
245234 'RSA-OAEP' : 'RsaOaepParams' ,
@@ -270,6 +259,47 @@ const kSupportedAlgorithms = {
270259 } ,
271260} ;
272261
262+ const experimentalAlgorithms = ObjectEntries ( {
263+ 'X25519' : {
264+ generateKey : null ,
265+ importKey : null ,
266+ deriveBits : 'EcdhKeyDeriveParams' ,
267+ } ,
268+ 'Ed25519' : {
269+ generateKey : null ,
270+ sign : null ,
271+ verify : null ,
272+ importKey : null ,
273+ } ,
274+ 'X448' : {
275+ generateKey : null ,
276+ importKey : null ,
277+ deriveBits : 'EcdhKeyDeriveParams' ,
278+ } ,
279+ 'Ed448' : {
280+ generateKey : null ,
281+ sign : 'Ed448Params' ,
282+ verify : 'Ed448Params' ,
283+ importKey : null ,
284+ } ,
285+ } ) ;
286+
287+ for ( let i = 0 ; i < experimentalAlgorithms . length ; i ++ ) {
288+ const name = experimentalAlgorithms [ i ] [ 0 ] ;
289+ const ops = ObjectEntries ( experimentalAlgorithms [ i ] [ 1 ] ) ;
290+ for ( let j = 0 ; j < ops . length ; j ++ ) {
291+ const { 0 : op , 1 : dict } = ops [ j ] ;
292+ ObjectDefineProperty ( kSupportedAlgorithms [ op ] , name , {
293+ get ( ) {
294+ emitExperimentalWarning ( `The ${ name } Web Crypto API algorithm` ) ;
295+ return dict ;
296+ } ,
297+ __proto__ : null ,
298+ enumerable : true ,
299+ } ) ;
300+ }
301+ }
302+
273303const simpleAlgorithmDictionaries = {
274304 AesGcmParams : { iv : 'BufferSource' , additionalData : 'BufferSource' } ,
275305 RsaHashedKeyGenParams : { hash : 'HashAlgorithmIdentifier' } ,
0 commit comments