Skip to content

Commit 8e03c51

Browse files
save file
1 parent dfe1dfb commit 8e03c51

1 file changed

Lines changed: 128 additions & 6 deletions

File tree

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

Lines changed: 128 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,42 @@ <h1 class=title>
8181

8282
<div class=description>
8383
<p>
84-
This blog post describes using x509 certificates to encrypt and decrypt data in a javascript environment. This
84+
This blog post describes using x509 certificates to encrypt and decrypt data in javascript environments. This
8585
can be useful since the public certificate can be made available publicly, even sent via an insecure communication
8686
channel, this public certificate can be used to encrypt data, the encrypted data can be sent to the holder
8787
of the private key, who can subsequently decode the encrypted data using the private key.
88+
<br>
89+
If two parties want to have a bi-directional encrypted communication, they can both send each other their
90+
public certificates.
8891
</p>
92+
</div>
93+
94+
95+
<div class=blog-text>
96+
<h4>
97+
notes :
98+
</h4>
8999
<p>
90-
Node.js supports both PKCS#1 and PKCS#8 private keys, while browsers only support PKCS#8.
91-
This difference comes from how each environment exposes cryptography: Node wraps OpenSSL
92-
(very flexible), while browsers expose WebCrypto (much stricter and standardized).
100+
private keys :
93101
</p>
102+
<ul>
103+
<li>
104+
Browsers only support PKCS#8
105+
</li>
106+
<li>
107+
Node.js supports both PKCS#1 and PKCS#8 private keys
108+
</li>
109+
</ul>
110+
<p>
111+
certificates :
112+
</p>
113+
<ul>
114+
<li>
115+
Browsers require the spki component in der form
116+
</li>
117+
<li>
118+
node.js supports the entire certificate in pem format
119+
</li>
94120
</div>
95121

96122
<div>
@@ -111,8 +137,104 @@ <h1 class=title>
111137
<snippet-editor component id=x509-nodejs src='ex/x509-nodejs.js'></snippet-editor>
112138

113139

114-
115-
140+
<divv class=blog-text>
141+
<h3 class=blog-hdr>
142+
SPKI
143+
</h3>
144+
<p>
145+
SPKI in X.509 stands for Subject Public Key Info.
146+
<br>
147+
It is the part of an X.509 certificate that contains the subject’s public key
148+
and information about the algorithm used with that key.
149+
</p>
150+
151+
<h4>
152+
What SPKI actually contains
153+
</h4>
154+
155+
<p>
156+
The Subject Public Key Info (SPKI) field is a structured ASN.1 block inside every X.509 certificate. It includes:
157+
</p>
158+
<ul>
159+
<li>
160+
The subject’s public key (e.g., RSA, ECDSA, Ed25519)
161+
</li>
162+
<li>
163+
The algorithm identifier for that key (e.g., rsaEncryption, id-ecPublicKey)
164+
</li>
165+
<li>
166+
Any algorithm parameters required by that key type
167+
</li>
168+
</ul>
169+
170+
<p>
171+
This is the part of the certificate that clients use to verify signatures or establish encrypted sessions.
172+
</p>
173+
174+
<h4>
175+
Why SPKI matters
176+
</h4>
177+
<p>
178+
SPKI is essential because:
179+
</p>
180+
<ul>
181+
<li>
182+
It is the actual public key that the certificate binds to an identity.
183+
</li>
184+
<li>
185+
It is used by TLS, code signing, S/MIME, and other PKI systems to verify authenticity.
186+
</li>
187+
<li>
188+
It is the part that gets hashed when generating a certificate pin (HPKP-style pins or modern SPKI pinning in some systems).
189+
</li>
190+
</ul>
191+
<p>
192+
In short, SPKI is the cryptographic heart of the certificate.
193+
</p>
194+
195+
<h4>
196+
Where SPKI sits in the certificate structure
197+
</h4>
198+
<p>
199+
According to the X.509 standard, SPKI is one of the core Version 1 certificate fields,
200+
meaning it has existed since the earliest form of the standard.
201+
<a href='https://learn.microsoft.com/en-us/azure/iot-hub/reference-x509-certificates'>
202+
</a>
203+
</p>
204+
<p>
205+
Typical X.509 structure (simplified):
206+
</p>
207+
208+
<ul>
209+
<li>
210+
Version
211+
</li>
212+
<li>
213+
Serial Number
214+
</li>
215+
<li>
216+
Signature Algorithm
217+
</li>
218+
<li>
219+
Issuer
220+
</li>
221+
<li>
222+
Validity
223+
</li>
224+
<li>
225+
Subject
226+
</li>
227+
<li>
228+
Subject Public Key Info (SPKI)
229+
</li>
230+
<li>
231+
Extensions (v3)
232+
</li>
233+
<li>
234+
Signature
235+
</li>
236+
</ul>
237+
</div>
116238

117239

118240
<log-mod component></log-mod>

0 commit comments

Comments
 (0)