bool TestExtOpenssl::test_openssl_digest() {
  String test = "OpenSSL is also good for hashing things";

  VS(f_md5(test), f_openssl_digest(test, "md5"));

  return Count(true);
}
Beispiel #2
0
/**
 * Loads a named systemlib section from the main binary (or DSO)
 * using the label "ext.{hash(name)}"
 *
 * If {name} is not passed, then {m_name} is assumed.
 */
void Extension::loadSystemlib(const std::string& name) {
  std::string n = name.empty() ?
    std::string(m_name.data(), m_name.size()) : name;
  std::string section("ext.");
  section += f_md5(n, false).substr(0, 12).data();
  std::string hhas;
  std::string slib = get_systemlib(&hhas, section, m_dsoName);
  if (!slib.empty()) {
    std::string phpname = s_systemlibPhpName + n;
    CompileSystemlib(slib, phpname);
  }
  if (!hhas.empty()) {
    std::string hhasname = s_systemlibHhasName + n;
    CompileSystemlib(hhas, hhasname);
  }
}
bool TestExtMcrypt::test_mcrypt_module_open() {
  Variant td = f_mcrypt_module_open("rijndael-256", "", "ofb", "");
  Variant iv = f_mcrypt_create_iv(f_mcrypt_enc_get_iv_size(td),
                                  k_MCRYPT_DEV_RANDOM);
  Variant ks = f_mcrypt_enc_get_key_size(td);
  Variant key = f_substr(f_md5("very secret key"), 0, ks);
  f_mcrypt_generic_init(td, key, iv);
  Variant encrypted = f_mcrypt_generic(td, "This is very important data");
  VERIFY(!same(encrypted, "This is very important data"));
  f_mcrypt_generic_deinit(td);
  f_mcrypt_generic_init(td, key, iv);
  Variant decrypted = f_mdecrypt_generic(td, encrypted);
  f_mcrypt_generic_end(td);
  f_mcrypt_module_close(td);

  VS(decrypted, "This is very important data");
  return Count(true);
}
Beispiel #4
0
/**
 * Loads a named systemlib section from the main binary (or DSO)
 * using the label "ext.{hash(name)}"
 *
 * If {name} is not passed, then {m_name} is assumed for
 * builtin extensions.  DSOs pull from the fixed "systemlib" label
 */
void Extension::loadSystemlib(const std::string& name /*= "" */) {
  std::string hhas, slib;
  if (m_dsoName.empty() || !name.empty()) {
    std::string section("ext.");
    section += f_md5(name.empty() ? m_name : name, false).substr(0, 12).data();
    slib = get_systemlib(&hhas, section);
  } else {
    slib = get_systemlib(&hhas, "systemlib", m_dsoName);
  }
  if (!slib.empty()) {
    std::string phpname("systemlib.php.");
    phpname += m_name.data();
    CompileSystemlib(slib, phpname);
  }
  if (!hhas.empty()) {
    std::string hhasname("systemlib.hhas.");
    hhasname += m_name.data();
    CompileSystemlib(hhas, hhasname);
  }
}
bool TestExtString::test_md5() {
  VS(f_md5("apple"), "1f3870be274f6c49b3e31a0c6728957f");
  return Count(true);
}