Back to index

texmacs  1.0.7.15
Functions
openssl.cpp File Reference
#include "openssl.hpp"
#include "file.hpp"

Go to the source code of this file.

Functions

void rsa_initialize ()
string rsa_my_private_key ()
string rsa_my_public_key ()
string rsa_encode (string msg, string key)
string rsa_decode (string msg, string key)
string secret_generate (int len)
string secret_encode (string msg, string key)
string secret_decode (string msg, string key)
string secret_hash (string msg)

Function Documentation

string rsa_decode ( string  msg,
string  key 
)

Definition at line 67 of file openssl.cpp.

                                    {
  url _msg= url_temp ();
  save_string (_msg, msg);
  url _key= url_temp ();
  save_string (_key, key);
  string r= eval_system ("openssl rsautl -in " * as_string (_msg) *
                      " -inkey " * as_string (_key) *
                      " -decrypt");
  remove (_msg);
  remove (_key);
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

string rsa_encode ( string  msg,
string  key 
)

Definition at line 53 of file openssl.cpp.

                                    {
  url _msg= url_temp ();
  save_string (_msg, msg);
  url _key= url_temp ();
  save_string (_key, key);
  string r= eval_system ("openssl rsautl -in " * as_string (_msg) *
                      " -pubin -inkey " * as_string (_key) *
                      " -encrypt");
  remove (_msg);
  remove (_key);
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void rsa_initialize ( )

Definition at line 20 of file openssl.cpp.

                  {
  url dir = url ("$TEXMACS_HOME_PATH") * "system/crypto";
  url priv= dir * "texmacs.private";
  url pub = dir * "texmacs.public";
  if (!exists (dir)) mkdir (dir);
  if (!exists (priv))
    system ("openssl genrsa -out " * as_string (priv) * " 2048 2> /dev/null");
  if (!exists (pub))
    system ("openssl rsa -in " * as_string (priv) *
           " -pubout -out " * as_string (pub) * " 2> /dev/null");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 33 of file openssl.cpp.

                      {
  rsa_initialize ();
  url dir = url ("$TEXMACS_HOME_PATH") * "system/crypto";
  url priv= dir * "texmacs.private";
  string private_key;
  load_string (priv, private_key, true);
  return private_key;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 43 of file openssl.cpp.

                     {
  rsa_initialize ();
  url dir = url ("$TEXMACS_HOME_PATH") * "system/crypto";
  url priv= dir * "texmacs.public";
  string public_key;
  load_string (priv, public_key, true);
  return public_key;
}

Here is the call graph for this function:

Here is the caller graph for this function:

string secret_decode ( string  msg,
string  key 
)

Definition at line 104 of file openssl.cpp.

                                       {
  url _msg= url_temp ();
  save_string (_msg, msg);
  url _key= url_temp ();
  save_string (_key, key);
  string r= eval_system ("openssl aes-256-cbc -nosalt -d -in " *
                      as_string (_msg) * " -pass file:" * as_string (_key));
  remove (_msg);
  remove (_key);
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

string secret_encode ( string  msg,
string  key 
)

Definition at line 91 of file openssl.cpp.

                                       {
  url _msg= url_temp ();
  save_string (_msg, msg);
  url _key= url_temp ();
  save_string (_key, key);
  string r= eval_system ("openssl aes-256-cbc -nosalt -in " *
                      as_string (_msg) * " -pass file:" * as_string (_key));
  remove (_msg);
  remove (_key);
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

string secret_generate ( int  len)

Definition at line 85 of file openssl.cpp.

                          {
  //return eval_system ("openssl rand -base64 " * as_string (len));
  return eval_system ("openssl rand " * as_string (len));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 117 of file openssl.cpp.

                         {
  return secret_encode ("TeXmacs worgelt BlauwBilGorgels", msg);
}

Here is the call graph for this function: