0

I have the next formula:

2^x mod p = m;

I know the value p and m, how can I calculate x using openssl library ?

VFcdxcv
  • 21
  • 5
  • Use the [`BN_mod`](https://wiki.openssl.org/index.php/Manual:BN_add(3)) functions. – jww Oct 29 '17 at 19:45
  • hey, thanks for your answer! Are you sure that I will get x using Bn_mod? Do I have to use it like this - Bn_mod(x, p, m, ctx) to get value x? – VFcdxcv Oct 29 '17 at 21:04
  • Oh, my bad. I misparsed the question and thought you were calculating `m`. You can't calculate `x` if the size of `p` is non-trivial, like sizes used in cryptography. If its a crypto puzzle or homework problem with smaller moduli, then use Shank's algorithm to solve for `x`. Here's what you should search for: [Shank's algorithm discrete log](https://www.google.com/search?q=Shank's+algorithm+discrete+log). – jww Oct 30 '17 at 13:44
  • If `p` is a full size, real security parameter, then don't waste your time on solving discrete logs. You probably won't be able to recover `x`. Instead, focus on intercepting the communications channel. Have your victim perform key exchange with you, and then you perform key exchange with the server. In this case, you are just proxying the messages from victim to server. – jww Oct 30 '17 at 13:49
  • You can not calculate x. It's private key. It could be different if you want to attack. – dralexnumber Dec 04 '17 at 15:47

0 Answers0