mpunsafe.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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.
  5. *
  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.
  15. *
  16. * Also, just in case those precautions aren't enough, all the unsafe
  17. * functions have 'unsafe' in the name.
  18. */
  19. #ifndef PUTTY_MPINT_UNSAFE_H
  20. #define PUTTY_MPINT_UNSAFE_H
  21. /*
  22. * The most obvious unsafe thing you want to do with an mp_int is to
  23. * get rid of leading zero words in its representation, so that its
  24. * nominal size is as close as possible to its true size, and you
  25. * don't waste any time processing it.
  26. *
  27. * mp_unsafe_shrink performs this operation in place, mutating the
  28. * size field of the mp_int it's given. It returns the same pointer it
  29. * was given.
  30. *
  31. * mp_unsafe_copy leaves the original mp_int alone and makes a new one
  32. * with the minimal size.
  33. */
  34. mp_int *mp_unsafe_shrink(mp_int *m);
  35. mp_int *mp_unsafe_copy(mp_int *m);
  36. #endif /* PUTTY_MPINT_UNSAFE_H */