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/01/04 12:21:21 UTC

[GitHub] utzig commented on a change in pull request #254: 2.0 mfgimage format

utzig commented on a change in pull request #254: 2.0 mfgimage format
URL: https://github.com/apache/mynewt-newt/pull/254#discussion_r245284068
 
 

 ##########
 File path: artifact/image/key.go
 ##########
 @@ -265,35 +294,48 @@ func parseEncKeyBase64(keyBytes []byte, plainSecret []byte) ([]byte, error) {
 			"Error creating keywrap cipher: %s", err.Error())
 	}
 
-	cipherSecret, err := keywrap.Wrap(cipher, plainSecret)
+	return cipher, nil
+}
+
+func encryptSecretAes(c cipher.Block, plainSecret []byte) ([]byte, error) {
+	cipherSecret, err := keywrap.Wrap(c, plainSecret)
 	if err != nil {
 		return nil, util.FmtNewtError("Error key-wrapping: %s", err.Error())
 	}
 
 	return cipherSecret, nil
 }
 
-func ReadEncKey(filename string, plainSecret []byte) ([]byte, error) {
-	keyBytes, err := ioutil.ReadFile(filename)
-	if err != nil {
+func GeneratePlainSecret() ([]byte, error) {
+	plainSecret := make([]byte, 16)
+	if _, err := rand.Read(plainSecret); err != nil {
 		return nil, util.FmtNewtError(
-			"Error reading pubkey file: %s", err.Error())
+			"Random generation error: %s\n", err)
 	}
 
+	return plainSecret, nil
+}
+
+func GenerateCipherSecret(pubKeBytes []byte,
 
 Review comment:
   Any reason for abbreviating `Key` to `Ke` in this function? Using just `PubK...` would be better IMO.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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