summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/main.go b/main.go
index e773b98..dac211b 100644
--- a/main.go
+++ b/main.go
@@ -87,23 +87,26 @@ func factor(N *big.Int) (*big.Int, *big.Int) {
return nil, nil
}
-func pubKey(f string) rsa.PublicKey {
+func pubKey(f string) (*rsa.PublicKey, error) {
file, err := ioutil.ReadFile(f)
if err != nil {
- log.Fatal(err)
+ return nil, err
}
block, _ := pem.Decode(file)
key, err := x509.ParsePKCS1PrivateKey(block.Bytes)
if err != nil {
- log.Fatal(err)
+ return nil, err
}
- return key.PublicKey
+ return &key.PublicKey, nil
}
func main() {
- pub := pubKey("test.key")
+ pub, err := pubKey("test.key")
+ if err != nil {
+ log.Fatal(err)
+ }
fmt.Println(factor(pub.N))
}