-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
249ee22
commit 2bd6976
Showing
2 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package main | ||
|
||
import ( | ||
"crypto/sha1" | ||
"fmt" | ||
|
||
"github.com/go-compile/rome/parse" | ||
) | ||
|
||
func main() { | ||
fmt.Println("P192r1 Private:") | ||
parsePrivate([]byte(`-----BEGIN EC PRIVATE KEY----- | ||
MF4CAQEEGIGv8cxcdkitRLKR8TQf2SGOoFqzO8Hs4KAJBgcrhkjOPQEDoTQDMgAE | ||
jBSOPviPICiS3A8oRgjYfkA3WMUCJvGclKooR+REWIBCvTEwaQP7DSTooC5z4BdB | ||
-----END EC PRIVATE KEY-----`)) | ||
|
||
fmt.Println("P192r1 Public:") | ||
parsePublic([]byte(`-----BEGIN EC PUBLIC KEY----- | ||
MEgwEgYHKoZIzj0CAQYHK4ZIzj0BAwMyAASMFI4++I8gKJLcDyhGCNh+QDdYxQIm | ||
8ZyUqihH5ERYgEK9MTBpA/sNJOigLnPgF0E= | ||
-----END EC PUBLIC KEY-----`)) | ||
} | ||
|
||
func parsePrivate(priv []byte) { | ||
k, err := parse.Private(priv) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
fmt.Printf(" Curve: %s\n Fingerprint: %x\n", k.Public().Name(), k.Public().Fingerprint(sha1.New())) | ||
} | ||
|
||
func parsePublic(pub []byte) { | ||
k, err := parse.Public(pub) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
fmt.Printf(" Curve: %s\n Fingerprint: %x\n", k.Name(), k.Fingerprint(sha1.New())) | ||
} |