/* rsavalidator.h
 * This file was written and placed in the public
 * domain by Selwyn Kramer (selwyn@nywles.org).
 *
 * If you live in place that doesn't recognize the
 * public domain i promise to look the other way
 * when you steal this code and make it you own.
 */

#ifndef RSA_H
#define RSA_H

#ifdef __cplusplus
extern "C" {
#endif

/**
 * Verifies the supplied message using the supplied signature. The verify
 * algorithm is a simple: m == s^e mod n but it is optimized for e = 3,
 * e = 17 or e = 65537 and will not work with anything else (probably). The
 * optimalization is described here:
 * http://www.di-mgt.com.au/rsa_alg.html#crt
 *
 * A couple of restrictions apply:
 *  - The length of the message must be shorter than the length of
 *    the key (mlen < nlen).
 *  - The exponent e must be 3, 17 or 65537
 *
 * @param e the exponent part of the public key (3 or 65537)
 * @param nlen the length of the modulo of the public key in bytes
 * @param n the modulo of the public key
 * @param slen the length of the signature in bytes
 * @param s the signature
 * @param mlen the message length in bytes
 * @param m the message to verify
 */
int RSAverify(
		const int /* e */,
		const int /* nlen */, const unsigned char * /* n */,
		const int /* slen */, const unsigned char * /* s */,
		const int /* mlen */, const unsigned char * /* m */);

#ifdef __cplusplus
}
#endif

#endif /* RSA_H */


