rippled
ec_key.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2014 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 #ifndef RIPPLE_CRYPTO_EC_KEY_H_INCLUDED
21 #define RIPPLE_CRYPTO_EC_KEY_H_INCLUDED
22 
23 #include <ripple/basics/base_uint.h>
24 #include <cstdint>
25 
26 namespace ripple {
27 namespace openssl {
28 
29 class ec_key
30 {
31 public:
32  using pointer_t = struct opaque_EC_KEY*;
33 
34  ec_key() : ptr(nullptr)
35  {
36  }
37 
38  ec_key(pointer_t raw) : ptr(raw)
39  {
40  }
41 
43  {
44  destroy();
45  }
46 
47  bool
48  valid() const
49  {
50  return ptr != nullptr;
51  }
52 
53  pointer_t
54  get() const
55  {
56  return ptr;
57  }
58 
59  ec_key(const ec_key&);
60 
61  pointer_t
63  {
64  pointer_t released = ptr;
65 
66  ptr = nullptr;
67 
68  return released;
69  }
70 
71 private:
73 
74  void
75  destroy();
76 
77  ec_key&
78  operator=(const ec_key&) = delete;
79 };
80 
81 } // namespace openssl
82 } // namespace ripple
83 
84 #endif
ripple::openssl::ec_key::get
pointer_t get() const
Definition: ec_key.h:54
ripple::openssl::ec_key::operator=
ec_key & operator=(const ec_key &)=delete
ripple::openssl::ec_key::ptr
pointer_t ptr
Definition: ec_key.h:72
ripple::openssl::ec_key::valid
bool valid() const
Definition: ec_key.h:48
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::openssl::ec_key::~ec_key
~ec_key()
Definition: ec_key.h:42
cstdint
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::ec_key::destroy
void destroy()
Definition: ec_key.cpp:55
ripple::openssl::ec_key::release
pointer_t release()
Definition: ec_key.h:62
ripple::openssl::ec_key::ec_key
ec_key(pointer_t raw)
Definition: ec_key.h:38