From 8082c228c5d618e6f865f76b4d0518c2fde573ec Mon Sep 17 00:00:00 2001 From: fusion32 Date: Fri, 15 Aug 2025 15:48:19 -0300 Subject: wrapping up for a public release --- tools/pubkey.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tools/pubkey.go (limited to 'tools/pubkey.go') diff --git a/tools/pubkey.go b/tools/pubkey.go new file mode 100644 index 0000000..4649664 --- /dev/null +++ b/tools/pubkey.go @@ -0,0 +1,34 @@ +package main + +import ( + "crypto/x509" + "encoding/pem" + "fmt" + "log" + "os" +) + +func main() { + keyFile := "key.pem" + if len(os.Args) > 1 { + keyFile = os.Args[1] + } + + keyData, err := os.ReadFile(keyFile) + if err != nil { + log.Panicf("failed to read key \"%v\": %v", keyFile, err) + } + + keyBlock, _ := pem.Decode(keyData) + if keyBlock == nil { + log.Panicf("key \"%v\" is empty") + } + + privateKey, err := x509.ParsePKCS1PrivateKey(keyBlock.Bytes) + if err != nil { + log.Panic("failed to read PKCS1 RSA private key: %v", err) + } + + fmt.Println("N", privateKey.N) + fmt.Println("E", privateKey.E) +} -- cgit v1.2.3