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

ca: replace rsa with ecdsa #34

Merged
merged 1 commit into from
Jan 2, 2024
Merged
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
11 changes: 6 additions & 5 deletions internal/ca/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package ca

import (
"bytes"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
Expand All @@ -14,12 +15,12 @@ import (
)

type CA struct {
rootPrivKey *rsa.PrivateKey
rootPrivKey *ecdsa.PrivateKey
rootCert *x509.Certificate
rootPEM []byte

// The intermPrivKey is used for both the intermediate and meshCA certificates.
intermPrivKey *rsa.PrivateKey
intermPrivKey *ecdsa.PrivateKey

intermCert *x509.Certificate
intermPEM []byte
Expand All @@ -45,7 +46,7 @@ func New(namespace string) (*CA, error) {
KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
BasicConstraintsValid: true,
}
rootPrivKey, err := rsa.GenerateKey(rand.Reader, 4096)
rootPrivKey, err := ecdsa.GenerateKey(elliptic.P384(), rand.Reader)
if err != nil {
return nil, fmt.Errorf("failed to generate RSA private key: %w", err)
}
Expand All @@ -72,7 +73,7 @@ func New(namespace string) (*CA, error) {
KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
BasicConstraintsValid: true,
}
intermPrivKey, err := rsa.GenerateKey(rand.Reader, 4096)
intermPrivKey, err := ecdsa.GenerateKey(elliptic.P384(), rand.Reader)
if err != nil {
return nil, fmt.Errorf("failed to generate RSA private key: %w", err)
}
Expand Down