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 valid() const
48  {
49  return ptr != nullptr;
50  }
51 
52  pointer_t get() const { return ptr; }
53 
54  ec_key (const ec_key&);
55 
57  {
58  pointer_t released = ptr;
59 
60  ptr = nullptr;
61 
62  return released;
63  }
64 
65 private:
67 
68  void destroy();
69 
70  ec_key& operator= (const ec_key&) = delete;
71 };
72 
73 } // openssl
74 } // ripple
75 
76 #endif
ripple::openssl::ec_key::get
pointer_t get() const
Definition: ec_key.h:52
ripple::openssl::ec_key::operator=
ec_key & operator=(const ec_key &)=delete
ripple::openssl::ec_key::ptr
pointer_t ptr
Definition: ec_key.h:66
ripple::openssl::ec_key::valid
bool valid() const
Definition: ec_key.h:47
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:53
ripple::openssl::ec_key::release
pointer_t release()
Definition: ec_key.h:56
ripple::openssl::ec_key::ec_key
ec_key(pointer_t raw)
Definition: ec_key.h:38