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

3rd party #95

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions biscuit.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ func (b *Biscuit) Authorizer(root ed25519.PublicKey) (Authorizer, error) {
}

currentKey = b.container.Authority.NextKey.Key
currentAlgorithm := b.container.Authority.NextKey.Algorithm
if len(currentKey) != 32 {
return nil, ErrInvalidKeySize
}
Expand All @@ -308,7 +309,26 @@ func (b *Biscuit) Authorizer(root ed25519.PublicKey) (Authorizer, error) {
return nil, ErrInvalidSignature
}

if block.ExternalSignature != nil {
// an external signature is present, we need to verify it
if *block.ExternalSignature.PublicKey.Algorithm != pb.PublicKey_Ed25519 {
return nil, UnsupportedAlgorithm
}

// the public key that's part of the signed block is the public key used to sign
// the previous block
algorithm := make([]byte, 4)
binary.LittleEndian.PutUint32(algorithm[0:], uint32(currentAlgorithm.Number()))
toVerify := append(block.Block[:], algorithm...)
toVerify = append(toVerify, currentKey[:]...)

if ok := ed25519.Verify(block.ExternalSignature.PublicKey.Key, toVerify, block.ExternalSignature.Signature); !ok {
return nil, ErrInvalidSignature
}
}

currentKey = block.NextKey.Key
currentAlgorithm = block.NextKey.Algorithm
if len(currentKey) != 32 {
return nil, ErrInvalidKeySize
}
Expand Down
Loading