]> Sergey Matveev's repositories - tofuproxy.git/blobdiff - cmd/certgen/main.go
Unify copyright comment format
[tofuproxy.git] / cmd / certgen / main.go
index e9a5cb1367c75f93e12a5a191b69489d309d56a9..5e66a5957971212eb5697f2041c4f64a882b5d98 100644 (file)
@@ -1,25 +1,22 @@
-/*
-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
-the Free Software Foundation, version 3 of the License.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
+// tofuproxy -- flexible HTTP/HTTPS proxy, TLS terminator, X.509 TOFU
+//              manager, WARC/geminispace browser
+// Copyright (C) 2021-2024 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
+// the Free Software Foundation, version 3 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// 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
 
 import (
-       "crypto/ed25519"
        "crypto/rand"
        "crypto/x509"
        "crypto/x509/pkix"
@@ -30,22 +27,22 @@ import (
        "math/big"
        "os"
        "time"
+
+       "go.stargrave.org/tofuproxy"
 )
 
 func main() {
        cn := flag.String("cn", "tofuproxy.localhost", "CommonName")
+       ai := flag.String("ai", "eddsa", "ecdsa|eddsa (ECDSA-256 or EdDSA algorithm)")
        flag.Parse()
        log.SetFlags(log.Lshortfile)
 
-       pub, prv, err := ed25519.GenerateKey(rand.Reader)
-       if err != nil {
-               log.Fatalln(err)
-       }
+       pub, prv := tofuproxy.NewKeypair(*ai)
        notBefore := time.Now()
        notAfter := notBefore.Add(365 * 24 * time.Hour)
 
        serialRaw := make([]byte, 16)
-       if _, err = io.ReadFull(rand.Reader, serialRaw); err != nil {
+       if _, err := io.ReadFull(rand.Reader, serialRaw); err != nil {
                log.Fatalln(err)
        }
        serial := big.NewInt(0)