Skip to content

Commit b02de90

Browse files
save file
1 parent b244984 commit b02de90

1 file changed

Lines changed: 54 additions & 8 deletions

File tree

blog/26-04-26/x509-certificates-in-js---encrypt-decrypt-data/x509-certificates-in-js---encrypt-decrypt-data.html

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,38 +154,84 @@ <h4>
154154
</ul>
155155
</div>
156156

157-
<div>
158157

159-
RSA encrypt / decrypt in the browser
158+
<div class=blog-text>
159+
160+
<h3>The Secure Workflow</h3>
161+
<p>The correct steps for sending a secure payload using x509 private key and certificate:</p>
162+
<ol>
163+
<li>
164+
<p>Receiver generates RSA Private Key &amp; X.509 Certificate (with Key Encipherment allowed).</p>
165+
</li>
166+
<li>
167+
<p>Receiver sends the X.509 Certificate to the Sender.</p>
168+
</li>
169+
<li>
170+
<p>Sender generates a random AES-GCM key and a 96-bit IV.</p>
171+
</li>
172+
<li>
173+
<p>Sender encrypts the payload with the AES key and IV.</p>
174+
</li>
175+
<li>
176+
<p>Sender encrypts the AES key using the Receiver's RSA Public Key (from the cert).</p>
177+
</li>
178+
<li>
179+
<p>Sender sends three things to the Receiver:</p>
180+
<ul>
181+
<li>
182+
<p>The encrypted payload.</p>
183+
</li>
184+
<li>
185+
<p>The 96-bit IV (unencrypted, this is safe to expose).</p>
186+
</li>
187+
<li>
188+
<p>The RSA-encrypted AES key.</p>
189+
</li>
190+
</ul>
191+
</li>
192+
<li>
193+
<p>Receiver uses their RSA Private Key to decrypt the AES key.</p>
194+
</li>
195+
<li>
196+
<p>Receiver uses the decrypted AES key + the IV to decrypt the payload.</p>
197+
</li>
198+
</ol>
160199

161200
</div>
162201

202+
203+
<h2>
204+
205+
RSA encrypt / decrypt in the browser
206+
207+
</h2>
208+
163209
<snippet-console component id=x509-browser src='ex/rsa-encrypt-decrypt-browser.js'></snippet-console>
164210

165211

166-
<div>
212+
<h2>
167213

168214
RSA encrypt / decrypt in nodejs
169215

170-
</div>
216+
</h2>
171217

172218
<snippet-editor component id=x509-nodejs src='ex/rsa-encrypt-decrypt-nodejs.js'></snippet-editor>
173219

174220

175-
<div>
221+
<h2>
176222

177223
AES encrypt / decrypt in the browser
178224

179-
</div>
225+
</h2>
180226

181227
<snippet-console component id=aes-browser src='ex/aes-encrypt-decrypt-browser.js'></snippet-console>
182228

183229

184-
<div>
230+
<h2>
185231

186232
AES encrypt / decrypt in nodejs
187233

188-
</div>
234+
</h2>
189235

190236
<snippet-editor component id=aes-nodejs src='ex/aes-encrypt-decrypt-nodejs.js'></snippet-editor>
191237

0 commit comments

Comments
 (0)