/ go Public
crypto/rsa: rsa.PrivateKey with json.Unmarshal and Go1.20 results in slow keys #59695
Tracked by #57752
The path to resolution is known, but the work has not been done.
What version of Go are you using (
Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
What did you do?
If you create an
rsa.PrivateKey, then call
json.Marshal, then call
json.Unmarshal, the resulting key "works" but is 3X slower for signing operations. The problem is that Go 1.20 added private fields to
rsa.PrecomputedValueswhich do not get round-tripped. The resulting keys need to have
key.Precompute()called to restore their performance. The following test fails on Go 1.20, but works on Go 1.19. The included benchmark demonstrates the performance problem.
From Issue #59442 , it seems like we may want to preserve the existing behavior: #59442 (comment)
What did you expect to see?
The test should pass, and the benchmark should show the two cases have approximately the same performance, like on Go 1.19:
What did you see instead?
The test fails, showing that the round tripped key has nil fields:
The benchmark shows ~3X slower signing until calling
The text was updated successfully, but these errors were encountered: