Exemplo n.º 1
0
void psx_image_module_init(void)
{
    register_func func = NULL;

#if defined(WIN32) && defined(_MSC_VER)
    lib_image = _module_load(get_library_path());
#else
    lib_image = _module_load("libpsx_image.so");
#endif
    if (lib_image == INVALID_HANDLE)
        return;

    func = _module_get_symbol(lib_image, "psx_image_register_operator");
    if (!func)
        return;

    gif_coder = (psx_image_operator*)calloc(1, sizeof(psx_image_operator));
    if (!gif_coder)
        return;

    gif_coder->read_header_info = read_gif_info;
    gif_coder->decode_image_data = decode_gif_data;
    gif_coder->release_read_header_info = release_read_gif_info;

    gif_coder->write_header_info = write_gif_info;
    gif_coder->encode_image_data = encode_gif_data;
    gif_coder->release_write_header_info = release_write_gif_info;

    func("gif", (ps_byte*)"GIF", 0, 3, PRIORITY_DEFAULT, gif_coder);
}
Exemplo n.º 2
0
static int verify_checksums(void)
{
    int rv;
    char path[PATH_MAX + 1];
    char *p;

    /* we need to avoid dlopening libssl, assume both libcrypto and libssl
       are in the same directory */

    rv = get_library_path("libcrypto.so." SHLIB_VERSION_NUMBER,
                          "FIPS_mode_set", path, sizeof(path));
    if (rv < 0)
        return 0;

    rv = FIPSCHECK_verify(path);
    if (!rv)
        return 0;

    /* replace libcrypto with libssl */
    while ((p = strstr(path, "libcrypto.so")) != NULL) {
        p = stpcpy(p, "libssl");
        memmove(p, p + 3, strlen(p + 2));
    }

    rv = FIPSCHECK_verify(path);
    if (!rv)
        return 0;
    return 1;
}
Exemplo n.º 3
0
bool GDNativeLibrary::_get(const StringName &p_name, Variant &r_ret) const {
	String name = p_name;
	if (name.begins_with("platform/")) {
		r_ret = get_library_path(name.get_slice("/", 1));
		return true;
	}
	return false;
}
Exemplo n.º 4
0
static void* score_new(t_symbol* name, int argc, t_atom* argv)
{
  t_score* x = (t_score*)eobj_new(score_class);
  auto path = get_library_path("score.");
  post("score player: %s", path.c_str());
  x->p = std::make_unique<score::Player>(path + "/plugins");

  return (x);
}
Exemplo n.º 5
0
/* Run an HMAC using the key above on the library binary data. 
 * Returns true on success and false on error.
 */
static unsigned check_binary_integrity(const char* libname, const char* symbol)
{
	int ret;
	unsigned prev;
	char mac_file[GNUTLS_PATH_MAX];
	char file[GNUTLS_PATH_MAX];
	uint8_t hmac[HMAC_SIZE];
	uint8_t new_hmac[HMAC_SIZE];
	size_t hmac_size;
	gnutls_datum_t data;

	ret = get_library_path(libname, symbol, file, sizeof(file));
	if (ret < 0) {
		_gnutls_debug_log("Could not get path for library %s\n", libname);
		return 0;
	}

	_gnutls_debug_log("Loading: %s\n", file);
	ret = gnutls_load_file(file, &data);
	if (ret < 0) {
		_gnutls_debug_log("Could not load: %s\n", file);
		return gnutls_assert_val(0);
	}

	prev = _gnutls_get_lib_state();
	_gnutls_switch_lib_state(LIB_STATE_OPERATIONAL);
	ret = gnutls_hmac_fast(HMAC_ALGO, FIPS_KEY, sizeof(FIPS_KEY)-1,
		data.data, data.size, new_hmac);
	_gnutls_switch_lib_state(prev);
	
	gnutls_free(data.data);

	if (ret < 0)
		return gnutls_assert_val(0);

	/* now open the .hmac file and compare */
	get_hmac_file(mac_file, sizeof(mac_file), file);

	ret = gnutls_load_file(mac_file, &data);
	if (ret < 0) {
		get_hmac_file2(mac_file, sizeof(mac_file), file);
		ret = gnutls_load_file(mac_file, &data);
		if (ret < 0) {
			_gnutls_debug_log("Could not open %s for MAC testing: %s\n", mac_file, gnutls_strerror(ret));
			return gnutls_assert_val(0);
		}
	}

	hmac_size = hex_data_size(data.size);
	ret = gnutls_hex_decode(&data, hmac, &hmac_size);
	gnutls_free(data.data);

	if (ret < 0) {
		_gnutls_debug_log("Could not convert hex data to binary for MAC testing for %s.\n", libname);
		return gnutls_assert_val(0);
	}

	if (hmac_size != sizeof(hmac) ||
			memcmp(hmac, new_hmac, sizeof(hmac)) != 0) {
		_gnutls_debug_log("Calculated MAC for %s does not match\n", libname);
		return gnutls_assert_val(0);
	}
	_gnutls_debug_log("Successfully verified MAC for %s (%s)\n", mac_file, libname);
	
	return 1;
}