Skip to content

Commit da46be2

Browse files
davidbenaddaleax
authored andcommitted
crypto: fix public key encoding name in comment
PKCS#8 describes an encoding for private keys, not public keys. Using the name as a format usually refers to the PrivateKeyInfo structure it defines. (Or sometimes the EncryptedPrivateKeyInfo variant or the little-used OneAsymmetricKey extension defined in RFC 5958.) None of these structures can hold public keys to begin with. d2i_PUBKEY actually parses the public key analogous format defined in X.509, SubjectPublicKeyInfo. This function already uses "X.509" to refer to an entire certificate, so say SubjectPublicKeyInfo in the comment. (The abbreviation SPKI sometimes refers to SubjectPublicKeyInfo, e.g. in RFC 7469, but it can also an alternate S-expression-based PKI to X.509, Simple Public Key Infrastructure. To avoid confusion, stick with the expanded name.) PR-URL: #25736 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 18b344c commit da46be2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/node_crypto.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2721,7 +2721,7 @@ static ParsePublicKeyResult ParsePublicKeyPEM(EVPKeyPointer* pkey,
27212721

27222722
ParsePublicKeyResult ret;
27232723

2724-
// Try PKCS#8 first.
2724+
// Try parsing as a SubjectPublicKeyInfo first.
27252725
ret = TryParsePublicKey(pkey, bp, "PUBLIC KEY",
27262726
[](const unsigned char** p, long l) { // NOLINT(runtime/int)
27272727
return d2i_PUBKEY(nullptr, p, l);

0 commit comments

Comments
 (0)