-
Notifications
You must be signed in to change notification settings - Fork 7
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
v2.3.0: manager.Add no longer adds to its keyset #27
Comments
Updated the description, because the handle returned by package main
import (
"log"
"github.com/tink-crypto/tink-go/v2/aead"
"github.com/tink-crypto/tink-go/v2/keyset"
)
func try() {
ks, err := keyset.NewHandle(aead.AES256GCMKeyTemplate())
if err != nil {
log.Fatal(err)
}
// size := ks.Len()
size := len(ks.KeysetInfo().GetKeyInfo())
if size != 1 {
log.Fatalf("Expected 1 key but found %v", size)
}
mgr := keyset.NewManagerFromHandle(ks)
mgr.Add(aead.AES128GCMSIVKeyTemplate())
ks, _ = mgr.Handle()
// size := ks.Len()
size = len(ks.KeysetInfo().GetKeyInfo())
if size != 2 {
log.Fatalf("Expected 2 keys but found %v", size)
}
log.Println("OK")
} The only change is the addition of this line: ks, _ = mgr.Handle() |
We are facing same issue. The problem is in Thanks for you suggestion, however wouldn't expect such a breaking change in minor version update. |
Thanks for reporting this. And sorry that our new version broke your code. We are aware of this. We noticed that the manager doesn't do a deep copy of the handle it returns, and considered this a bug. In Tink, the Handle object is considered immutable. That's why all the mutation functions are in a different object called "Manager". I think it should not be too difficult to update your code so that it works with the new implementation:, by adding some calls to mgr.Handle() as you did in the example code. Does that work for you? |
I can't speak for the others, but yes it worked once I figured it out. Seems fussier than I'd like but I understand the sentiment. Would be useful if the release notes mentioned the need to adapt to the change, and how. |
I'm not sure if this is real quote, but it circulates over internet
However, I have found, that the code which was affected was covered by tests (that's how I found the issue). But was actually dead code. So I deleted that all and was happy. |
Describe the bug:
In v2.2.0 and earlier, after a call to
manager.Add
, the size ofks.KeysetInfo().GetKeyInfo()
would increase. In v2.3.0, it does not (andLen()
also doesn't return the proper number).What was the expected behavior?
I would expect a key added to a keyset via
manager.Add
to be reflected in the number of keys in the set.How can we reproduce the bug?
Try this code:
With
v2.3.0
the output is:But with v2.2.0, it's:
Can you tell us more about your development environment?
go version go1.23.2 darwin/arm64
The text was updated successfully, but these errors were encountered: