I'd like to propose a way of early and fast detection of PEM decryption errors.
How this check works: it uses the ASN.1 basic encoding rules (BER) to parse the first length field. This length field will contain a number which, when [properly decoded and] parsed, contains the length of the PEM encoded message blob (plus the 2-4 bytes declaring this length). The power of doing this size comparison check via length field is that the decoding routine will then have a verification, with high certainty, that the blob was decoded properly -- and since this does not depend on knowing which kind of crypto pkcs PEM file is being decoded, it is not tied to the knowing or testing any of the pkcs formats; thus it is forward compatible.
The text was updated successfully, but these errors were encountered:
ianlancetaylor
changed the title
crypto/x509: decryption of PEM file failure not being caught
proposal: crypto/x509: decryption of PEM file failure not being caught
Jan 5, 2021
I'd like to propose a way of early and fast detection of PEM decryption errors.
How this check works: it uses the ASN.1 basic encoding rules (BER) to parse the first length field. This length field will contain a number which, when [properly decoded and] parsed, contains the length of the PEM encoded message blob (plus the 2-4 bytes declaring this length). The power of doing this size comparison check via length field is that the decoding routine will then have a verification, with high certainty, that the blob was decoded properly -- and since this does not depend on knowing which kind of crypto pkcs PEM file is being decoded, it is not tied to the knowing or testing any of the pkcs formats; thus it is forward compatible.
Please see the proposal here
https://go-review.googlesource.com/c/proposal/+/281454
and pull request here
#43463
View pull request discussion here
https://go-review.googlesource.com/c/go/+/281112
resolves issue:
#10171
The text was updated successfully, but these errors were encountered: