-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add support for generating ed25519 keys and certs #1061
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
Merged
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
e340753
add support for generating ed25519 keys and certs
izolight c639e67
add 5min ca testfiles
izolight e4cf3d8
only build for go1.13 as the ed25519 package is now part of std library
izolight bb83c8c
remove dependency on golang.org/x/crypto/ed25519
izolight 9a17a34
add support for generating ed25519 keys and certs
izolight cf7fb43
add 5min ca testfiles
izolight 79fa3b0
only build for go1.13 as the ed25519 package is now part of std library
izolight 221d4ec
remove dependency on golang.org/x/crypto/ed25519
izolight 626680c
Change string domain and format
claucece 1d9e618
typo
izolight 751bf89
compare key and cert
izolight 6624bf1
update comment and error to indicate support for ed25519
izolight b43f9a2
update comments
izolight 7f6b294
Change to use circl ed25519. This will fail due to issue cloudflare/c…
claucece b8f9375
Use circl only for signing
claucece f1bf794
Update vendor
claucece 259b11c
Update vendor to mod
claucece 35d039a
Remove go 1.12
claucece 887b6fc
Only use c25519 for generation
claucece 7dc5eca
Fix style
claucece 4685a06
Use circl library for all ed25519 key generation
claucece b4a68f6
Run the tests with expired data
claucece 7aff46b
Consistent naming
claucece 2725cfc
Not using pointers
claucece ad00b62
Fix 5min files
claucece 7d2779f
Use 25519 from stdlib
claucece acff4d8
This package is vendored
claucece 21fb139
Re add error line and mod tidy
claucece bca3df9
Merge branch 'claucece-ed25519cert' into ed25519
izolight c1cfc4c
Merge remote-tracking branch 'origin' into ed25519
izolight 58fc165
remove unneeded todo as per https://github.com/cloudflare/cfssl/pull/…
izolight fcceb3d
ignore key size for ed25519 as all keys are 256bit
izolight dfcdcd0
remove duplicate case from merge
izolight 27e825e
add Ed25519 to error for supported keys
izolight ed80075
Update errors/error.go
izolight 2b14670
remove duplicate switch case
izolight 6fdd6b4
correctly remove size param from ed25519 instead of ecdsa
izolight 0c7066a
remove unneeded test for ed25519 size
izolight ecc0574
print config instead of error if test fails
izolight File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -3,6 +3,7 @@ package csr | |
import ( | ||
"crypto" | ||
"crypto/ecdsa" | ||
"crypto/ed25519" | ||
"crypto/elliptic" | ||
"crypto/rsa" | ||
"crypto/x509" | ||
|
@@ -42,6 +43,10 @@ func TestKeyRequest(t *testing.T) { | |
if kr.Algo() != "ecdsa" { | ||
t.Fatal("ECDSA key generated, but expected", kr.Algo()) | ||
} | ||
case ed25519.PrivateKey: | ||
if kr.Algo() != "ed25519" { | ||
t.Fatal("Ed25519 key generated, but expected", kr.Algo()) | ||
} | ||
} | ||
} | ||
|
||
|
@@ -311,6 +316,21 @@ func TestECGeneration(t *testing.T) { | |
} | ||
} | ||
|
||
func TestED25519Generation(t *testing.T) { | ||
kr := &KeyRequest{A: "ed25519"} | ||
priv, err := kr.Generate() | ||
if err != nil { | ||
t.Fatalf("%v", err) | ||
} | ||
_, ok := priv.(ed25519.PrivateKey) | ||
if !ok { | ||
t.Fatal("Expected ed25519 key") | ||
} | ||
if sa := kr.SigAlgo(); sa == x509.UnknownSignatureAlgorithm { | ||
t.Fatal("Invalid signature algorithm!") | ||
} | ||
} | ||
|
||
func TestRSAKeyGeneration(t *testing.T) { | ||
var rsakey *rsa.PrivateKey | ||
|
||
|
@@ -404,6 +424,10 @@ func TestDefaultKeyRequest(t *testing.T) { | |
if DefaultKeyRequest.Algo() != "ecdsa" { | ||
t.Fatal("Invalid default key request.") | ||
} | ||
case "Ed25519 PRIVATE KEY": | ||
if DefaultKeyRequest.Algo() != "ed25519" { | ||
t.Fatal("Invalid default key request.") | ||
} | ||
} | ||
} | ||
|
||
|
@@ -430,6 +454,29 @@ func TestRSACertRequest(t *testing.T) { | |
} | ||
} | ||
|
||
// TestED25519CertRequest validates parsing a certificate request with an | ||
// ED25519 key. | ||
func TestED25519CertRequest(t *testing.T) { | ||
var req = &CertificateRequest{ | ||
Names: []Name{ | ||
{ | ||
C: "US", | ||
ST: "California", | ||
L: "San Francisco", | ||
O: "CloudFlare", | ||
OU: "Systems Engineering", | ||
}, | ||
}, | ||
CN: "cloudflare.com", | ||
Hosts: []string{"cloudflare.com", "www.cloudflare.com", "[email protected]", "https://www.cloudflare.com"}, | ||
KeyRequest: &KeyRequest{A: "ed25519"}, | ||
} | ||
_, _, err := ParseRequest(req) | ||
if err != nil { | ||
t.Fatalf("%v", err) | ||
} | ||
} | ||
|
||
// TestBadCertRequest checks for failure conditions of ParseRequest. | ||
func TestBadCertRequest(t *testing.T) { | ||
var req = &CertificateRequest{ | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.