Skip to content

fix: collaboration rsa #11294

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 8 additions & 4 deletions services/collaboration/pkg/proofkeys/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,15 @@ func (vh *VerifyHandler) Verify(accessToken, url, timestamp, sig64, oldSig64 str
expectedProof := vh.generateProof(accessToken, url, timestamp)
hashedProof := sha256.Sum256(expectedProof)

// verify
if err := rsa.VerifyPKCS1v15(pubkeys.Key, crypto.SHA256, hashedProof[:], signature); err != nil {
if err := rsa.VerifyPKCS1v15(pubkeys.Key, crypto.SHA256, hashedProof[:], oldSignature); err != nil {
// verify using PSS padding for better security
pssOpts := &rsa.PSSOptions{
SaltLength: rsa.PSSSaltLengthEqualsHash,
Hash: crypto.SHA256,
}
if err := rsa.VerifyPSS(pubkeys.Key, crypto.SHA256, hashedProof[:], signature, pssOpts); err != nil {
if err := rsa.VerifyPSS(pubkeys.Key, crypto.SHA256, hashedProof[:], oldSignature, pssOpts); err != nil {
if pubkeys.OldKey != nil {
return rsa.VerifyPKCS1v15(pubkeys.OldKey, crypto.SHA256, hashedProof[:], signature)
return rsa.VerifyPSS(pubkeys.OldKey, crypto.SHA256, hashedProof[:], signature, pssOpts)
} else {
return err
}
Expand Down