Fixed issue #3848: "Git Sync..." > "Compare tags" does not properly clear state from...
[TortoiseGit.git] / src / TortoisePlink / mpunsafe.h
blob6d382f4707e3a68819b539a8af2ee29e0d16e049
1 /*
2 * mpunsafe.h: functions that deal with mp_ints in ways that are *not*
3 * expected to be constant-time. Used during key generation, in which
4 * constant run time is a lost cause anyway.
6 * These functions are in a separate header, so that you can easily
7 * check that you're not calling them in the wrong context. They're
8 * also defined in a separate source file, which is only linked in to
9 * the key generation tools. Furthermore, that source file also
10 * defines a global symbol that intentionally conflicts with one
11 * defined in the SSH client code, so that any attempt to put these
12 * functions into the same binary as the live SSH client
13 * implementation will cause a link-time failure. They should only be
14 * linked into PuTTYgen and auxiliary test programs.
16 * Also, just in case those precautions aren't enough, all the unsafe
17 * functions have 'unsafe' in the name.
20 #ifndef PUTTY_MPINT_UNSAFE_H
21 #define PUTTY_MPINT_UNSAFE_H
24 * The most obvious unsafe thing you want to do with an mp_int is to
25 * get rid of leading zero words in its representation, so that its
26 * nominal size is as close as possible to its true size, and you
27 * don't waste any time processing it.
29 * mp_unsafe_shrink performs this operation in place, mutating the
30 * size field of the mp_int it's given. It returns the same pointer it
31 * was given.
33 * mp_unsafe_copy leaves the original mp_int alone and makes a new one
34 * with the minimal size.
36 mp_int *mp_unsafe_shrink(mp_int *m);
37 mp_int *mp_unsafe_copy(mp_int *m);
40 * Compute the residue of x mod m. This is implemented in the most
41 * obvious way using the C % operator, which won't be constant-time on
42 * many C implementations.
44 uint32_t mp_unsafe_mod_integer(mp_int *x, uint32_t m);
46 #endif /* PUTTY_MPINT_UNSAFE_H */