summaryrefslogtreecommitdiff
path: root/zen/open_ssl.h
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2019-07-28 22:11:18 +0000
committerB Stack <bgstack15@gmail.com>2019-07-28 22:11:18 +0000
commitd55d83514b81127e53ebcaaaf261c40c6bd265b1 (patch)
tree3e1ab2d39bea9777796470da1ee22d8a8591feef /zen/open_ssl.h
parentMerge branch '10.13' into 'master' (diff)
parentAdd open_ssl.cpp to CPP_FILES in Makefile (diff)
downloadFreeFileSync-d55d83514b81127e53ebcaaaf261c40c6bd265b1.tar.gz
FreeFileSync-d55d83514b81127e53ebcaaaf261c40c6bd265b1.tar.bz2
FreeFileSync-d55d83514b81127e53ebcaaaf261c40c6bd265b1.zip
Merge branch '10.14' into 'master'10.14
10.14 See merge request opensource-tracking/FreeFileSync!11
Diffstat (limited to 'zen/open_ssl.h')
-rw-r--r--zen/open_ssl.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/zen/open_ssl.h b/zen/open_ssl.h
new file mode 100644
index 00000000..5bf4e9ce
--- /dev/null
+++ b/zen/open_ssl.h
@@ -0,0 +1,49 @@
+// *****************************************************************************
+// * This file is part of the FreeFileSync project. It is distributed under *
+// * GNU General Public License: https://www.gnu.org/licenses/gpl-3.0 *
+// * Copyright (C) Zenju (zenju AT freefilesync DOT org) - All Rights Reserved *
+// *****************************************************************************
+
+#ifndef OPEN_SSL_H_801974580936508934568792347506
+#define OPEN_SSL_H_801974580936508934568792347506
+
+#include <zen/zstring.h>
+#include <zen/sys_error.h>
+
+
+namespace zen //init OpenSSL before use!
+{
+enum class RsaStreamType
+{
+ pkix, //base-64-encoded SubjectPublicKeyInfo structure ("BEGIN PUBLIC KEY")
+ pkcs1, //base-64-encoded RSA number and exponent ("BEGIN RSA PUBLIC KEY")
+ pkcs1_raw
+};
+
+//verify signatures produced with: "openssl dgst -sha256 -sign private.pem -out file.sig file.txt"
+void verifySignature(const std::string& message,
+ const std::string& signature,
+ const std::string& publicKeyStream,
+ RsaStreamType streamType); //throw SysError
+
+std::string convertRsaKey(const std::string& keyStream, RsaStreamType typeFrom, RsaStreamType typeTo, bool publicKey); //throw SysError
+
+
+class TlsContext
+{
+public:
+ TlsContext(int socket, //throw SysError
+ const Zstring& server,
+ const Zstring* caCertFilePath /*optional: enable certificate validation*/);
+ ~TlsContext();
+
+ size_t tryRead( void* buffer, size_t bytesToRead ); //throw SysError; may return short, only 0 means EOF!
+ size_t tryWrite(const void* buffer, size_t bytesToWrite); //throw SysError; may return short! CONTRACT: bytesToWrite > 0
+
+private:
+ class Impl;
+ const std::unique_ptr<Impl> pimpl_;
+};
+}
+
+#endif //OPEN_SSL_H_801974580936508934568792347506
bgstack15