What is the expert cryptographic opinion on the following?
Assume that there is a web server and a client on web page. User on the Client calls an OTP web service on the server which:
- creates a RSA key pair
- generates a random 10 digit string - the Message
- Encrypts the Message with the Public Key component to generate an OTP
- Returns the Message and Private Key to Client
- Sends OTP via alternate channel (say SMS) to User on mobile
The reason for this kludge is that the web service return can be a script that gets added to the DOM on the fly. The script contains the RSA decrypt method with a built-in Private Key and has the Message as the vallidator. When User enters the OTP into the web page, the vallidator succeeds or not.
The advantage in this method is that the OTP does not need to be stored in a server side database, and there is only one web call-out with the browser doing the validation. However, I am unsure whether RSA was meant to have a private Public Key and a public Private Key.
What is the analysis on whether a malicious user can get the Private key and Message and then compute the OTP? If so, then could I make the OTP entry time bound so as to minimize the attack possibility? Is there a better way to fullfil my requirements?