-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KES secure forgetting #255
Conversation
d46bc60
to
93efd67
Compare
8865739
to
1618f77
Compare
112aa7b
to
92943f1
Compare
d51c39b
to
5305dd1
Compare
f220e2d
to
8cbebe3
Compare
Added cardano-mempool package to the repo, which will later be used in KES secure forgetting and mlocking the memory. See #255
242c7ca
to
b94dc60
Compare
Added cardano-mempool package to the repo, which will later be used in KES secure forgetting and mlocking the memory. See #255
b22e666
to
8288b75
Compare
d30c878
to
5064344
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good. I did review only a portion of this PR, I'll do a follow up review at later point.
cardano-crypto-class/src/Cardano/Crypto/Libsodium/Memory/Internal.hs
Outdated
Show resolved
Hide resolved
cardano-crypto-class/src/Cardano/Crypto/Libsodium/Memory/Internal.hs
Outdated
Show resolved
Hide resolved
cardano-crypto-class/src/Cardano/Crypto/Libsodium/Memory/Internal.hs
Outdated
Show resolved
Hide resolved
cardano-crypto-class/src/Cardano/Crypto/Libsodium/Memory/Internal.hs
Outdated
Show resolved
Hide resolved
6f4166e
to
36de1dc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went through the full implementation. It looks really good. Left some feedback, but nothing critical. I'll go through the test suite in the next day or two.
It is awesome that you were able to move all the logging into the test suite!
I didn't go into test in too much detail at the moment, but I noticed all the KES tests use the same lock. Is the idea to run each test in isolation? From what I know the implementation is totally thread safe, so by adding a lock we aren't making our tests any better. As far as mempool is concerned this lock does nothing for it, because GC is not affected by the lock and can run at any time. Unless I am missing something I'd suggest removing using locks in testing
cardano-crypto-class/src/Cardano/Crypto/Libsodium/Memory/Internal.hs
Outdated
Show resolved
Hide resolved
cardano-crypto-class/src/Cardano/Crypto/Libsodium/Memory/Internal.hs
Outdated
Show resolved
Hide resolved
I've made some more changes, and I think things should be in pretty good shape now. Specifically:
Windows builds are unfortunately still failing on the setup steps, but that is beyond my control and needs to be fixed on master. |
070eb1b
to
35af549
Compare
39b5afb
to
39b2d94
Compare
462e539
to
dea754d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great piece of work.
My comments fall into three categories, but none of them are really blocking this PR, except only maybe the first point:
- In KES newly allocated seed is not zeroed out
- Suggestions with minor improvements
- Some questions about unfinished business in tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice.
Due to IntersectMBO/cardano-base#255 we must set tighter upper bounds to unsure we don't run into 'cabal update' issues as the interfaces have changed heavily
7134327
to
bef6a99
Compare
4356: Fix upper bound for cardano-crypto-xxx packages r=dnadales a=abailly-iohk # Description Due to IntersectMBO/cardano-base#255 we must set tighter upper bounds to unsure we don't run into 'cabal update' issues as the interfaces have changed heavily. Co-authored-by: Arnaud Bailly <arnaud.bailly@iohk.io>
4356: Fix upper bound for cardano-crypto-xxx packages r=dnadales a=abailly-iohk # Description Due to IntersectMBO/cardano-base#255 we must set tighter upper bounds to unsure we don't run into 'cabal update' issues as the interfaces have changed heavily. Co-authored-by: Arnaud Bailly <arnaud.bailly@iohk.io>
bef6a99
to
8e01212
Compare
8e01212
to
def0ed5
Compare
In #255 we somehow removed the ``` c-sources: cbits/blst_util.c ``` from the library. This included the symbol: `size_blst_p1`, which _is_ used in `cardano-crypto-class` 😱 . E.g. https://github.com/input-output-hk/cardano-base/blob/e48f2ec561713f7a0863e58e34004b8099079cab/cardano-crypto-class/src/Cardano/Crypto/EllipticCurve/BLS12_381/Internal.hs#L372 And thus we now run into undefined symbols issues 🤯
In #255 we somehow removed the ``` c-sources: cbits/blst_util.c ``` from the library. This included the symbol: `size_blst_p1`, which _is_ used in `cardano-crypto-class` 😱 . E.g. https://github.com/input-output-hk/cardano-base/blob/e48f2ec561713f7a0863e58e34004b8099079cab/cardano-crypto-class/src/Cardano/Crypto/EllipticCurve/BLS12_381/Internal.hs#L372 And thus we now run into undefined symbols issues 🤯
In #255 we somehow removed the ``` c-sources: cbits/blst_util.c ``` from the library. This included the symbol: `size_blst_p1`, which _is_ used in `cardano-crypto-class` 😱 . E.g. https://github.com/input-output-hk/cardano-base/blob/e48f2ec561713f7a0863e58e34004b8099079cab/cardano-crypto-class/src/Cardano/Crypto/EllipticCurve/BLS12_381/Internal.hs#L372 And thus we now run into undefined symbols issues 🤯
In #255 we somehow removed the ``` c-sources: cbits/blst_util.c ``` from the library. This included the symbol: `size_blst_p1`, which _is_ used in `cardano-crypto-class` 😱 . E.g. https://github.com/input-output-hk/cardano-base/blob/e48f2ec561713f7a0863e58e34004b8099079cab/cardano-crypto-class/src/Cardano/Crypto/EllipticCurve/BLS12_381/Internal.hs#L372 And thus we now run into undefined symbols issues 🤯
This adds "secure forgetting" to the KES signature schemes.
The purpose of KES is to enable forward security, by regularly "evolving" signing keys, such that existing verification keys still work on signatures produced by the new signing key, but the old signing key cannot be inferred from the new one. This means that once a signing key has been evolved, and the old key has been deleted, leaking a new signing key can no longer compromise the integrity of signatures produced by the older key.
For this to actually work, however, it is crucial that absolutely no copies of the old key remain stored anywhere, otherwise there is still a nonzero possibility of leaking them.
This is where "secure forgetting" comes in.
In order to guarantee that sign keys remain in a confined storage location, from which they cannot accidentally leak, and that they are properly erased in a controlled and deterministic fashion, we do the following:
mlock
API pins memory into physical RAM, preventing it to be swapped out to disk (this is important, because "deleting from disk" is not reliably possible on modern hardware).IO
. (Future PRs may provide additional instances, e.g.IOSim
for testing purposes).ForeignPtr
s, and set them up to perform a secure forgetting in the finalizer. This is not intended to be the normal use case, because we cannot be sure when the GC will run, if at all, but it helps mitigate potential programming errors that leave secrets un-forgotten.NOTE that the current implementation as it is here has one loophole: signing keys and seeds are still serializable, and once serialized, they are no longer stored in mlocked memory, and so the protection does not work when the serialization features are used.