SSLIOP_EVP_PKEY.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 #include "orbsvcs/SSLIOP/SSLIOP_EVP_PKEY.h"
00004 
00005 #include <openssl/x509.h>
00006 #include <openssl/rsa.h>
00007 #include <openssl/dsa.h>
00008 #include <openssl/dh.h>
00009 #include "orbsvcs/SSLIOP/params_dup.h"
00010 
00011 
00012 ACE_RCSID (SSLIOP,
00013            SSLIOP_EVP_PKEY,
00014            "SSLIOP_EVP_PKEY.cpp,v 1.10 2006/03/14 06:14:35 jtc Exp")
00015 
00016 
00017 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00018 
00019 ::EVP_PKEY *
00020 TAO::SSLIOP::OpenSSL_traits< ::EVP_PKEY >::copy (::EVP_PKEY const & key)
00021 {
00022   ::EVP_PKEY * pkey = const_cast< ::EVP_PKEY *> (&key);
00023 
00024   // We're using the EVP_PKEY_var even though it depends on this
00025   // trait function.  This works since we're not actually using
00026   // any of the EVP_PKEY_var methods that call this copy()
00027   // trait.  This allows us to maintain exception safety.
00028   TAO::SSLIOP::EVP_PKEY_var p = ::EVP_PKEY_new ();
00029 
00030   switch (::EVP_PKEY_type (pkey->type))
00031     {
00032     case EVP_PKEY_RSA:
00033       {
00034         RSA * rsa = ::EVP_PKEY_get1_RSA (pkey);
00035         if (rsa != 0)
00036           {
00037             // Not exception safe!
00038             ::EVP_PKEY_set1_RSA (p.in (), RSAPrivateKey_dup (rsa));
00039             ::RSA_free (rsa);
00040           }
00041       }
00042       break;
00043 
00044     case EVP_PKEY_DSA:
00045       {
00046         DSA * dsa = ::EVP_PKEY_get1_DSA (pkey);
00047         if (dsa != 0)
00048           {
00049             // Not exception safe!
00050             ::EVP_PKEY_set1_DSA (p.in (), DSAPARAMS_DUP_WRAPPER_NAME (dsa));
00051             ::DSA_free (dsa);
00052           }
00053       }
00054       break;
00055 
00056     case EVP_PKEY_DH:
00057       {
00058         DH * dh = ::EVP_PKEY_get1_DH (pkey);
00059         if (dh != 0)
00060           {
00061             // Not exception safe!
00062             ::EVP_PKEY_set1_DH (p.in (), DHPARAMS_DUP_WRAPPER_NAME (dh));
00063             ::DH_free (dh);
00064           }
00065       }
00066       break;
00067 
00068     default:
00069       // We should never get here!
00070       return 0;
00071     }
00072 
00073   return p._retn ();
00074 }
00075 
00076 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 13:54:14 2006 for TAO_SSLIOP by doxygen 1.3.6