Fix invalid RSA private key PKCS8 encoding - #120
Conversation
…mpatibility between backends
| This is incorrect parsing and only works because the legacy PKCS1-to-PKCS8 | ||
| encoding was also incorrect. | ||
| """ | ||
| return der_key[len(LEGACY_INVALID_PKCS8_RSA_HEADER):] |
There was a problem hiding this comment.
Please add a check that the prefix of this invalid key is, in fact, equal to LEGACY_INVALID_PKCS8_RSA_HEADER, else reject.
There was a problem hiding this comment.
Check added looking for the legacy header followed immediately by an ASN1 sequence identifier. That will protect against the case where an otherwise-invalid key is processed here, since for 2048-bit keys the legacy prefix is actually correct, but incomplete.
… for known legacy prefix in legacy parsing
Codecov Report
@@ Coverage Diff @@## backend-explicit-tests #120 +/- ##
===========================================================
- Coverage 96.86% 68.99% -27.88%
===========================================================
Files 13 13 Lines 1022 1032 +10 ===========================================================
- Hits 990 712 -278 - Misses 32 320 +288
Continue to review full report at Codecov.
|
mpdavis
commented
Dec 27, 2018
Other than the merge conflict, this LGTM. |
mattsb42-aws
commented
Dec 27, 2018
Merge conflict resolved, and since it did a full branch merge, all the tests should actually pass now. :) |
This addresses #119 to fix the way that the
rsa_backendmodule was converting PKCS1 keys to PKCS8. I left a fallback on read to attempt the old methodology if the valid parsing fails, but writes will only every use the valid encoding.NOTE: The Firebase tests will still fail. That is addressed in #118. Also, some of the
pyca/cryptographyand compatibility tests will fail. Those are addressed in #116 and #117.