-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
3792 lines (3764 loc) · 144 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Secure Curves in the Web Cryptography API</title>
<script src="https://www.w3.org/Tools/respec/respec-w3c" class="remove"></script>
<script class='remove'>
"use strict";
// See https://github.com/w3c/respec/wiki/ for how to configure ReSpec
var respecConfig = {
"github": "WICG/webcrypto-secure-curves",
"editors": [
{
name: "Daniel Huigens",
url: "mailto:[email protected]",
company: "Proton AG",
companyURL: "https://proton.me/",
},
],
"shortName": "webcrypto-secure-curves",
"specStatus": "CG-DRAFT",
"group": "wicg",
"xref": ["WebIDL", "WebCryptoAPI"],
"localBiblio": {
"SafeCurves": {
"title": "Daniel J. Bernstein and Tanja Lange. SafeCurves: choosing safe curves for elliptic-curve cryptography",
"href": "https://safecurves.cr.yp.to/",
}
},
};
</script>
</head>
<body>
<section id="abstract">
<p>
This specification defines a number of algorithms for the [[[WebCryptoAPI]]],
namely X25519 and X448 [[RFC7748]], and Ed25519 and Ed448 [[RFC8032]].
</p>
</section>
<section id="sotd">
<p>
This is an unofficial proposal.
</p>
</section>
<section id="introduction" class="informative">
<h2>Introduction</h2>
<p>
The [[[WebCryptoAPI]]] currently does not specify any "safe curves" [[SafeCurves]].
Among the safe curves, Curve25519 and Curve448 have gained the most traction, and
have been specified for use in TLS 1.3, among others. This specification aims to
expose these algorithms to the web platform.
To this end, this specification defines a number of algorithms and operations for
the [[[WebCryptoAPI]]], namely key agreement using X25519 and X448 [[RFC7748]], and
signing and verifying using Ed25519 and Ed448 [[RFC8032]].
</p>
</section>
<section id="specification-conventions">
<h2>Specification Conventions</h3>
<p>
This specification follows the <a data-cite="WebCryptoAPI#algorithm-conventions">conventions</a>
laid out in Section 18.3 of [[WebCryptoAPI]]. None of the algorithms defined here
are required to be implemented, but if a conforming User Agent implements an
algorithm, it MUST implement all of the supported operations specified in this
document, and must perform the steps to <a data-cite="WebCryptoAPI#concept-define-an-algorithm">define an algorithm</a>
specified in section 18.4.3 of [[WebCryptoAPI]] for each of the supported operations.
</p>
</section>
<section id="x25519">
<h3>X25519</h3>
<section id="x25519-description" class="informative">
<h4>Description</h4>
<p>
The "`X25519`" algorithm identifier is used to perform
key agreement using the X25519 algorithm specified in
[[RFC7748]].
</p>
</section>
<section id="x25519-registration">
<h4>Registration</h4>
<p>
The <a data-cite="WebCryptoAPI#recognized-algorithm-name">recognized algorithm name</a>
for this algorithm is "`X25519`".
</p>
<table>
<thead>
<tr>
<th><a data-cite="WebCryptoAPI#supported-operations">Operation</a></th>
<th><a data-cite="WebCryptoAPI#algorithm-specific-params">Parameters</a></th>
<th><a data-cite="WebCryptoAPI#algorithm-result">Result</a></th>
</tr>
</thead>
<tbody>
<tr>
<td>deriveBits</td>
<td>{{EcdhKeyDeriveParams}}</td>
<td><a data-cite="WebCryptoAPI#dfn-octet-string">octet string</a></td>
</tr>
<tr>
<td>generateKey</td>
<td>None</td>
<td>{{CryptoKeyPair}}</td>
</tr>
<tr>
<td>importKey</td>
<td>None</td>
<td>{{CryptoKey}}</td>
</tr>
<tr>
<td>exportKey</td>
<td>None</td>
<td>object</td>
</tr>
</tbody>
</table>
</section>
<section id="x25519-operations">
<h4>Operations</h4>
<dl>
<dt>Derive Bits</dt>
<dd>
<ol>
<li>
<p>
If the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-type">[[\type]]</a> internal slot of
|key| is not {{KeyType/"private"}}, then [= exception/throw =] an {{InvalidAccessError}}.
</p>
</li>
<li>
<p>
Let |publicKey| be the
{{EcdhKeyDeriveParams/public}} member of
|normalizedAlgorithm|.
</p>
</li>
<li>
<p>
If the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-type">[[\type]]</a> internal slot of
|publicKey| is not "`public`", then [= exception/throw =] an {{InvalidAccessError}}.
</p>
</li>
<li>
<p>
If the {{KeyAlgorithm/name}} attribute of
the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-algorithm">[[\algorithm]]</a> internal slot of
|publicKey| is not equal to the {{KeyAlgorithm/name}} property of the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-algorithm">[[\algorithm]]</a> internal slot of
|key|, then [= exception/throw =] an {{InvalidAccessError}}.
</p>
</li>
<li>
<p>
Let |secret| be the result of performing the X25519 function specified in
[[RFC7748]] Section 5 with |key| as the X25519 private key |k|
and the X25519 public key represented by the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-handle">[[\handle]]</a>
internal slot of |publicKey| as the X25519 public key |u|.
</p>
</li>
<li>
<p>
If |secret| is the all-zero value,
then [= exception/throw =] a {{OperationError}}.
This check must be performed in constant-time, as per [[RFC7748]] Section 6.1.
</p>
</li>
<li>
<dl class="switch">
<dt>If |length| is null:</dt>
<dd>Return |secret|</dd>
<dt>Otherwise:</dt>
<dd>
<dl class="switch">
<dt>
If the length of |secret| in bits is less than
|length|:
</dt>
<dd>
[= exception/throw =] an
{{OperationError}}.
</dd>
<dt>Otherwise:</dt>
<dd>
Return an <a data-cite="WebCryptoAPI#octet-string-containing">octet string containing</a> the first |length| bits of |secret|.
</dd>
</dl>
</dd>
</dl>
</li>
</ol>
</dd>
<dt>Generate Key</dt>
<dd>
<ol>
<li>
<p>
If |usages| contains an entry which is not
"`deriveKey`" or "`deriveBits`"
then [= exception/throw =] a
{{SyntaxError}}.
</p>
</li>
<li>
<p>
Generate an X25519 key pair, with the private key being 32 random bytes,
and the public key being `X25519(a, 9)`,
as defined in [[RFC7748]], section 6.1.
</p>
</li>
<li>
<p>
Let |algorithm| be a new {{KeyAlgorithm}} object.
</p>
</li>
<li>
<p>
Set the {{KeyAlgorithm/name}} attribute of
|algorithm| to "`X25519`".
</p>
</li>
<li>
<p>
Let |publicKey| be a new {{CryptoKey}} associated with the
[= relevant global object =]
of `this` [[HTML]], and
representing the public key of the generated key pair.
</p>
</li>
<li>
<p>
Set the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-type">[[\type]]</a> internal slot of
|publicKey| to "`public`"
</p>
</li>
<li>
<p>
Set the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-algorithm">[[\algorithm]]</a> internal
slot of |publicKey| to |algorithm|.
</p>
</li>
<li>
<p>
Set the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-extractable">[[\extractable]]</a> internal
slot of |publicKey| to true.
</p>
</li>
<li>
<p>
Set the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-usages">[[\usages]]</a> internal slot of
|publicKey| to be the empty list.
</p>
</li>
<li>
<p>
Let |privateKey| be a new {{CryptoKey}} associated with the
[= relevant global object =]
of `this` [[HTML]], and
representing the private key of the generated key pair.
</p>
</li>
<li>
<p>
Set the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-type">[[\type]]</a> internal slot of
|privateKey| to {{KeyType/"private"}}
</p>
</li>
<li>
<p>
Set the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-algorithm">[[\algorithm]]</a> internal
slot of |privateKey| to |algorithm|.
</p>
</li>
<li>
<p>
Set the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-extractable">[[\extractable]]</a> internal
slot of |privateKey| to |extractable|.
</p>
</li>
<li>
<p>
Set the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-usages">[[\usages]]</a> internal slot of
|privateKey| to be the
<a data-cite="WebCryptoAPI#concept-usage-intersection">usage intersection</a> of
|usages| and `[ "deriveKey", "deriveBits" ]`.
</p>
</li>
<li>
<p>
Let |result| be a new {{CryptoKeyPair}}
dictionary.
</p>
</li>
<li>
<p>
Set the {{CryptoKeyPair/publicKey}} attribute
of |result| to be |publicKey|.
</p>
</li>
<li>
<p>
Set the {{CryptoKeyPair/privateKey}} attribute
of |result| to be |privateKey|.
</p>
</li>
<li>
<p>
Return the result of converting |result| to an ECMAScript Object, as
defined by [[WebIDL]].
</p>
</li>
</ol>
</dd>
<dt>Import Key</dt>
<dd>
<ol>
<li>
<p>Let |keyData| be the key data to be imported.</p>
</li>
<li>
<dl class="switch">
<dt>If |format| is {{KeyFormat/"spki"}}:</dt>
<dd>
<ol>
<li>
<p>
If |usages| is not empty
then [= exception/throw =] a
{{SyntaxError}}.
</p>
</li>
<li>
<p>
Let |spki| be the result of running the
<a data-cite="WebCryptoAPI#concept-parse-a-spki">parse a subjectPublicKeyInfo</a>
algorithm over |keyData|.
</p>
</li>
<li>
<p>
If an error occurred while parsing,
then [= exception/throw =] a
{{DataError}}.
</p>
</li>
<li>
<p>
If the `algorithm` object identifier field of the
`algorithm` AlgorithmIdentifier field of |spki| is
not equal to the `id-X25519`
object identifier defined in [[RFC8410]],
then [= exception/throw =] a
{{DataError}}.
</p>
</li>
<li>
<p>
If the `parameters` field of the `algorithm`
AlgorithmIdentifier field of |spki| is present,
then [= exception/throw =] a
{{DataError}}.
</p>
</li>
<li>
<p>
Let |publicKey| be the X25519 public key identified by
the `subjectPublicKey` field of |spki|.
</p>
</li>
<li>
<p>
Let |key| be a new {{CryptoKey}} associated with the
[= relevant global object =]
of `this` [[HTML]], and
that represents |publicKey|.
</p>
</li>
<li>
<p>
Set the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-type">[[\type]]</a> internal slot
of |key| to "`public`"
</p>
</li>
<li>
<p>
Let |algorithm| be a new {{KeyAlgorithm}}.
</p>
</li>
<li>
<p>
Set the {{KeyAlgorithm/name}} attribute of
|algorithm| to "`X25519`".
</p>
</li>
<li>
<p>
Set the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-algorithm">[[\algorithm]]</a>
internal slot of |key| to |algorithm|.
</p>
</li>
</ol>
</dd>
<dt>If |format| is {{KeyFormat/"pkcs8"}}:</dt>
<dd>
<ol>
<li>
<p>
If |usages| contains an entry which is not
"`deriveKey`" or "`deriveBits`"
then [= exception/throw =] a
{{SyntaxError}}.
</p>
</li>
<li>
<p>
Let |privateKeyInfo| be the result of running the
<a data-cite="WebCryptoAPI#concept-parse-a-privateKeyInfo">parse a privateKeyInfo</a>
algorithm over |keyData|.
</p>
</li>
<li>
<p>
If an error occurs while parsing,
then [= exception/throw =] a
{{DataError}}.
</p>
</li>
<li>
<p>
If the `algorithm` object identifier field of the
`privateKeyAlgorithm` PrivateKeyAlgorithm field of
|privateKeyInfo| is not equal to the
`id-X25519` object identifier defined in [[RFC8410]],
then [= exception/throw =] a
{{DataError}}.
</p>
</li>
<li>
<p>
If the `parameters` field of the
`privateKeyAlgorithm` PrivateKeyAlgorithmIdentifier field
of |privateKeyInfo| is present,
then [= exception/throw =] a
{{DataError}}.
</p>
</li>
<li>
<p>
Let |curvePrivateKey| be the result of performing the <a data-cite="WebCryptoAPI#concept-parse-an-asn1-structure">parse an ASN.1 structure</a>
algorithm, with |data| as the `privateKey` field
of |privateKeyInfo|, |structure| as the ASN.1
`CurvePrivateKey` structure specified in Section 7 of [[RFC8410]], and |exactData| set to true.
</p>
</li>
<li>
<p>
If an error occurred while parsing,
then [= exception/throw =] a
{{DataError}}.
</p>
</li>
<li>
<p>
Let |key| be a new {{CryptoKey}} associated with the
[= relevant global object =]
of `this` [[HTML]], and
that represents the X25519 private key identified by |curvePrivateKey|.
</p>
</li>
<li>
<p>
Set the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-type">[[\type]]</a> internal slot
of |key| to {{KeyType/"private"}}
</p>
</li>
<li>
<p>
Let |algorithm| be a new {{KeyAlgorithm}}.
</p>
</li>
<li>
<p>
Set the {{KeyAlgorithm/name}} attribute of
|algorithm| to "`X25519`".
</p>
</li>
<li>
<p>
Set the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-algorithm">[[\algorithm]]</a>
internal slot of |key| to |algorithm|.
</p>
</li>
</ol>
</dd>
<dt>If |format| is {{KeyFormat/"jwk"}}:</dt>
<dd>
<ol>
<li>
<dl class="switch">
<dt>If |keyData| is a {{JsonWebKey}} dictionary:</dt>
<dd><p>Let |jwk| equal |keyData|.</p></dd>
<dt>Otherwise:</dt>
<dd><p>[= exception/Throw =] a {{DataError}}.</p></dd>
</dl>
</li>
<li>
<p>
If the {{JsonWebKey/d}} field is present and if |usages|
contains an entry which is not
"`deriveKey`" or "`deriveBits`"
then [= exception/throw =] a
{{SyntaxError}}.
</p>
</li>
<li>
<p>
If the {{JsonWebKey/d}} field is not present and if |usages| is not
empty
then [= exception/throw =] a
{{SyntaxError}}.
</p>
</li>
<li>
<p>
If the {{JsonWebKey/kty}} field of |jwk| is not
"`OKP`",
then [= exception/throw =] a
{{DataError}}.
</p>
</li>
<li>
<p>
If the {{JsonWebKey/crv}} field of |jwk| is not
"`X25519`",
then [= exception/throw =] a
{{DataError}}.
</p>
</li>
<li>
<p>
If |usages| is non-empty and the {{JsonWebKey/use}} field of |jwk| is present
and is not equal to "`enc`" then [= exception/throw =] a
{{DataError}}.
</p>
</li>
<li>
<p>
If the {{JsonWebKey/key_ops}} field of |jwk| is present, and
is invalid according to the requirements of JSON Web
Key [[JWK]], or it does not contain all of the specified |usages|
values,
then [= exception/throw =] a
{{DataError}}.
</p>
</li>
<li>
<p>
If the {{JsonWebKey/ext}} field of |jwk| is present and
has the value false and |extractable| is true,
then [= exception/throw =] a
{{DataError}}.
</p>
</li>
<li>
<dl class="switch">
<dt>If the {{JsonWebKey/d}} field is present:</dt>
<dd>
<ol>
<li>
<p>
If |jwk| does not meet the requirements of
the JWK private key format described in Section 2
of [[RFC8037]], then [= exception/throw =] a {{DataError}}.
</p>
</li>
<li>
<p>
Let |key| be a new {{CryptoKey}} object that represents the
X25519 private key identified by interpreting
|jwk| according to Section 2 of [[RFC8037]].
</p>
</li>
<li>
<p>
Set the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-type">[[\type]]</a>
internal slot of |Key| to {{KeyType/"private"}}.
</p>
</li>
</ol>
</dd>
<dt>Otherwise:</dt>
<dd>
<ol>
<li>
<p>
If |jwk| does not meet the requirements of
the JWK public key format described in Section 2
of [[RFC8037]], then [= exception/throw =] a {{DataError}}.
</p>
</li>
<li>
<p>
Let |key| be a new {{CryptoKey}} object that represents the
X25519 public key identified by interpreting
|jwk| according to Section 2 of [[RFC8037]].
</p>
</li>
<li>
<p>
Set the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-type">[[\type]]</a>
internal slot of |Key| to {{KeyType/"public"}}.
</p>
</li>
</ol>
</dd>
</dl>
</li>
<li>
<p>
Let |algorithm| be a new instance of a {{KeyAlgorithm}} object.
</p>
</li>
<li>
<p>
Set the {{KeyAlgorithm/name}} attribute of
|algorithm| to "`X25519`".
</p>
</li>
<li>
<p>
Set the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-algorithm">[[\algorithm]]</a>
internal slot of |key| to |algorithm|.
</p>
</li>
</ol>
</dd>
<dt>If |format| is {{KeyFormat/"raw"}}:</dt>
<dd>
<ol>
<li>
<p>
If |usages| is not empty
then [= exception/throw =] a
{{SyntaxError}}.
</p>
</li>
<li>
<p>
Let |algorithm| be a new {{KeyAlgorithm}} object.
</p>
</li>
<li>
<p>
Set the {{KeyAlgorithm/name}} attribute of
|algorithm| to "`X25519`".
</p>
</li>
<li>
<p>
Let |key| be a new {{CryptoKey}} associated with the
[= relevant global object =]
of `this` [[HTML]], and
representing the key data provided in |keyData|.
</p>
</li>
<li>
<p>
Set the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-type">[[\type]]</a> internal slot
of |key| to "`public`"
</p>
</li>
<li>
<p>
Set the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-algorithm">[[\algorithm]]</a>
internal slot of |key| to |algorithm|.
</p>
</li>
</ol>
</dd>
<dt>Otherwise:</dt>
<dd>
<p>
[= exception/throw =] a
{{NotSupportedError}}.
</p>
</dd>
</dl>
</li>
<li>
<p>
Return |key|
</p>
</li>
</ol>
</dd>
<dt>Export Key</dt>
<dd>
<ol>
<li>
<p>
Let |key| be the {{CryptoKey}} to be
exported.
</p>
</li>
<li>
<p>
If the underlying cryptographic key material represented by the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-handle">[[\handle]]</a> internal slot of |key|
cannot be accessed, then [= exception/throw =] an {{OperationError}}.
</p>
</li>
<li>
<dl class="switch">
<dt>If |format| is {{KeyFormat/"spki"}}:</dt>
<dd>
<ol>
<li>
<p>
If the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-type">[[\type]]</a> internal slot
of |key| is not "`public`", then [= exception/throw =] an {{InvalidAccessError}}.
</p>
</li>
<li>
<p>
Let |data| be an instance of the `subjectPublicKeyInfo`
ASN.1 structure defined in [[RFC5280]]
with the following properties:
</p>
<ul>
<li>
<p>
Set the |algorithm| field to an
`AlgorithmIdentifier` ASN.1 type with the following
properties:
</p>
<ul>
<li>
<p>
Set the |algorithm| object identifier to the
`id-X25519` OID defined in [[RFC8410]].
</p>
</li>
</ul>
</li>
<li>
<p>
Set the |subjectPublicKey| field to |keyData|.
</p>
</li>
</ul>
</li>
<li>
<p>
Let |result| be a new {{ArrayBuffer}} associated with the
[= relevant global object =]
of `this` [[HTML]], and containing
|data|.
</p>
</li>
</ol>
</dd>
<dt>If |format| is {{KeyFormat/"pkcs8"}}:</dt>
<dd>
<ol>
<li>
<p>
If the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-type">[[\type]]</a> internal slot
of |key| is not {{KeyType/"private"}}, then [= exception/throw =] an {{InvalidAccessError}}.
</p>
</li>
<li>
<p>
Let |data| be an instance of the `privateKeyInfo`
ASN.1 structure defined in [[RFC5208]]
with the following properties:
</p>
<ul>
<li>
<p>
Set the |version| field to `0`.
</p>
</li>
<li>
<p>
Set the |privateKeyAlgorithm| field to a
`PrivateKeyAlgorithmIdentifier` ASN.1 type with the
following properties:
</p>
<ul>
<li>
<p>
Set the |algorithm| object identifier to the
`id-X25519` OID defined in [[RFC8410]].
</p>
</li>
</ul>
</li>
<li>
<p>
Set the |privateKey| field to the result of DER-encoding
a `CurvePrivateKey` ASN.1 type, as defined in Section 7 of [[RFC8410]], that represents the
X25519 private key represented by the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-handle">[[\handle]]</a> internal slot of
|key|
</p>
</li>
</ul>
</li>
<li>
<p>
Let |result| be a new {{ArrayBuffer}} associated with the
[= relevant global object =]
of `this` [[HTML]], and containing
|data|.
</p>
</li>
</ol>
</dd>
<dt>If |format| is {{KeyFormat/"jwk"}}:</dt>
<dd>
<ol>
<li>
<p>
Let |jwk| be a new {{JsonWebKey}}
dictionary.
</p>
</li>
<li>
<p>
Set the `kty` attribute of |jwk| to
"`OKP`".
</p>
</li>
<li>
<p>
Set the `crv` attribute of |jwk| to
"`X25519`".
</p>
</li>
<li>
<p>
Set the {{JsonWebKey/x}} attribute of |jwk| according to the
definition in Section 2 of [[RFC8037]].
</p>
</li>
<li>
<dl class="switch">
<dt>
If the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-type">[[\type]]</a> internal slot
of |key| is {{KeyType/"private"}}
</dt>
<dd>
Set the {{JsonWebKey/d}} attribute of |jwk| according to the
definition in Section 2 of [[RFC8037]].
</dd>
</dl>
</li>
<li>
<p>
Set the `key_ops` attribute of |jwk| to the {{CryptoKey/usages}} attribute of |key|.
</p>
</li>
<li>
<p>
Set the `ext` attribute of |jwk| to the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-extractable">[[\extractable]]</a> internal slot
of |key|.
</p>
</li>
<li>
<p>
Let |result| be the result of converting |jwk|
to an ECMAScript Object, as defined by [[WebIDL]].
</p>
</li>
</ol>
</dd>
<dt>
If |format| is {{KeyFormat/"raw"}}:
</dt>
<dd>
<ol>
<li>
<p>
If the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-type">[[\type]]</a> internal slot
of |key| is not "`public`", then [= exception/throw =] an {{InvalidAccessError}}.
</p>
</li>
<li>
<p>
Let |data| be an <a data-cite="WebCryptoAPI#dfn-octet-string">octet string</a> representing the X25519
public key represented by the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-handle">[[\handle]]</a> internal slot of
|key|.
</p>
</li>
<li>
<p>
Let |result| be a new {{ArrayBuffer}} associated with the
[= relevant global object =]
of `this` [[HTML]], and containing
|data|.
</p>
</li>
</ol>
</dd>
<dt>Otherwise:</dt>
<dd>
<p>
[= exception/throw =] a
{{NotSupportedError}}.
</p>
</dd>
</dl>
</li>
<li>
<p>
Return |result|.
</p>
</li>
</ol>
</dd>
</dl>
</section>
</section>
<section id="x448">
<h3>X448</h3>
<section id="x448-description" class="informative">
<h4>Description</h4>
<p>
The "`X448`" algorithm identifier is used to perform
key agreement using the X448 algorithm specified in
[[RFC7748]].
</p>
</section>
<section id="x448-registration">
<h4>Registration</h4>
<p>
The <a data-cite="WebCryptoAPI#recognized-algorithm-name">recognized algorithm name</a>
for this algorithm is "`X448`".
</p>
<table>
<thead>
<tr>
<th><a data-cite="WebCryptoAPI#supported-operations">Operation</a></th>
<th><a data-cite="WebCryptoAPI#algorithm-specific-params">Parameters</a></th>
<th><a data-cite="WebCryptoAPI#algorithm-result">Result</a></th>
</tr>
</thead>
<tbody>
<tr>
<td>deriveBits</td>
<td>{{EcdhKeyDeriveParams}}</td>
<td><a data-cite="WebCryptoAPI#dfn-octet-string">octet string</a></td>
</tr>
<tr>
<td>generateKey</td>
<td>None</td>
<td>{{CryptoKeyPair}}</td>
</tr>
<tr>
<td>importKey</td>
<td>None</td>
<td>{{CryptoKey}}</td>
</tr>
<tr>
<td>exportKey</td>
<td>None</td>
<td>object</td>
</tr>
</tbody>
</table>
</section>
<section id="x448-operations">
<h4>Operations</h4>
<dl>
<dt>Derive Bits</dt>
<dd>
<ol>
<li>
<p>
If the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-type">[[\type]]</a> internal slot of
|key| is not {{KeyType/"private"}}, then [= exception/throw =] an {{InvalidAccessError}}.
</p>
</li>
<li>
<p>
Let |publicKey| be the
{{EcdhKeyDeriveParams/public}} member of
|normalizedAlgorithm|.
</p>
</li>
<li>
<p>
If the <a data-cite="WebCryptoAPI#dfn-CryptoKey-slot-type">[[\type]]</a> internal slot of
|publicKey| is not "`public`", then [= exception/throw =] an {{InvalidAccessError}}.
</p>
</li>
<li>
<p>