blob: 9ed92d48a821d91e4a65ba97e4dadb0d007d5299 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// -*- C++ -*-
#include "SSLIOP_EVP_PKEY.h"
#include <openssl/x509.h>
#include <openssl/rsa.h>
#include <openssl/dsa.h>
#include <openssl/dh.h>
#include "params_dup.h"
ACE_RCSID (SSLIOP,
SSLIOP_EVP_PKEY,
"$Id$")
::EVP_PKEY *
TAO::SSLIOP::OpenSSL_traits< ::EVP_PKEY >::copy (::EVP_PKEY const & key)
{
::EVP_PKEY * pkey = const_cast< ::EVP_PKEY *> (&key);
// We're using the EVP_PKEY_var even though it depends on this
// trait function. This works since we're not actually using
// any of the EVP_PKEY_var methods that call this copy()
// trait. This allows us to maintain exception safety.
TAO::SSLIOP::EVP_PKEY_var p = ::EVP_PKEY_new ();
switch (::EVP_PKEY_type (pkey->type))
{
case EVP_PKEY_RSA:
{
RSA * rsa = ::EVP_PKEY_get1_RSA (pkey);
if (rsa != 0)
{
// Not exception safe!
::EVP_PKEY_set1_RSA (p.in (), RSAPrivateKey_dup (rsa));
::RSA_free (rsa);
}
}
break;
case EVP_PKEY_DSA:
{
DSA * dsa = ::EVP_PKEY_get1_DSA (pkey);
if (dsa != 0)
{
// Not exception safe!
::EVP_PKEY_set1_DSA (p.in (), DSAparams_dup_wrapper (dsa));
::DSA_free (dsa);
}
}
break;
case EVP_PKEY_DH:
{
DH * dh = ::EVP_PKEY_get1_DH (pkey);
if (dh != 0)
{
// Not exception safe!
::EVP_PKEY_set1_DH (p.in (), DHparams_dup_wrapper (dh));
::DH_free (dh);
}
}
break;
default:
// We should never get here!
return 0;
}
return p._retn ();
}
|