RStudio Launcher Plugin SDK  1.1.3
A software development kit for creating plugins that work the the RStudio Launcher.
Crypto.hpp
Go to the documentation of this file.
1 /*
2  * Crypto.hpp
3  *
4  * Copyright (C) 2022 by RStudio, PBC
5  *
6  * Unless you have received this program directly from RStudio pursuant to the
7  * terms of a commercial license agreement with RStudio, then this program is
8  * licensed to you under the following terms:
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a copy
11  * of this software and associated documentation files (the "Software"), to deal
12  * in the Software without restriction, including without limitation the rights
13  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14  * copies of the Software, and to permit persons to whom the Software is
15  * furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included in
18  * all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26  * SOFTWARE.
27  *
28  */
29 
30 #ifndef LAUNCHER_PLUGINS_SYSTEM_CRYPTO_HPP
31 #define LAUNCHER_PLUGINS_SYSTEM_CRYPTO_HPP
32 
33 #include <string>
34 #include <vector>
35 
36 namespace rstudio {
37 namespace launcher_plugins {
38 
39 class Error;
40 class ErrorLocation;
41 
42 } // namespace launcher_plugins
43 } // namespace rstudio
44 
45 namespace rstudio {
46 namespace launcher_plugins {
47 namespace system {
48 namespace crypto {
49 
67 Error aesDecrypt(
68  const std::vector<unsigned char>& in_data,
69  const std::vector<unsigned char>& in_key,
70  const std::vector<unsigned char>& in_iv,
71  std::vector<unsigned char>& out_decrypted);
72 
85 Error aesEncrypt(
86  const std::vector<unsigned char>& in_data,
87  const std::vector<unsigned char>& in_key,
88  const std::vector<unsigned char>& in_iv,
89  std::vector<unsigned char>& out_encrypted);
90 
100 Error aesEncrypt(
101  const std::vector<unsigned char>& in_data,
102  const std::vector<unsigned char>& in_key,
103  std::vector<unsigned char>& out_encrypted);
104 
115 Error base64Decode(const std::string& in_data, std::vector<unsigned char>& out_decoded);
116 
127 Error base64Decode(const std::string& in_data, std::string& out_decoded);
128 
139 Error base64Encode(const std::vector<unsigned char>& in_data, std::string& out_encoded);
140 
152 Error base64Encode(const unsigned char* in_data, int in_length, std::string& out_encoded);
153 
168  const std::string& in_input,
169  const std::string& in_key,
170  const std::string& in_ivStr,
171  std::string& out_decrypted);
172 
187  const std::string& in_input,
188  const std::string& in_key,
189  std::string& out_iv,
190  std::string& out_encrypted);
191 
205 Error random(uint32_t in_length, std::vector<unsigned char>& out_randomData);
206 
207 } // namespace crypto
208 } // namespace system
209 } // namespace launcher_plugins
210 } // namespace rstudio
211 
212 #endif
rstudio::launcher_plugins::system::crypto::aesEncrypt
Error aesEncrypt(const std::vector< unsigned char > &in_data, const std::vector< unsigned char > &in_key, const std::vector< unsigned char > &in_iv, std::vector< unsigned char > &out_encrypted)
AES encrypts the specified data using the specified initialization vector.
rstudio::launcher_plugins::system::crypto::random
Error random(uint32_t in_length, std::vector< unsigned char > &out_randomData)
Generates random bytes of the specified length.
rstudio::launcher_plugins::system::crypto::base64Encode
Error base64Encode(const std::vector< unsigned char > &in_data, std::string &out_encoded)
Base-64 encodes a string.
rstudio::launcher_plugins::system::crypto::aesDecrypt
Error aesDecrypt(const std::vector< unsigned char > &in_data, const std::vector< unsigned char > &in_key, const std::vector< unsigned char > &in_iv, std::vector< unsigned char > &out_decrypted)
AES decrypts the specified data using the specified initialization vector.
rstudio::launcher_plugins::system::crypto::encryptAndBase64Encode
Error encryptAndBase64Encode(const std::string &in_input, const std::string &in_key, std::string &out_iv, std::string &out_encrypted)
AES encrypts and then base-64 encodes the specified string using the given key. Also generates and ba...
rstudio::launcher_plugins::system::crypto::base64Decode
Error base64Decode(const std::string &in_data, std::vector< unsigned char > &out_decoded)
Base-64 decodes a string.
rstudio::launcher_plugins::system::crypto::decryptAndBase64Decode
Error decryptAndBase64Decode(const std::string &in_input, const std::string &in_key, const std::string &in_ivStr, std::string &out_decrypted)
Base-64 decodes and then decrypts an AES encrypted string with the specified initialization vector,...