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

Set min value for the --ssh-rsa-bits flag #4177

Merged
merged 1 commit into from
Aug 22, 2023
Merged
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
5 changes: 4 additions & 1 deletion internal/flags/rsa_key_bits.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ func (b *RSAKeyBits) Set(str string) error {
if err != nil {
return err
}
if bits < 1024 {
return fmt.Errorf("RSA key bit size must be at least 1024")
}
if bits == 0 || bits%8 != 0 {
return fmt.Errorf("RSA key bit size must be a multiples of 8")
}
Expand All @@ -51,5 +54,5 @@ func (b *RSAKeyBits) Type() string {
}

func (b *RSAKeyBits) Description() string {
return "SSH RSA public key bit size (multiplies of 8)"
return "SSH RSA public key bit size (multiplies of 8, min 1024)"
}
4 changes: 2 additions & 2 deletions internal/flags/rsa_key_bits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func TestRSAKeyBits_Set(t *testing.T) {
}{
{"supported", "4096", "4096", false},
{"empty (default)", "", "2048", false},
{"unsupported", "0", "0", true},
{"unsupported", "123", "0", true},
{"unsupported", "512", "0", true},
{"unsupported", "1025", "0", true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Loading