-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow OpenSSH-style key type identifiers (#14143)
* Allow OpenSSH-style key type identifiers To bring better parity with the changes of #14008, wherein we allowed OpenSSH-style key identifiers during generation. When specifying a list of allowed keys, validate against both OpenSSH-style key identifiers and the usual simplified names as well ("rsa" or "ecdsa"). Notably, the PKI secrets engine prefers "ec" over "ecdsa", so we permit both as well. Signed-off-by: Alexander Scheel <[email protected]> * Fix missing quote in docs
- Loading branch information
Showing
3 changed files
with
142 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,6 +119,9 @@ SjOQL/GkH1nkRcDS9++aAAAAAmNhAQID | |
-----END OPENSSH PRIVATE KEY----- | ||
` | ||
|
||
publicKeyECDSA256 = `ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJsfOouYIjJNI23QJqaDsFTGukm21fRAMeGvKZDB59i5jnX1EubMH1AEjjzz4fgySUlyWKo+TS31rxU8kX3DDM4= [email protected]` | ||
publicKeyECDSA521 = `ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBAEg73ORD4J3FV2CrL01gLSKREO2EHrZPlJCOeDL5OKD3M1GCHv3q8O452RW49Aw+8zFFFU5u6d1Ys3Qsj05zdaQwQDt/D3ceWLGVkWiKyLPQStfn0GGOZh3YFKEw5XmeW9jh6xudEHlKs4Pfv2FrroaUKZvM2SlxR/feOK0tCQyq3MN/g== [email protected]` | ||
|
||
// testPublicKeyInstall is the public key that is installed in the | ||
// admin account's authorized_keys | ||
testPublicKeyInstall = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9i+hFxZHGo6KblVme4zrAcJstR6I0PTJozW286X4WyvPnkMYDQ5mnhEYC7UWCvjoTWbPEXPX7NjhRtwQTGD67bV+lrxgfyzK1JZbUXK4PwgKJvQD+XyyWYMzDgGSQY61KUSqCxymSm/9NZkPU3ElaQ9xQuTzPpztM4ROfb8f2Yv6/ZESZsTo0MTAkp8Pcy+WkioI/uJ1H7zqs0EA4OMY4aDJRu0UtP4rTVeYNEAuRXdX+eH4aW3KMvhzpFTjMbaJHJXlEeUm2SaX5TNQyTOvghCeQILfYIL/Ca2ij8iwCmulwdV6eQGfd4VDu40PvSnmfoaE38o6HaPnX0kUcnKiT" | ||
|
@@ -1307,6 +1310,60 @@ func TestBackend_AllowedUserKeyLengths(t *testing.T) { | |
return nil | ||
}, | ||
}, | ||
// Fail with ECDSA key | ||
{ | ||
Operation: logical.UpdateOperation, | ||
Path: "sign/multikey", | ||
Data: map[string]interface{}{ | ||
"public_key": publicKeyECDSA256, | ||
}, | ||
ErrorOk: true, | ||
Check: func(resp *logical.Response) error { | ||
if resp.Data["error"] != "public_key failed to meet the key requirements: key of type ecdsa is not allowed" { | ||
return errors.New("an ECDSA key was allowed under RSA-only policy") | ||
} | ||
return nil | ||
}, | ||
}, | ||
createRoleStep("ectypes", map[string]interface{}{ | ||
"key_type": "ca", | ||
"allow_user_certificates": true, | ||
"allowed_user_key_lengths": map[string]interface{}{ | ||
"ec": []int{256}, | ||
"ecdsa-sha2-nistp521": 0, | ||
}, | ||
}), | ||
// Pass with ECDSA P-256 | ||
{ | ||
Operation: logical.UpdateOperation, | ||
Path: "sign/ectypes", | ||
Data: map[string]interface{}{ | ||
"public_key": publicKeyECDSA256, | ||
}, | ||
}, | ||
// Pass with ECDSA P-521 | ||
{ | ||
Operation: logical.UpdateOperation, | ||
Path: "sign/ectypes", | ||
Data: map[string]interface{}{ | ||
"public_key": publicKeyECDSA521, | ||
}, | ||
}, | ||
// Fail with RSA key | ||
{ | ||
Operation: logical.UpdateOperation, | ||
Path: "sign/ectypes", | ||
Data: map[string]interface{}{ | ||
"public_key": publicKey3072, | ||
}, | ||
ErrorOk: true, | ||
Check: func(resp *logical.Response) error { | ||
if resp.Data["error"] != "public_key failed to meet the key requirements: key of type rsa is not allowed" { | ||
return errors.New("an RSA key was allowed under ECDSA-only policy") | ||
} | ||
return nil | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters