Qore Programming Language  1.12.0
QoreSSLPrivateKey.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  QC_SSLPrivateKey.h
4 
5  Qore Programming Language
6 
7  Copyright (C) 2003 - 2022 Qore Technologies, s.r.o.
8 
9  Permission is hereby granted, free of charge, to any person obtaining a
10  copy of this software and associated documentation files (the "Software"),
11  to deal in the Software without restriction, including without limitation
12  the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  and/or sell copies of the Software, and to permit persons to whom the
14  Software is furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in
17  all copies or substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  DEALINGS IN THE SOFTWARE.
26 
27  Note that the Qore library is released under a choice of three open-source
28  licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
29  information.
30 */
31 
32 #ifndef _QORE_QORESSLPRIVATEKEY_H
33 
34 #define _QORE_QORESSLPRIVATEKEY_H
35 
36 #include <openssl/ssl.h>
37 #include <openssl/evp.h>
38 
41 public:
43 
47  DLLEXPORT QoreSSLPrivateKey(const char* fn, const char* pp, ExceptionSink* xsink);
48 
50 
53  DLLEXPORT QoreSSLPrivateKey(const BinaryNode* bin, ExceptionSink* xsink);
54 
56 
60  DLLEXPORT QoreSSLPrivateKey(const QoreString* str, const char* pp, ExceptionSink* xsink);
61 
63 
65  DLLEXPORT QoreStringNode* getPEM(ExceptionSink* xsink) const;
66 
68 
72  DLLEXPORT BinaryNode* getDER(ExceptionSink* xsink) const;
73 
74  // caller does NOT own the EVP_PKEY returned; "const" cannot be used because the openssl API does not support it
75  DLLEXPORT EVP_PKEY* getData() const;
76 
78  DLLEXPORT const char* getType() const;
79 
81  DLLEXPORT int64 getVersion() const;
82 
84  DLLEXPORT int64 getBitLength() const;
85 
87  DLLEXPORT QoreHashNode* getInfo() const;
88 
90  DLLEXPORT QoreSSLPrivateKey* pkRefSelf() const;
91 
93  DLLLOCAL QoreSSLPrivateKey(EVP_PKEY* p);
94 
95 protected:
96  DLLLOCAL virtual ~QoreSSLPrivateKey();
97 
98 private:
99  // the private implementation of the class
100  hashdecl qore_sslpk_private *priv;
101 
103  DLLLOCAL QoreSSLPrivateKey(const QoreSSLPrivateKey&) = delete;
104 
106  DLLLOCAL QoreSSLPrivateKey& operator=(const QoreSSLPrivateKey&) = delete;
107 };
108 
109 #endif
the base class for all data to be used as private data of Qore objects
Definition: AbstractPrivateData.h:44
holds arbitrary binary data
Definition: BinaryNode.h:41
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
This is the hash or associative list container type in Qore, dynamically allocated only,...
Definition: QoreHashNode.h:50
provides access to a private key data structure for SSL connections
Definition: QoreSSLPrivateKey.h:40
DLLEXPORT int64 getVersion() const
returns a constant '1': do not use; only included for backwards-compatibility
DLLEXPORT const char * getType() const
returns the key type
DLLEXPORT QoreStringNode * getPEM(ExceptionSink *xsink) const
returns a string in PEM format representing the private key, caller owns the QoreStringNode reference...
DLLEXPORT QoreSSLPrivateKey(const char *fn, const char *pp, ExceptionSink *xsink)
creates the object from a file name by reading in the file in PEM format
DLLEXPORT BinaryNode * getDER(ExceptionSink *xsink) const
returns a binary in DER format representing the private key, caller owns the BinaryNode reference cou...
DLLEXPORT int64 getBitLength() const
returns the length in bits
DLLEXPORT QoreSSLPrivateKey * pkRefSelf() const
caller owns reference returned
DLLEXPORT QoreHashNode * getInfo() const
caller owns the QoreHashNode reference count returned
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:93
Qore's string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:50
long long int64
64bit integer type, cannot use int64_t here since it breaks the API on some 64-bit systems due to equ...
Definition: common.h:260