<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-text-plain" wrap="true" graphical-quote="true"
style="font-family: -moz-fixed; font-size: 12px;" lang="x-unicode">
<pre wrap="">Hi,
在 2017年05月14日 01:40, Trevor Perrin 写道:
</pre>
<blockquote type="cite" style="color: #000000;">
<pre wrap="">On Sat, May 13, 2017 at 5:21 PM, Alex <a class="moz-txt-link-rfc2396E" href="mailto:alex@centromere.net"><alex@centromere.net></a> wrote:
</pre>
<blockquote type="cite" style="color: #000000;">
<pre wrap="">The `psk` token unlike all other tokens: It is parameterized. There is
no way for a Noise library to know ahead of time what the value will
be.
</pre>
</blockquote>
<pre wrap="">In a general-purpose library I think "psk" tokens should probably be
handled by a callback (psk0 is perhaps an exception to this, if the
library wants to provide a different/simpler API for just setting the
psk0 explicitly).
That's different from existing tokens, but seems OK to me - callbacks
are not uncommon if you look at, say, TLS APIs.
</pre>
</blockquote>
<pre wrap="">Using callbacks is what I first thought of too. But there is a
limitation: it is hard to support async/non-blocking IO in the
callbacks.
I am more inclined to have read_message/write_message returning an
error indicating that a PSK is needed. Something like
let r = handshake_state.write_message(payload, output);
if r == Err(NeedPsk) {
let psk = lookup_psk(handshake_state.get_rs());
handshake_state.set_next_psk(psk);
handshake_state.write_message(payload, output);
}
(Hypothetical Rust code)
I'll play with this idea in noise-rust and see how it turns out.
Guanhao Yin
</pre>
</div>
</body>
</html>