mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-24 08:42:25 +00:00
testcrypt: allow ssh2_cipher_new to return NULL.
No cipher construction function _currently_ returns NULL, but one's about to start, so the testcrypt system will have to be able to cope. This is the first time a function in the testcrypt API has had an 'opt' type as its return value rather than an argument. But it works just the same in reverse: the wire protocol emits the special identifer "NULL" when the optional return value is absent, and the Python module catches that and rewrites it as Python 'None'.
This commit is contained in:
parent
9128454750
commit
ee8025dd1c
@ -139,6 +139,10 @@ def make_argword(arg, argtype, fnname, argindex, to_preserve):
|
||||
fnname, argindex, typename, arg))
|
||||
|
||||
def make_retval(rettype, word, unpack_strings):
|
||||
if rettype.startswith("opt_"):
|
||||
if word == "NULL":
|
||||
return None
|
||||
rettype = rettype[4:]
|
||||
if rettype == "val_string" and unpack_strings:
|
||||
retwords = childprocess.funcall("getstring", [word])
|
||||
childprocess.funcall("free", [word])
|
||||
|
@ -505,6 +505,14 @@ static void return_val_string_asciz(strbuf *out, char *s)
|
||||
return_val_string(out, sb);
|
||||
}
|
||||
|
||||
static void return_opt_val_ssh2cipher(strbuf *out, ssh2_cipher *c)
|
||||
{
|
||||
if (!c)
|
||||
strbuf_catf(out, "NULL\n");
|
||||
else
|
||||
return_val_ssh2cipher(out, c);
|
||||
}
|
||||
|
||||
static void handle_hello(BinarySource *in, strbuf *out)
|
||||
{
|
||||
strbuf_catf(out, "hello, world");
|
||||
|
@ -162,7 +162,7 @@ FUNC2(val_string, ssh1_cipher_decrypt, val_ssh1cipher, val_string_ptrlen)
|
||||
/*
|
||||
* The ssh2_cipher abstraction, with similar modifications.
|
||||
*/
|
||||
FUNC1(val_ssh2cipher, ssh2_cipher_new, ssh2_cipheralg)
|
||||
FUNC1(opt_val_ssh2cipher, ssh2_cipher_new, ssh2_cipheralg)
|
||||
FUNC2(void, ssh2_cipher_setiv, val_ssh2cipher, val_string_ptrlen)
|
||||
FUNC2(void, ssh2_cipher_setkey, val_ssh2cipher, val_string_ptrlen)
|
||||
FUNC2(val_string, ssh2_cipher_encrypt, val_ssh2cipher, val_string_ptrlen)
|
||||
|
Loading…
Reference in New Issue
Block a user