Skip to content
Discussion options

You must be logged in to vote

I looked into this, since I was curious too. Short answer: the non-FIPS version of BouncyCastle does not protect private keys in memory. No encryption, no zeroization, no IDisposable.

Here's what I found in the source code.

Asymmetric keys are stored as plain BigInteger

RSA private keys (RsaPrivateCrtKeyParameters) keep all the sensitive values -- p, q, dP, dQ, qInv, the private exponent -- as BigInteger fields. BigInteger is a sealed class with a readonly uint[] for its internal data, so there's no way to zero it out in place. This is the same for EC, DH, and DSA private keys.

What surprised me is that newer algorithms like Ed25519, X25519, and ML-KEM store their private keys as byte[] a…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by okay9109
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants