Skip to content

Commit 2603aa4

Browse files
authored
Remove weakKeyFile and blockedKeyFile support (#7783)
Goodkey has two ways to detect a key as weak: it runs a variety of algorithmic checks (such as Fermat factorization and rocacheck), or the key can be listed in a "weak key file". Similarly, it has two ways to detect a key as blocked: it can call a generic function (which we use to query our database), or the key can be listed in a "blocked key file". This is two methods too many. Reliance on files of weak or blocked keys introduces unnecessary complexity to both the implementation and configuration of the goodkey package. Remove both "key file" options and delete all code which supported them. Also remove //test/block-a-key, as it was only used to generate these test files. IN-10762 tracked the removal of these files in prod. Fixes #7748
1 parent 6a2819a commit 2603aa4

24 files changed

+7
-709
lines changed

cmd/cert-checker/main.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -547,12 +547,6 @@ func main() {
547547
// Validate PA config and set defaults if needed.
548548
cmd.FailOnError(config.PA.CheckChallenges(), "Invalid PA configuration")
549549

550-
if config.CertChecker.GoodKey.WeakKeyFile != "" {
551-
cmd.Fail("cert-checker does not support checking against weak key files")
552-
}
553-
if config.CertChecker.GoodKey.BlockedKeyFile != "" {
554-
cmd.Fail("cert-checker does not support checking against blocked key files")
555-
}
556550
kp, err := sagoodkey.NewPolicy(&config.CertChecker.GoodKey, nil)
557551
cmd.FailOnError(err, "Unable to create key policy")
558552

goodkey/blocked.go

Lines changed: 0 additions & 95 deletions
This file was deleted.

goodkey/blocked_test.go

Lines changed: 0 additions & 100 deletions
This file was deleted.

goodkey/good_key.go

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,6 @@ type Config struct {
4242
// AllowedKeys enables or disables specific key algorithms and sizes. If
4343
// nil, defaults to just those keys allowed by the Let's Encrypt CPS.
4444
AllowedKeys *AllowedKeys
45-
// WeakKeyFile is the path to a JSON file containing truncated modulus hashes
46-
// of known weak RSA keys. If this config value is empty, then RSA modulus
47-
// hash checking will be disabled.
48-
WeakKeyFile string
49-
// BlockedKeyFile is the path to a YAML file containing base64-encoded SHA256
50-
// hashes of PKIX Subject Public Keys that should be blocked. If this config
51-
// value is empty, then blocked key checking will be disabled.
52-
//
53-
// Deprecated: This functionality is better performed by the blockedKeys database
54-
// table, and will be removed in a future release.
55-
BlockedKeyFile string
5645
// FermatRounds is an integer number of rounds of Fermat's factorization
5746
// method that should be performed to attempt to detect keys whose modulus can
5847
// be trivially factored because the two factors are very close to each other.
@@ -115,17 +104,14 @@ type BlockedKeyCheckFunc func(ctx context.Context, keyHash []byte) (bool, error)
115104
// operations.
116105
type KeyPolicy struct {
117106
allowedKeys AllowedKeys
118-
weakRSAList *WeakRSAKeys
119-
blockedList *blockedKeys
120107
fermatRounds int
121108
blockedCheck BlockedKeyCheckFunc
122109
}
123110

124111
// NewPolicy returns a key policy based on the given configuration, with sane
125112
// defaults. If the config's AllowedKeys is nil, the LetsEncryptCPS AllowedKeys
126-
// is used. If the config's WeakKeyFile or BlockedKeyFile paths are empty, those
127-
// checks are disabled. If the config's FermatRounds is 0, Fermat Factorization
128-
// defaults to attempting 110 rounds.
113+
// is used. If the configured FermatRounds is 0, Fermat Factorization defaults to
114+
// attempting 110 rounds.
129115
func NewPolicy(config *Config, bkc BlockedKeyCheckFunc) (KeyPolicy, error) {
130116
if config == nil {
131117
config = &Config{}
@@ -138,20 +124,6 @@ func NewPolicy(config *Config, bkc BlockedKeyCheckFunc) (KeyPolicy, error) {
138124
} else {
139125
kp.allowedKeys = *config.AllowedKeys
140126
}
141-
if config.WeakKeyFile != "" {
142-
keyList, err := LoadWeakRSASuffixes(config.WeakKeyFile)
143-
if err != nil {
144-
return KeyPolicy{}, err
145-
}
146-
kp.weakRSAList = keyList
147-
}
148-
if config.BlockedKeyFile != "" {
149-
blocked, err := loadBlockedKeysList(config.BlockedKeyFile)
150-
if err != nil {
151-
return KeyPolicy{}, err
152-
}
153-
kp.blockedList = blocked
154-
}
155127
if config.FermatRounds == 0 {
156128
// The BRs require 100 rounds, so give ourselves a margin above that.
157129
kp.fermatRounds = 110
@@ -176,15 +148,6 @@ func (policy *KeyPolicy) GoodKey(ctx context.Context, key crypto.PublicKey) erro
176148
default:
177149
return badKey("unsupported key type %T", t)
178150
}
179-
// If there is a blocked list configured then check if the public key is one
180-
// that has been administratively blocked.
181-
if policy.blockedList != nil {
182-
if blocked, err := policy.blockedList.blocked(key); err != nil {
183-
return fmt.Errorf("error checking blocklist for key: %v", key)
184-
} else if blocked {
185-
return badKey("public key is forbidden")
186-
}
187-
}
188151
if policy.blockedCheck != nil {
189152
digest, err := core.KeyDigest(key)
190153
if err != nil {
@@ -329,10 +292,6 @@ func (policy *KeyPolicy) goodKeyRSA(key *rsa.PublicKey) error {
329292
return err
330293
}
331294

332-
if policy.weakRSAList != nil && policy.weakRSAList.Known(key) {
333-
return badKey("key is on a known weak RSA key list")
334-
}
335-
336295
// Rather than support arbitrary exponents, which significantly increases
337296
// the size of the key space we allow, we restrict E to the defacto standard
338297
// RSA exponent 65537. There is no specific standards document that specifies

goodkey/good_key_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ func TestUnknownKeyType(t *testing.T) {
2525
err := testingPolicy.GoodKey(context.Background(), notAKey)
2626
test.AssertError(t, err, "Should have rejected a key of unknown type")
2727
test.AssertEquals(t, err.Error(), "unsupported key type struct {}")
28-
29-
// Check for early rejection and that no error is seen from blockedKeys.blocked.
30-
testingPolicyWithBlockedKeys := *testingPolicy
31-
testingPolicyWithBlockedKeys.blockedList = &blockedKeys{}
32-
err = testingPolicyWithBlockedKeys.GoodKey(context.Background(), notAKey)
33-
test.AssertError(t, err, "Should have rejected a key of unknown type")
34-
test.AssertEquals(t, err.Error(), "unsupported key type struct {}")
3528
}
3629

3730
func TestNilKey(t *testing.T) {

goodkey/weak.go

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)