rippled
ripple
crypto
impl
ec_key.cpp
1
//------------------------------------------------------------------------------
2
/*
3
This file is part of rippled: https://github.com/ripple/rippled
4
Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6
Permission to use, copy, modify, and/or distribute this software for any
7
purpose with or without fee is hereby granted, provided that the above
8
copyright notice and this permission notice appear in all copies.
9
10
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
*/
18
//==============================================================================
19
20
// Copyright (c) 2009-2010 Satoshi Nakamoto
21
// Copyright (c) 2011 The Bitcoin developers
22
// Distributed under the MIT/X11 software license, see the accompanying
23
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
24
25
#include <ripple/basics/contract.h>
26
#include <ripple/crypto/impl/ec_key.h>
27
#include <openssl/ec.h>
28
29
namespace
ripple
{
30
namespace
openssl {
31
32
static
inline
EC_KEY*
33
get_EC_KEY
(
const
ec_key
& that)
34
{
35
return
(EC_KEY*)that.
get
();
36
}
37
38
ec_key::ec_key
(
const
ec_key
& that)
39
{
40
if
(that.
ptr
==
nullptr
)
41
{
42
ptr
=
nullptr
;
43
return
;
44
}
45
46
ptr
= (
pointer_t
)EC_KEY_dup(
get_EC_KEY
(that));
47
48
if
(
ptr
==
nullptr
)
49
Throw<std::runtime_error>(
"ec_key::ec_key() : EC_KEY_dup failed"
);
50
51
EC_KEY_set_conv_form(
get_EC_KEY
(*
this
), POINT_CONVERSION_COMPRESSED);
52
}
53
54
void
55
ec_key::destroy
()
56
{
57
if
(
ptr
!=
nullptr
)
58
{
59
EC_KEY_free(
get_EC_KEY
(*
this
));
60
ptr
=
nullptr
;
61
}
62
}
63
64
}
// namespace openssl
65
}
// namespace ripple
ripple::openssl::ec_key::get
pointer_t get() const
Definition:
ec_key.h:54
ripple::openssl::ec_key::ptr
pointer_t ptr
Definition:
ec_key.h:72
ripple::openssl::ec_key::ec_key
ec_key()
Definition:
ec_key.h:34
ripple::openssl::ec_key::pointer_t
struct opaque_EC_KEY * pointer_t
Definition:
ec_key.h:32
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition:
RCLCensorshipDetector.h:29
ripple::openssl::ec_key
Definition:
ec_key.h:29
ripple::openssl::get_EC_KEY
static EC_KEY * get_EC_KEY(const ec_key &that)
Definition:
ec_key.cpp:33
ripple::openssl::ec_key::destroy
void destroy()
Definition:
ec_key.cpp:55
Generated by
1.8.17