RStudio Launcher Plugin SDK  1.1.3
A software development kit for creating plugins that work the the RStudio Launcher.
Functions
Crypto.hpp File Reference
#include <string>
#include <vector>

Go to the source code of this file.

Functions

Error rstudio::launcher_plugins::system::crypto::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. More...
 
Error rstudio::launcher_plugins::system::crypto::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. More...
 
Error rstudio::launcher_plugins::system::crypto::aesEncrypt (const std::vector< unsigned char > &in_data, const std::vector< unsigned char > &in_key, std::vector< unsigned char > &out_encrypted)
 
Error rstudio::launcher_plugins::system::crypto::base64Decode (const std::string &in_data, std::vector< unsigned char > &out_decoded)
 Base-64 decodes a string. More...
 
Error rstudio::launcher_plugins::system::crypto::base64Decode (const std::string &in_data, std::string &out_decoded)
 Base-64 decodes a string. More...
 
Error rstudio::launcher_plugins::system::crypto::base64Encode (const std::vector< unsigned char > &in_data, std::string &out_encoded)
 Base-64 encodes a string. More...
 
Error rstudio::launcher_plugins::system::crypto::base64Encode (const unsigned char *in_data, int in_length, std::string &out_encoded)
 Base-64 encodes a string. More...
 
Error rstudio::launcher_plugins::system::crypto::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, which is also base-64 encoded. More...
 
Error rstudio::launcher_plugins::system::crypto::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 base-64 encodes an initialization vector which is used in the encryption of the input. More...
 
Error rstudio::launcher_plugins::system::crypto::random (uint32_t in_length, std::vector< unsigned char > &out_randomData)
 Generates random bytes of the specified length. More...
 

Detailed Description

Cryptographic Utilities.

Function Documentation

◆ aesDecrypt()

Error rstudio::launcher_plugins::system::crypto::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.

This function is the inverse of aesEncrypt.

Parameters
in_dataThe data to be decrypted.
in_keyThe key with which to decrypt the data.
in_ivThe initialization vector that was used during encryption.
out_decryptedThe decrypted data.
Returns
Success if the data could be AES decrypted; Error otherwise.

◆ aesEncrypt() [1/2]

Error rstudio::launcher_plugins::system::crypto::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.

This function is the inverse of aesDecrypt.

Parameters
in_dataThe data to be encrypted.
in_keyThe key with which to encrypt the data.
in_ivThe initialization vector to use during encryption.
out_encryptedThe encrypted data.
Returns
Success if the data could be AES encrypted; Error otherwise.

◆ aesEncrypt() [2/2]

Error rstudio::launcher_plugins::system::crypto::aesEncrypt ( const std::vector< unsigned char > &  in_data,
const std::vector< unsigned char > &  in_key,
std::vector< unsigned char > &  out_encrypted 
)

Overloaded version of aesEncrypt for use without an initialization vector.

Parameters
in_dataThe data to be encrypted.
in_keyThe key with which to encrypt the data.
out_encryptedThe encrypted data.
Returns
Success if the data could be AES encrypted; Error otherwise.

◆ base64Decode() [1/2]

Error rstudio::launcher_plugins::system::crypto::base64Decode ( const std::string &  in_data,
std::string &  out_decoded 
)

Base-64 decodes a string.

This function is the inverse of base64Encode.

Parameters
in_dataThe base-64 encoded data to be decoded.
out_decodedThe decoded data.
Returns
Success if the data could be base-64 decoded; Error otherwise.

◆ base64Decode() [2/2]

Error rstudio::launcher_plugins::system::crypto::base64Decode ( const std::string &  in_data,
std::vector< unsigned char > &  out_decoded 
)

Base-64 decodes a string.

This function is the inverse of base64Encode.

Parameters
in_dataThe base-64 encoded data to be decoded.
out_decodedThe decoded data.
Returns
Success if the data could be base-64 decoded; Error otherwise.

◆ base64Encode() [1/2]

Error rstudio::launcher_plugins::system::crypto::base64Encode ( const std::vector< unsigned char > &  in_data,
std::string &  out_encoded 
)

Base-64 encodes a string.

This function is the inverse of base64Decode.

Parameters
in_dataThe string data to be encoded.
out_encodedThe base-64 encoded string.
Returns
Success if the data could be base-64 encoded; Error otherwise.

◆ base64Encode() [2/2]

Error rstudio::launcher_plugins::system::crypto::base64Encode ( const unsigned char *  in_data,
int  in_length,
std::string &  out_encoded 
)

Base-64 encodes a string.

This function is the inverse of base64Decode.

Parameters
in_dataThe string data to be encoded.
in_lengthThe length of in_data.
out_encodedThe base-64 encoded string.
Returns
Success if the data could be base-64 encoded; Error otherwise.

◆ decryptAndBase64Decode()

Error rstudio::launcher_plugins::system::crypto::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, which is also base-64 encoded.

This function is the inverse of encryptAndBase64Encode.

Parameters
in_inputThe base-64 encoded AES encrypted string.
in_keyThe key with which to decrypt the string.
in_ivStrThe base-64 encrypted initialization vector.
out_decryptedThe base-64 decoded and decrypted string.
Returns
Success if in_input could be base-64 decoded and decrypted; Error otherwise.

◆ encryptAndBase64Encode()

Error rstudio::launcher_plugins::system::crypto::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 base-64 encodes an initialization vector which is used in the encryption of the input.

This function is the inverse of decryptAndBase64Decode.

Parameters
in_inputThe string to encrypt and base-64 encode.
in_keyThe key with which to encrypt the string.
out_ivThe generated base-64 encoded initialization vector.
out_encryptedThe encrypted and base-64 encoded string.
Returns
Success if the string could be encrypted and base-64 encoded; Error otherwise.

◆ random()

Error rstudio::launcher_plugins::system::crypto::random ( uint32_t  in_length,
std::vector< unsigned char > &  out_randomData 
)

Generates random bytes of the specified length.

This function uses openSSL to generate random data. Summarized from the openSSL documentation: The bytes are generated using a cryptographically secure pseudo random generator. The quality of the randomness is determined by the operating system's entropy source. If an entropy source fails or isn't available, an error will be returned.

Parameters
in_lengthThe number of bytes of random data to generate.
out_randomDataThe random data.
Returns
Success if the random data could be generated; Error otherwise.