Ver Fonte

opengpg: set SelfSignature.PreferredHash in NewEntity

Say the user wants to create a NewEntity, then Serialize the private and public
keys. Then call Encrypt. The Hash used first for Encrypt will be `RIPEMD160`,
which is not compiled in by default. So say they _specifically_ pass
crypto.SHA256 as the Default hash to NewEntity, this should set the
PreferredHash in the SelfSignature so they can be encrypted with that hash.

Related to golang/go#12153

Change-Id: I3d89f9d60f9abb29ec8365f81da38b8cd0594587
Reviewed-on: https://go-review.googlesource.com/23209
Reviewed-by: Adam Langley <agl@golang.org>
Jessica Frazelle há 9 anos atrás
pai
commit
119f50887f
2 ficheiros alterados com 40 adições e 0 exclusões
  1. 6 0
      openpgp/keys.go
  2. 34 0
      openpgp/keys_test.go

+ 6 - 0
openpgp/keys.go

@@ -504,6 +504,12 @@ func NewEntity(name, comment, email string, config *packet.Config) (*Entity, err
 		},
 	}
 
+	// If the user passes in a DefaultHash via packet.Config,
+	// set the PreferredHash for the SelfSignature.
+	if config != nil && config.DefaultHash != 0 {
+		e.Identities[uid.Id].SelfSignature.PreferredHash = []uint8{hashToHashId(config.DefaultHash)}
+	}
+
 	e.Subkeys = make([]Subkey, 1)
 	e.Subkeys[0] = Subkey{
 		PublicKey:  packet.NewRSAPublicKey(currentTime, &encryptingPriv.PublicKey),

Diff do ficheiro suprimidas por serem muito extensas
+ 34 - 0
openpgp/keys_test.go


Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff