1
1
<!DOCTYPE html>
2
2
< html lang ="en ">
3
3
< head >
4
- < meta charset ="utf-8 ">
4
+ < meta charset ="utf-8 " / >
5
5
< title > Web Crypto API example</ title >
6
- < link rel ="stylesheet " href ="style.css ">
6
+ < link rel ="stylesheet " href ="style.css " / >
7
7
</ head >
8
8
9
9
< body >
10
10
< main >
11
11
< h1 > Web Crypto: sign/verify</ h1 >
12
12
13
13
< section class ="description ">
14
- < p > This page shows the use of the < code > sign()</ code > and < code > verify()</ code > functions of the < a href ="https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API "> Web Crypto API</ a > . It contains four separate examples, one for each signing algorithm supported:</ p >
15
- < ul >
14
+ < p >
15
+ This page shows how to use the < code > sign()</ code > and
16
+ < code > verify()</ code > functions of the
17
+ < a
18
+ href ="https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API "
19
+ > Web Crypto API</ a
20
+ > . It contains examples for the following signing algorithms:
21
+ </ p >
22
+ < ol >
16
23
< li > "RSASSA-PKCS1-v1_5"</ li >
17
24
< li > "RSA-PSS"</ li >
18
25
< li > "ECDSA"</ li >
19
26
< li > "HMAC"</ li >
20
- </ ul >
21
- < hr />
27
+ < li >
28
+ "Ed25519"
29
+ < ul >
30
+ < li class ="caution-list-item ">
31
+ < span class ="caution "> Caution: </ span > For information about
32
+ Ed25519 support, see
33
+ < a
34
+ href ="https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto#browser_compatibility "
35
+ > SubtleCrypto: Browser compatibility</ a
36
+ >
37
+ and
38
+ < a
39
+ href ="https://blogs.igalia.com/jfernandez/2023/06/20/secure-curves-in-the-web-cryptography-api/ "
40
+ > Secure Curves in the Web Cryptography API</ a
41
+ > . Chrome requires the
42
+ < code > enable-experimental-web-platform-features</ code >
43
+ preference to be set via
44
+ < a
45
+ href ="https://peter.sh/experiments/chromium-command-line-switches/#enable-experimental-web-platform-features "
46
+ > command-line switch</ a
47
+ >
48
+ or via
49
+ < code
50
+ > chrome://flags/#enable-experimental-web-platform-features</ code
51
+ > .
52
+ </ li >
53
+ </ ul >
54
+ </ li >
55
+ </ ol >
56
+ < hr />
22
57
< p > Each example has four components:</ p >
23
58
< ul >
24
59
< li > A text box containing a message to sign.</ li >
25
60
< li > A representation of the signature.</ li >
26
- < li > A "Sign" button: this signs the text box contents, displays part of the signature, and stores the complete signature.</ li >
27
- < li > A "Verify" button: this verifies the text box contents against the stored signature, and styles the displayed signature according to the result.</ li >
61
+ < li >
62
+ A "Sign" button: this signs the text box contents, displays part of
63
+ the signature, and stores the complete signature.
64
+ </ li >
65
+ < li >
66
+ A "Verify" button: this verifies the text box contents against the
67
+ stored signature, and styles the displayed signature according to
68
+ the result.
69
+ </ li >
28
70
</ ul >
29
71
< p > Try it:</ p >
30
72
< ul >
@@ -41,12 +83,19 @@ <h2 class="sign-verify-heading">RSASSA-PKCS1-v1_5</h2>
41
83
< section class ="sign-verify-controls ">
42
84
< div class ="message-control ">
43
85
< label for ="rsassa-pkcs1-message "> Enter a message to sign:</ label >
44
- < input type ="text " id ="rsassa-pkcs1-message " name ="message " size ="25 "
45
- value ="The owl hoots at midnight ">
86
+ < input
87
+ type ="text "
88
+ id ="rsassa-pkcs1-message "
89
+ name ="message "
90
+ size ="25 "
91
+ value ="The owl hoots at midnight "
92
+ />
46
93
</ div >
47
- < div class ="signature "> Signature:< span class ="signature-value "> </ span > </ div >
48
- < input class ="sign-button " type ="button " value ="Sign ">
49
- < input class ="verify-button " type ="button " value ="Verify ">
94
+ < div class ="signature ">
95
+ Signature:< span class ="signature-value "> </ span >
96
+ </ div >
97
+ < input class ="sign-button " type ="button " value ="Sign " />
98
+ < input class ="verify-button " type ="button " value ="Verify " />
50
99
</ section >
51
100
</ section >
52
101
@@ -55,12 +104,19 @@ <h2 class="sign-verify-heading">RSA-PSS</h2>
55
104
< section class ="sign-verify-controls ">
56
105
< div class ="message-control ">
57
106
< label for ="rsa-pss-message "> Enter a message to sign:</ label >
58
- < input type ="text " id ="rsa-pss-message " name ="message " size ="25 "
59
- value ="The tiger prowls at dawn ">
107
+ < input
108
+ type ="text "
109
+ id ="rsa-pss-message "
110
+ name ="message "
111
+ size ="25 "
112
+ value ="The tiger prowls at dawn "
113
+ />
114
+ </ div >
115
+ < div class ="signature ">
116
+ Signature:< span class ="signature-value "> </ span >
60
117
</ div >
61
- < div class ="signature "> Signature:< span class ="signature-value "> </ span > </ div >
62
- < input class ="sign-button " type ="button " value ="Sign ">
63
- < input class ="verify-button " type ="button " value ="Verify ">
118
+ < input class ="sign-button " type ="button " value ="Sign " />
119
+ < input class ="verify-button " type ="button " value ="Verify " />
64
120
</ section >
65
121
</ section >
66
122
@@ -69,12 +125,19 @@ <h2 class="sign-verify-heading">ECDSA</h2>
69
125
< section class ="sign-verify-controls ">
70
126
< div class ="message-control ">
71
127
< label for ="ecdsa-message "> Enter a message to sign:</ label >
72
- < input type ="text " id ="ecdsa-message " name ="message " size ="25 "
73
- value ="The eagle flies at twilight ">
128
+ < input
129
+ type ="text "
130
+ id ="ecdsa-message "
131
+ name ="message "
132
+ size ="25 "
133
+ value ="The eagle flies at twilight "
134
+ />
74
135
</ div >
75
- < div class ="signature "> Signature:< span class ="signature-value "> </ span > </ div >
76
- < input class ="sign-button " type ="button " value ="Sign ">
77
- < input class ="verify-button " type ="button " value ="Verify ">
136
+ < div class ="signature ">
137
+ Signature:< span class ="signature-value "> </ span >
138
+ </ div >
139
+ < input class ="sign-button " type ="button " value ="Sign " />
140
+ < input class ="verify-button " type ="button " value ="Verify " />
78
141
</ section >
79
142
</ section >
80
143
@@ -83,20 +146,48 @@ <h2 class="sign-verify-heading">HMAC</h2>
83
146
< section class ="sign-verify-controls ">
84
147
< div class ="message-control ">
85
148
< label for ="hmac-message "> Enter a message to sign:</ label >
86
- < input type ="text " id ="hmac-message " name ="message " size ="25 "
87
- value ="The bunny hops at teatime ">
149
+ < input
150
+ type ="text "
151
+ id ="hmac-message "
152
+ name ="message "
153
+ size ="25 "
154
+ value ="The bunny hops at teatime "
155
+ />
156
+ </ div >
157
+ < div class ="signature ">
158
+ Signature:< span class ="signature-value "> </ span >
159
+ </ div >
160
+ < input class ="sign-button " type ="button " value ="Sign " />
161
+ < input class ="verify-button " type ="button " value ="Verify " />
162
+ </ section >
163
+ </ section >
164
+
165
+ < section class ="sign-verify ed25519 ">
166
+ < h2 class ="sign-verify-heading "> Ed25519</ h2 >
167
+ < section class ="sign-verify-controls ">
168
+ < div class ="message-control ">
169
+ < label for ="ed25519-message "> Enter a message to sign:</ label >
170
+ < input
171
+ type ="text "
172
+ id ="ed25519-message "
173
+ name ="message "
174
+ size ="25 "
175
+ value ="The lion roars near dawn "
176
+ />
177
+ </ div >
178
+ < div class ="signature ">
179
+ Signature:< span class ="signature-value "> </ span >
88
180
</ div >
89
- < div class ="signature "> Signature:< span class ="signature-value "> </ span > </ div >
90
- < input class ="sign-button " type ="button " value ="Sign ">
91
- < input class ="verify-button " type ="button " value ="Verify ">
181
+ < input class ="sign-button " type ="button " value ="Sign " />
182
+ < input class ="verify-button " type ="button " value ="Verify " />
92
183
</ section >
93
184
</ section >
94
185
</ section >
95
186
</ main >
96
-
97
187
</ body >
98
188
< script src ="rsassa-pkcs1.js "> </ script >
99
189
< script src ="rsa-pss.js "> </ script >
100
190
< script src ="ecdsa.js "> </ script >
101
191
< script src ="hmac.js "> </ script >
192
+ < script src ="ed25519.js "> </ script >
102
193
</ html >
0 commit comments