aboutsummaryrefslogtreecommitdiff
path: root/certificate_test.go
diff options
context:
space:
mode:
authorGibheer <gibheer+git@zero-knowledge.org>2023-01-10 17:38:46 +0100
committerGibheer <gibheer+git@zero-knowledge.org>2023-01-10 14:39:33 +0100
commit0380f7f91c831af18e37414afcdf30935b4b4ee9 (patch)
treeea77ed196eccbef388dca34e936a428fb672b72b /certificate_test.go
parentd34a8ab26ec72ea5ac1d1b2cd39ea736eb5af014 (diff)
fix ed25519 key functionHEADmaster
The private key for ed25519 never returned crypto.PrivateKey. This caused the generation of certificates to not work and may also have resulted in other issues.
Diffstat (limited to 'certificate_test.go')
-rw-r--r--certificate_test.go42
1 files changed, 26 insertions, 16 deletions
diff --git a/certificate_test.go b/certificate_test.go
index 9951d7a..14b1279 100644
--- a/certificate_test.go
+++ b/certificate_test.go
@@ -16,29 +16,39 @@ var (
)
func TestCertificateCreation(t *testing.T) {
- pk, err := NewPrivateKeyEcdsa(elliptic.P224())
+ ed25519Key, err := NewPrivateKeyEd25519()
if err != nil {
- t.Errorf("cert: creating private key failed: %s", err)
+ t.Errorf("cert: creating private key ed25519 failed: %s", err)
}
-
- csr, err := TestCertificateData.ToCertificateRequest(pk)
+ ecdsaKey, err := NewPrivateKeyEcdsa(elliptic.P224())
if err != nil {
- t.Errorf("cert: creating csr failed: %s", err)
- }
-
- cert_opts := CertificateOptions{
- // KeyUsage: x509.KeyUsageEncipherOnly | x509.KeyUsageKeyEncipherment | x509.KeyUsageCertSign,
- SerialNumber: big.NewInt(1),
- CALength: -1,
+ t.Errorf("cert: creating private key ecdsa failed: %s", err)
}
-
- cert, err := csr.ToCertificate(pk, cert_opts, nil)
+ rsaKey, err := NewPrivateKeyRsa(1024)
if err != nil {
- t.Errorf("cert: creating cert failed: %s", err)
+ t.Errorf("cert: creating private key rsa failed: %s", err)
}
- if !fieldsAreSame(TestCertificateData, cert) {
- t.Errorf("cert: Fields are not the same")
+ for _, pk := range []PrivateKey{rsaKey, ecdsaKey, ed25519Key} {
+ csr, err := TestCertificateData.ToCertificateRequest(pk)
+ if err != nil {
+ t.Errorf("cert: creating csr failed: %s", err)
+ }
+
+ cert_opts := CertificateOptions{
+ // KeyUsage: x509.KeyUsageEncipherOnly | x509.KeyUsageKeyEncipherment | x509.KeyUsageCertSign,
+ SerialNumber: big.NewInt(1),
+ CALength: -1,
+ }
+
+ cert, err := csr.ToCertificate(pk, cert_opts, nil)
+ if err != nil {
+ t.Errorf("cert: creating cert failed: %s", err)
+ }
+
+ if !fieldsAreSame(TestCertificateData, cert) {
+ t.Errorf("cert: Fields are not the same")
+ }
}
}