diff options
author | 无闻 <u@gogs.io> | 2015-11-01 12:39:12 -0500 |
---|---|---|
committer | 无闻 <u@gogs.io> | 2015-11-01 12:39:12 -0500 |
commit | 50058b3c6d05d38d98cddeba2ad353f8138f1234 (patch) | |
tree | 6b41392ec15dac3e1a6d75fc609be57341996068 /models | |
parent | b0226a1d05616ac7fdbff4f8a956990654972798 (diff) | |
parent | b90b0c1191c559a60d4f30633266fc4c0a76ae4b (diff) | |
download | gitea-50058b3c6d05d38d98cddeba2ad353f8138f1234.tar.gz gitea-50058b3c6d05d38d98cddeba2ad353f8138f1234.zip |
Merge pull request #1871 from Gibheer/config_minimum_key_sizes
move minimum key sizes to config
Diffstat (limited to 'models')
-rw-r--r-- | models/publickey.go | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/models/publickey.go b/models/publickey.go index 6c0ffc0c78..04ae4c42fc 100644 --- a/models/publickey.go +++ b/models/publickey.go @@ -117,16 +117,6 @@ func (key *PublicKey) GetAuthorizedString() string { return fmt.Sprintf(_TPL_PUBLICK_KEY, appPath, key.ID, setting.CustomConf, key.Content) } -var minimumKeySizes = map[string]int{ - "(ED25519)": 256, - "(ECDSA)": 256, - "(NTRU)": 1087, - "(MCE)": 1702, - "(McE)": 1702, - "(RSA)": 1024, - "(DSA)": 1024, -} - func extractTypeFromBase64Key(key string) (string, error) { b, err := base64.StdEncoding.DecodeString(key) if err != nil || len(b) < 4 { @@ -251,8 +241,8 @@ func CheckPublicKeyString(content string) (_ string, err error) { if keySize == 0 { return "", errors.New("cannot get key size of the given key") } - keyType := strings.TrimSpace(sshKeygenOutput[len(sshKeygenOutput)-1]) - if minimumKeySize := minimumKeySizes[keyType]; minimumKeySize == 0 { + keyType := strings.Trim(sshKeygenOutput[len(sshKeygenOutput)-1], " ()") + if minimumKeySize := setting.Service.MinimumKeySizes[keyType]; minimumKeySize == 0 { return "", errors.New("sorry, unrecognized public key type") } else if keySize < minimumKeySize { return "", fmt.Errorf("the minimum accepted size of a public key %s is %d", keyType, minimumKeySize) |