You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2019/11/01 19:09:46 UTC
[GitHub] [mynewt-imgmod] ccollins476ad commented on a change in pull request
#5: Add new command: `imgmod key show`
ccollins476ad commented on a change in pull request #5: Add new command: `imgmod key show`
URL: https://github.com/apache/mynewt-imgmod/pull/5#discussion_r341713928
##########
File path: ikey/ikey.go
##########
@@ -0,0 +1,52 @@
+package ikey
+
+import (
+ "fmt"
+
+ "github.com/apache/mynewt-artifact/sec"
+ "github.com/pkg/errors"
+)
+
+type Desc struct {
+ Private bool
+ Algorithm string
+ PubBytes []byte
+ Hash []byte
+}
+
+func signKeyToDesc(key sec.PubSignKey, private bool) (Desc, error) {
+ var alg string
+ if key.Rsa != nil {
+ alg = fmt.Sprintf("RSA-%d", key.Rsa.Size()*8)
+ } else if key.Ec != nil {
+ alg = fmt.Sprintf("ECDSA-%d", key.Ec.X.BitLen())
+ } else {
+ alg = fmt.Sprintf("ED25519-%d", len(key.Ed25519)*8)
Review comment:
Thanks @utzig, that is good to know. I have fixed it as follows:
```
diff --git a/ikey/ikey.go b/ikey/ikey.go
index 54f0093..043d097 100644
--- a/ikey/ikey.go
+++ b/ikey/ikey.go
@@ -21,7 +21,7 @@ func signKeyToDesc(key sec.PubSignKey, private bool) (Desc, error) {
} else if key.Ec != nil {
alg = fmt.Sprintf("ECDSA-%d", key.Ec.X.BitLen())
} else {
- alg = fmt.Sprintf("ED25519-%d", len(key.Ed25519)*8)
+ alg = "ED25519"
}
pubBytes, err := key.Bytes()
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services