mtproto_dh_utils.h 921 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "base/bytes.h"
  9. namespace openssl {
  10. class BigNum;
  11. } // namespace openssl
  12. namespace MTP {
  13. struct ModExpFirst {
  14. static constexpr auto kRandomPowerSize = 256;
  15. bytes::vector modexp;
  16. bytes::vector randomPower;
  17. };
  18. [[nodiscard]] bool IsPrimeAndGood(bytes::const_span primeBytes, int g);
  19. [[nodiscard]] bool IsGoodModExpFirst(
  20. const openssl::BigNum &modexp,
  21. const openssl::BigNum &prime);
  22. [[nodiscard]] ModExpFirst CreateModExp(
  23. int g,
  24. bytes::const_span primeBytes,
  25. bytes::const_span randomSeed);
  26. [[nodiscard]] bytes::vector CreateAuthKey(
  27. bytes::const_span firstBytes,
  28. bytes::const_span randomBytes,
  29. bytes::const_span primeBytes);
  30. } // namespace MTP