+ h := handshake{
+ conn: rw,
+ initer: false,
+ skeys: sliceIter(skeys),
+ }
+ return h.Do()
+}
+
+func sliceIter(skeys [][]byte) SecretKeyIter {
+ return func(callback func([]byte) bool) {
+ for _, sk := range skeys {
+ if !callback(sk) {
+ break
+ }
+ }
+ }
+}
+
+// A function that given a function, calls it with secret keys until it
+// returns false or exhausted.
+type SecretKeyIter func(callback func(skey []byte) (more bool))
+
+// Doesn't unpack the secret keys until it needs to, and through the passed
+// function.
+func ReceiveHandshakeLazy(rw io.ReadWriter, skeys SecretKeyIter) (ret io.ReadWriter, err error) {