]> Sergey Matveev's repositories - tofuproxy.git/blobdiff - x509.go
Use faster modern EdDSA-based certificates
[tofuproxy.git] / x509.go
diff --git a/x509.go b/x509.go
index d0e54a1607a6c86beab2af8220e1fbb50df231e5..4dafb908383eb894ef68348c8804c77da4363756 100644 (file)
--- a/x509.go
+++ b/x509.go
@@ -1,5 +1,7 @@
 /*
-Copyright (C) 2021 Sergey Matveev <stargrave@stargrave.org>
+tofuproxy -- flexible HTTP/HTTPS proxy, TLS terminator, X.509 TOFU
+             manager, WARC/geminispace browser
+Copyright (C) 2021-2023 Sergey Matveev <stargrave@stargrave.org>
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -14,12 +16,11 @@ You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-package main
+package tofuproxy
 
 import (
        "crypto"
-       "crypto/ecdsa"
-       "crypto/elliptic"
+       "crypto/ed25519"
        "crypto/rand"
        "crypto/x509"
        "crypto/x509/pkix"
@@ -55,11 +56,10 @@ func newKeypair(
        caCert *x509.Certificate,
        caPrv crypto.PrivateKey,
 ) *Keypair {
-       prv, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
+       pub, prv, err := ed25519.GenerateKey(rand.Reader)
        if err != nil {
                log.Fatalln(err)
        }
-       pub := prv.Public()
        notBefore := time.Now()
        notAfter := notBefore.Add(24 * time.Hour)
        Serial = Serial.Add(Serial, big.NewInt(1))