5

I want to use the AES implementation in the standard library of crypto in GO.

But as far as I know, I don't have any control where the expanded key is stored and when it is freed, so this can cause a security problem.

I wanted to use memguard (https://github.com/awnumar/memguard) library to secure the key, but I don't have any access to the key after it is expanded.

Any ideas how can I store and manage the key securely?

3
  • 5
    Neither the downvotes nor the close votes make sense. This is a very good question and well explained. And now that it's been raised, I have to wonder what on earth the Go standard library is doing to keep key material secure. Commented Apr 22, 2018 at 17:13
  • 3
    @MichaelHampton Although I did not vote to close the question, there are issues in the question worthy of negative feedback. Notably, there is a mention of an attempt to a solution, but no code to let us understand how that attempt was concretely made. Moreover, the question should not ask for library recommendations.
    – E_net4
    Commented Apr 24, 2018 at 10:52
  • @E_net4 Removed part of asking for libraries. I guess explaining how to use memguard to protect the key would expand the question needlessly. Cast the last re-open vote and voted question up as the main question is certainly something that should be answered. Happy to upvote any other answers from Go developers! Off topic: wow, a +4 / -4 ; you don't see that happening all too often! Commented Apr 26, 2018 at 12:41

2 Answers 2

2

memguard is the right library for this tool, but it has to be manually dropped into the AES code by replacing the calls to make([]byte) with calls to memguard.New...

By changing the encryption/decryption expanded key schedules to memguard LockedBuffers, you can control where they live in memory. Further, after the use of the AES block is completed, you can then destroy the underlying LockedBuffers

I was working on the same problem, and I believe I've solved it here: https://github.com/anitgandhi/aesguard

1

It looks to me that it is simply garbage collected and that no attempt is made to destroy the key material otherwise.

The source simply shows that the subkeys are derived and then returned in a pointer to a struct. It doesn't seem that there are any methods defined to destroy the expanded key material.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.