diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2006-04-08 13:02:04 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2006-04-08 13:02:04 +0000 |
commit | 8cd44e3630d2b02e2e29f15e152131c770c165a9 (patch) | |
tree | e9fe142de8fe206dd2e0c4cfd4015cf01bf004ed /crypto/rsa | |
parent | 07e970c7e68232a7c182aa3373b74a7e88fe6a76 (diff) |
Implement encrypt/decrypt using RSA.
Diffstat (limited to 'crypto/rsa')
-rw-r--r-- | crypto/rsa/rsa_pmeth.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/crypto/rsa/rsa_pmeth.c b/crypto/rsa/rsa_pmeth.c index 78143a6ee3..7fe9e52a7d 100644 --- a/crypto/rsa/rsa_pmeth.c +++ b/crypto/rsa/rsa_pmeth.c @@ -125,6 +125,31 @@ static int pkey_rsa_verifyrecover(EVP_PKEY_CTX *ctx, return 1; } +static int pkey_rsa_encrypt(EVP_PKEY_CTX *ctx, unsigned char *out, int *outlen, + unsigned char *in, int inlen) + { + int ret; + RSA_PKEY_CTX *rctx = ctx->data; + ret = RSA_public_encrypt(inlen, in, out, ctx->pkey->pkey.rsa, + rctx->pad_mode); + if (ret < 0) + return ret; + *outlen = ret; + return 1; + } + +static int pkey_rsa_decrypt(EVP_PKEY_CTX *ctx, unsigned char *out, int *outlen, + unsigned char *in, int inlen) + { + int ret; + RSA_PKEY_CTX *rctx = ctx->data; + ret = RSA_private_decrypt(inlen, in, out, ctx->pkey->pkey.rsa, + rctx->pad_mode); + if (ret < 0) + return ret; + *outlen = ret; + return 1; + } const EVP_PKEY_METHOD rsa_pkey_meth = { @@ -143,6 +168,18 @@ const EVP_PKEY_METHOD rsa_pkey_meth = 0,0, 0, - pkey_rsa_verifyrecover + pkey_rsa_verifyrecover, + + + 0,0,0,0, + + 0, + pkey_rsa_encrypt, + + 0, + pkey_rsa_decrypt, + + 0,0 + }; |