mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-05 21:42:47 -05:00
Add primegen() to the testcrypt API.
I just found I wanted to generate a prime with particular properties, and I knew PuTTY's prime generator could manage it, so it was easier to add this function to testcrypt for occasional manual use than to look for another prime-generator with the same feature set! I've wrapped the function so as to remove the three progress- reporting parameters.
This commit is contained in:
23
testcrypt.c
23
testcrypt.c
@ -900,6 +900,16 @@ bool crcda_detect(ptrlen packet, ptrlen iv)
|
||||
|
||||
#define return_void(out, expression) (expression)
|
||||
|
||||
static void no_progress(void *param, int action, int phase, int iprogress) {}
|
||||
|
||||
mp_int *primegen_wrapper(
|
||||
int bits, int modulus, int residue, mp_int *factor, unsigned firstbits)
|
||||
{
|
||||
return primegen(bits, modulus, residue, factor,
|
||||
0, no_progress, NULL, firstbits);
|
||||
}
|
||||
#define primegen primegen_wrapper
|
||||
|
||||
#define VALTYPE_TYPEDEF(n,t,f) \
|
||||
typedef t TD_val_##n; \
|
||||
typedef t *TD_out_val_##n;
|
||||
@ -967,8 +977,19 @@ typedef RsaSsh1Order TD_rsaorder;
|
||||
return_##rettype(out, function(arg1, arg2, arg3, arg4)); \
|
||||
}
|
||||
|
||||
#define FUNC5(rettype, function, type1, type2, type3, type4, type5) \
|
||||
static void handle_##function(BinarySource *in, strbuf *out) { \
|
||||
TD_##type1 arg1 = get_##type1(in); \
|
||||
TD_##type2 arg2 = get_##type2(in); \
|
||||
TD_##type3 arg3 = get_##type3(in); \
|
||||
TD_##type4 arg4 = get_##type4(in); \
|
||||
TD_##type5 arg5 = get_##type5(in); \
|
||||
return_##rettype(out, function(arg1, arg2, arg3, arg4, arg5)); \
|
||||
}
|
||||
|
||||
#include "testcrypt.h"
|
||||
|
||||
#undef FUNC5
|
||||
#undef FUNC4
|
||||
#undef FUNC3
|
||||
#undef FUNC2
|
||||
@ -1002,9 +1023,11 @@ static void process_line(BinarySource *in, strbuf *out)
|
||||
#define FUNC2 FUNC
|
||||
#define FUNC3 FUNC
|
||||
#define FUNC4 FUNC
|
||||
#define FUNC5 FUNC
|
||||
|
||||
#include "testcrypt.h"
|
||||
|
||||
#undef FUNC5
|
||||
#undef FUNC4
|
||||
#undef FUNC3
|
||||
#undef FUNC2
|
||||
|
Reference in New Issue
Block a user