2000-01-11 22:35:21 +00:00
|
|
|
=pod
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
RSA_set_default_method, RSA_get_default_method, RSA_set_method,
|
2000-11-08 17:51:37 +00:00
|
|
|
RSA_get_method, RSA_PKCS1_SSLeay,
|
2000-09-14 21:23:28 +00:00
|
|
|
RSA_null_method, RSA_flags, RSA_new_method - select RSA method
|
2000-01-11 22:35:21 +00:00
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
#include <openssl/rsa.h>
|
2000-10-26 21:07:28 +00:00
|
|
|
#include <openssl/engine.h>
|
2000-01-11 22:35:21 +00:00
|
|
|
|
2000-10-26 21:07:28 +00:00
|
|
|
void RSA_set_default_openssl_method(RSA_METHOD *meth);
|
2000-01-11 22:35:21 +00:00
|
|
|
|
2000-10-26 21:07:28 +00:00
|
|
|
RSA_METHOD *RSA_get_default_openssl_method(void);
|
2000-01-11 22:35:21 +00:00
|
|
|
|
2000-10-26 21:07:28 +00:00
|
|
|
int RSA_set_method(RSA *rsa, ENGINE *engine);
|
2000-01-11 22:35:21 +00:00
|
|
|
|
|
|
|
RSA_METHOD *RSA_get_method(RSA *rsa);
|
|
|
|
|
|
|
|
RSA_METHOD *RSA_PKCS1_SSLeay(void);
|
|
|
|
|
|
|
|
RSA_METHOD *RSA_null_method(void);
|
|
|
|
|
|
|
|
int RSA_flags(RSA *rsa);
|
|
|
|
|
2000-10-26 21:07:28 +00:00
|
|
|
RSA *RSA_new_method(ENGINE *engine);
|
2000-01-11 22:35:21 +00:00
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
|
|
|
An B<RSA_METHOD> specifies the functions that OpenSSL uses for RSA
|
|
|
|
operations. By modifying the method, alternative implementations
|
|
|
|
such as hardware accelerators may be used.
|
|
|
|
|
2000-11-08 17:51:37 +00:00
|
|
|
Initially, the default is to use the OpenSSL internal implementation.
|
|
|
|
RSA_PKCS1_SSLeay() returns a pointer to that method.
|
2000-01-11 22:35:21 +00:00
|
|
|
|
2000-10-26 21:07:28 +00:00
|
|
|
RSA_set_default_openssl_method() makes B<meth> the default method for all B<RSA>
|
|
|
|
structures created later. B<NB:> This is true only whilst the default engine
|
|
|
|
for RSA operations remains as "openssl". ENGINEs provide an
|
|
|
|
encapsulation for implementations of one or more algorithms at a time, and all
|
|
|
|
the RSA functions mentioned here operate within the scope of the default
|
|
|
|
"openssl" engine.
|
2000-01-11 22:35:21 +00:00
|
|
|
|
2000-10-26 21:07:28 +00:00
|
|
|
RSA_get_default_openssl_method() returns a pointer to the current default
|
|
|
|
method for the "openssl" engine.
|
2000-01-11 22:35:21 +00:00
|
|
|
|
2000-10-26 21:07:28 +00:00
|
|
|
RSA_set_method() selects B<engine> for all operations using the key
|
2000-01-11 22:35:21 +00:00
|
|
|
B<rsa>.
|
|
|
|
|
2000-10-26 21:07:28 +00:00
|
|
|
RSA_get_method() returns a pointer to the RSA_METHOD from the currently
|
|
|
|
selected ENGINE for B<rsa>.
|
2000-01-11 22:35:21 +00:00
|
|
|
|
|
|
|
RSA_flags() returns the B<flags> that are set for B<rsa>'s current method.
|
|
|
|
|
2000-10-26 21:07:28 +00:00
|
|
|
RSA_new_method() allocates and initializes an RSA structure so that
|
|
|
|
B<engine> will be used for the RSA operations. If B<engine> is NULL,
|
|
|
|
the default engine for RSA operations is used.
|
2000-01-11 22:35:21 +00:00
|
|
|
|
|
|
|
=head1 THE RSA_METHOD STRUCTURE
|
|
|
|
|
|
|
|
typedef struct rsa_meth_st
|
|
|
|
{
|
|
|
|
/* name of the implementation */
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
/* encrypt */
|
|
|
|
int (*rsa_pub_enc)(int flen, unsigned char *from,
|
|
|
|
unsigned char *to, RSA *rsa, int padding);
|
|
|
|
|
|
|
|
/* verify arbitrary data */
|
|
|
|
int (*rsa_pub_dec)(int flen, unsigned char *from,
|
|
|
|
unsigned char *to, RSA *rsa, int padding);
|
|
|
|
|
|
|
|
/* sign arbitrary data */
|
|
|
|
int (*rsa_priv_enc)(int flen, unsigned char *from,
|
|
|
|
unsigned char *to, RSA *rsa, int padding);
|
|
|
|
|
|
|
|
/* decrypt */
|
|
|
|
int (*rsa_priv_dec)(int flen, unsigned char *from,
|
|
|
|
unsigned char *to, RSA *rsa, int padding);
|
|
|
|
|
2000-03-09 17:07:55 +00:00
|
|
|
/* compute r0 = r0 ^ I mod rsa->n (May be NULL for some
|
|
|
|
implementations) */
|
2000-01-11 22:35:21 +00:00
|
|
|
int (*rsa_mod_exp)(BIGNUM *r0, BIGNUM *I, RSA *rsa);
|
|
|
|
|
2000-03-09 17:07:55 +00:00
|
|
|
/* compute r = a ^ p mod m (May be NULL for some implementations) */
|
2000-01-11 22:35:21 +00:00
|
|
|
int (*bn_mod_exp)(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
|
|
|
|
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
|
|
|
|
|
|
|
/* called at RSA_new */
|
|
|
|
int (*init)(RSA *rsa);
|
|
|
|
|
|
|
|
/* called at RSA_free */
|
|
|
|
int (*finish)(RSA *rsa);
|
|
|
|
|
|
|
|
/* RSA_FLAG_EXT_PKEY - rsa_mod_exp is called for private key
|
|
|
|
* operations, even if p,q,dmp1,dmq1,iqmp
|
|
|
|
* are NULL
|
|
|
|
* RSA_FLAG_SIGN_VER - enable rsa_sign and rsa_verify
|
|
|
|
* RSA_METHOD_FLAG_NO_CHECK - don't check pub/private match
|
|
|
|
*/
|
|
|
|
int flags;
|
|
|
|
|
|
|
|
char *app_data; /* ?? */
|
|
|
|
|
|
|
|
/* sign. For backward compatibility, this is used only
|
|
|
|
* if (flags & RSA_FLAG_SIGN_VER)
|
|
|
|
*/
|
|
|
|
int (*rsa_sign)(int type, unsigned char *m, unsigned int m_len,
|
|
|
|
unsigned char *sigret, unsigned int *siglen, RSA *rsa);
|
|
|
|
|
|
|
|
/* verify. For backward compatibility, this is used only
|
|
|
|
* if (flags & RSA_FLAG_SIGN_VER)
|
|
|
|
*/
|
|
|
|
int (*rsa_verify)(int type, unsigned char *m, unsigned int m_len,
|
|
|
|
unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
|
|
|
|
|
|
|
|
} RSA_METHOD;
|
|
|
|
|
|
|
|
=head1 RETURN VALUES
|
|
|
|
|
2000-11-08 17:51:37 +00:00
|
|
|
RSA_PKCS1_SSLeay(), RSA_PKCS1_null_method(), RSA_get_default_openssl_method()
|
|
|
|
and RSA_get_method() return pointers to the respective RSA_METHODs.
|
2000-01-11 22:35:21 +00:00
|
|
|
|
2000-10-26 21:07:28 +00:00
|
|
|
RSA_set_default_openssl_method() returns no value.
|
2000-01-11 22:35:21 +00:00
|
|
|
|
2000-10-26 21:07:28 +00:00
|
|
|
RSA_set_method() selects B<engine> as the engine that will be responsible for
|
|
|
|
all operations using the structure B<rsa>. If this function completes successfully,
|
|
|
|
then the B<rsa> structure will have its own functional reference of B<engine>, so
|
|
|
|
the caller should remember to free their own reference to B<engine> when they are
|
|
|
|
finished with it. NB: An ENGINE's RSA_METHOD can be retrieved (or set) by
|
|
|
|
ENGINE_get_RSA() or ENGINE_set_RSA().
|
2000-01-11 22:35:21 +00:00
|
|
|
|
2000-10-26 21:07:28 +00:00
|
|
|
RSA_new_method() returns NULL and sets an error code that can be
|
|
|
|
obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. Otherwise
|
|
|
|
it returns a pointer to the newly allocated structure.
|
2000-01-11 22:35:21 +00:00
|
|
|
|
|
|
|
=head1 SEE ALSO
|
|
|
|
|
2000-01-27 01:25:31 +00:00
|
|
|
L<rsa(3)|rsa(3)>, L<RSA_new(3)|RSA_new(3)>
|
2000-01-11 22:35:21 +00:00
|
|
|
|
|
|
|
=head1 HISTORY
|
|
|
|
|
|
|
|
RSA_new_method() and RSA_set_default_method() appeared in SSLeay 0.8.
|
|
|
|
RSA_get_default_method(), RSA_set_method() and RSA_get_method() as
|
|
|
|
well as the rsa_sign and rsa_verify components of RSA_METHOD were
|
|
|
|
added in OpenSSL 0.9.4.
|
|
|
|
|
2000-10-26 21:07:28 +00:00
|
|
|
RSA_set_default_openssl_method() and RSA_get_default_openssl_method()
|
|
|
|
replaced RSA_set_default_method() and RSA_get_default_method() respectively,
|
|
|
|
and RSA_set_method() and RSA_new_method() were altered to use B<ENGINE>s
|
2000-11-06 21:28:38 +00:00
|
|
|
rather than B<RSA_METHOD>s during development of OpenSSL 0.9.6.
|
2000-10-26 21:07:28 +00:00
|
|
|
|
2000-01-11 22:35:21 +00:00
|
|
|
=cut
|