Throw error for unsupported key algorithms.#61
Conversation
Throw error from `AsymmetricKey.getAlgorithm()` if an unsupported encoded key algorithm is found. This may be indirectly called from the constructor and other functions.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #61 +/- ##
==========================================
+ Coverage 49.69% 49.86% +0.16%
==========================================
Files 10 10
Lines 1831 1837 +6
==========================================
+ Hits 910 916 +6
Misses 921 921
Continue to review full report in Codecov by Sentry.
|
|
This needs more work. It's doing encoded base58 prefix checking with the assumption this is equivalent to checking the leading encoded bytes. That is not correct in the case of bls12_381-g2-pub multicodec check for [0xeb, 0x01, ...publickey(96)]. If publickey[0] > 128, then the base58 multibase encoded prefix is zUC7, but if it's <=128, then prefix is zUC6. (Need to check math to see if those are the only values). May be able to map two prefixes to the same algorithm. Or may need to do partial byte decoding for bytes to check. Or perhaps some bit mask or base58 mask of the prefix bytes. Need to check other values and code for this issue as well. |
|
What about mapping to |
|
@davidlehn, this PR needs to be rebased which will bring in the valid |
Throw error from
AsymmetricKey.getAlgorithm()if an unsupported encoded key algorithm is found. This may be indirectly called from the constructor and other functions.This helps when unsupported or bad key data is used which would previously be partially processed but with the algorithm field set to undefined leading to later issues that were difficult to debug.