Skip to content
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

tkn20: prevent panics on key gen errors #409

Merged
merged 1 commit into from Mar 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions abe/cpabe/tkn20/tkn20.go
Expand Up @@ -62,7 +62,10 @@ func (msk *SystemSecretKey) KeyGen(rand io.Reader, attrs Attributes) (AttributeK
rand = cryptoRand.Reader
}
sk, err := tkn.DeriveAttributeKeysCCA(rand, &msk.sp, &attrs.attrs)
return AttributeKey{*sk}, err
if err != nil {
return AttributeKey{}, err
}
return AttributeKey{*sk}, nil
}

type AttributeKey struct {
Expand Down Expand Up @@ -150,5 +153,8 @@ func Setup(rand io.Reader) (PublicKey, SystemSecretKey, error) {
rand = cryptoRand.Reader
}
pp, sp, err := tkn.GenerateParams(rand)
return PublicKey{*pp}, SystemSecretKey{*sp}, err
if err != nil {
return PublicKey{}, SystemSecretKey{}, err
}
return PublicKey{*pp}, SystemSecretKey{*sp}, nil
}