What is the expert cryptographic opinion on the following?
Assume that there is a web server and a Client on web page who calls an OTP ([One-Time Password]) 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 an alternate channel (say SMS) to User on a 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 validator. When User enters the OTP into the web page, the validator 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 fulfill my requirements?