From 19417e33e2277fd2979d5bd1a960f09f8b4079f2 Mon Sep 17 00:00:00 2001 From: gotoyuzo Date: Sun, 18 Sep 2005 22:56:11 +0000 Subject: * ext/openssl/ossl_pkey.h, ossl_pkey_rsa.c, ossl_pkey_dsa.c: an instance variable "private" is added to OpenSSL::PKey class. this ivar is a flag that shows whether there is a private key in the instance. * ext/openssl/ossl_engine.c: (ossl_engine_load_privkey): set private key flag. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/openssl/ossl_pkey_rsa.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'ext/openssl/ossl_pkey_rsa.c') diff --git a/ext/openssl/ossl_pkey_rsa.c b/ext/openssl/ossl_pkey_rsa.c index 75b02d2..17bec2b 100644 --- a/ext/openssl/ossl_pkey_rsa.c +++ b/ext/openssl/ossl_pkey_rsa.c @@ -20,12 +20,7 @@ } while (0) #define RSA_HAS_PRIVATE(rsa) ((rsa)->p && (rsa)->q) - -#ifdef OSSL_ENGINE_ENABLED -# define RSA_PRIVATE(rsa) (RSA_HAS_PRIVATE(rsa) || (rsa)->engine) -#else -# define RSA_PRIVATE(rsa) RSA_HAS_PRIVATE(rsa) -#endif +#define RSA_PRIVATE(obj,rsa) (RSA_HAS_PRIVATE(rsa)||OSSL_PKEY_IS_PRIVATE(obj)) /* * Classes @@ -181,8 +176,8 @@ ossl_rsa_is_private(VALUE self) EVP_PKEY *pkey; GetPKeyRSA(self, pkey); - - return (RSA_PRIVATE(pkey->pkey.rsa)) ? Qtrue : Qfalse; + + return (RSA_PRIVATE(self, pkey->pkey.rsa)) ? Qtrue : Qfalse; } static VALUE @@ -303,7 +298,7 @@ ossl_rsa_private_encrypt(int argc, VALUE *argv, VALUE self) VALUE str, buffer, padding; GetPKeyRSA(self, pkey); - if (!RSA_PRIVATE(pkey->pkey.rsa)) { + if (!RSA_PRIVATE(self, pkey->pkey.rsa)) { ossl_raise(eRSAError, "private key needed."); } rb_scan_args(argc, argv, "11", &buffer, &padding); @@ -328,7 +323,7 @@ ossl_rsa_private_decrypt(int argc, VALUE *argv, VALUE self) VALUE str, buffer, padding; GetPKeyRSA(self, pkey); - if (!RSA_PRIVATE(pkey->pkey.rsa)) { + if (!RSA_PRIVATE(self, pkey->pkey.rsa)) { ossl_raise(eRSAError, "private key needed."); } rb_scan_args(argc, argv, "11", &buffer, &padding); -- cgit v1.2.3