mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00: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:
parent
03492ab593
commit
30117bff55
6
Recipe
6
Recipe
@ -389,8 +389,10 @@ osxlaunch : [UT] osxlaunch
|
|||||||
|
|
||||||
fuzzterm : [UT] UXTERM CHARSET MISC version uxmisc uxucs fuzzterm time settings
|
fuzzterm : [UT] UXTERM CHARSET MISC version uxmisc uxucs fuzzterm time settings
|
||||||
+ uxstore be_none uxnogtk memory
|
+ uxstore be_none uxnogtk memory
|
||||||
testcrypt : [UT] testcrypt SSHCRYPTO marshal utils memory tree234 uxutils
|
testcrypt : [UT] testcrypt SSHCRYPTO sshprime marshal utils memory tree234
|
||||||
testcrypt : [C] testcrypt SSHCRYPTO marshal utils memory tree234 winmiscs
|
+ uxutils
|
||||||
|
testcrypt : [C] testcrypt SSHCRYPTO sshprime marshal utils memory tree234
|
||||||
|
+ winmiscs
|
||||||
testzlib : [UT] testzlib sshzlib memory
|
testzlib : [UT] testzlib sshzlib memory
|
||||||
|
|
||||||
uppity : [UT] uxserver SSHSERVER UXMISC uxsignal uxnoise uxgss uxnogtk
|
uppity : [UT] uxserver SSHSERVER UXMISC uxsignal uxnoise uxgss uxnogtk
|
||||||
|
23
testcrypt.c
23
testcrypt.c
@ -900,6 +900,16 @@ bool crcda_detect(ptrlen packet, ptrlen iv)
|
|||||||
|
|
||||||
#define return_void(out, expression) (expression)
|
#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) \
|
#define VALTYPE_TYPEDEF(n,t,f) \
|
||||||
typedef t TD_val_##n; \
|
typedef t TD_val_##n; \
|
||||||
typedef t *TD_out_val_##n;
|
typedef t *TD_out_val_##n;
|
||||||
@ -967,8 +977,19 @@ typedef RsaSsh1Order TD_rsaorder;
|
|||||||
return_##rettype(out, function(arg1, arg2, arg3, arg4)); \
|
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"
|
#include "testcrypt.h"
|
||||||
|
|
||||||
|
#undef FUNC5
|
||||||
#undef FUNC4
|
#undef FUNC4
|
||||||
#undef FUNC3
|
#undef FUNC3
|
||||||
#undef FUNC2
|
#undef FUNC2
|
||||||
@ -1002,9 +1023,11 @@ static void process_line(BinarySource *in, strbuf *out)
|
|||||||
#define FUNC2 FUNC
|
#define FUNC2 FUNC
|
||||||
#define FUNC3 FUNC
|
#define FUNC3 FUNC
|
||||||
#define FUNC4 FUNC
|
#define FUNC4 FUNC
|
||||||
|
#define FUNC5 FUNC
|
||||||
|
|
||||||
#include "testcrypt.h"
|
#include "testcrypt.h"
|
||||||
|
|
||||||
|
#undef FUNC5
|
||||||
#undef FUNC4
|
#undef FUNC4
|
||||||
#undef FUNC3
|
#undef FUNC3
|
||||||
#undef FUNC2
|
#undef FUNC2
|
||||||
|
@ -238,6 +238,7 @@ FUNC1(uint, crc32_rfc1662, val_string_ptrlen)
|
|||||||
FUNC1(uint, crc32_ssh1, val_string_ptrlen)
|
FUNC1(uint, crc32_ssh1, val_string_ptrlen)
|
||||||
FUNC2(uint, crc32_update, uint, val_string_ptrlen)
|
FUNC2(uint, crc32_update, uint, val_string_ptrlen)
|
||||||
FUNC2(boolean, crcda_detect, val_string_ptrlen, val_string_ptrlen)
|
FUNC2(boolean, crcda_detect, val_string_ptrlen, val_string_ptrlen)
|
||||||
|
FUNC5(val_mpint, primegen, uint, uint, uint, val_mpint, uint)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These functions aren't part of PuTTY's own API, but are additions
|
* These functions aren't part of PuTTY's own API, but are additions
|
||||||
|
Loading…
Reference in New Issue
Block a user