Skip to content
This repository was archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Check key size is at least 1024 bits
Browse files Browse the repository at this point in the history
  • Loading branch information
emersion committed Mar 11, 2019
1 parent ab81aa5 commit 1eaa896
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/rsa"
"crypto/x509"
"encoding/base64"
"fmt"
"net"
"strings"
)
Expand Down Expand Up @@ -88,6 +89,11 @@ func parsePublicKey(s string) (*queryResult, error) {
if !ok {
return nil, permFailError("key syntax error: not an RSA public key")
}
// RFC 8301 section 3.2: verifiers MUST NOT consider signatures using
// RSA keys of less than 1024 bits as valid signatures.
if rsaPub.Size() * 8 < 1024 {
return nil, permFailError(fmt.Sprintf("key is too short: want 1024 bits, has %v bits", rsaPub.Size() * 8))
}
res.Verifier = &rsaVerifier{rsaPub}
res.KeyAlgo = "rsa"
default:
Expand Down

0 comments on commit 1eaa896

Please sign in to comment.