Sha256: db1b73412dec5f1f66ba24ad1433f6a580e0d526a3403ecefccc22627098840d

Contents?: true

Size: 957 Bytes

Versions: 2

Compression:

Stored size: 957 Bytes

Contents

extern crate data_encoding;
extern crate pythia;
extern crate pythia_crypto;
extern crate libc;
extern crate tokio_core;

use libc::c_char;
use data_encoding::base64url;

use pythia::client::PythiaClient;

use std::ffi::{CStr, CString};

#[no_mangle]
/// Exported standalone function to get a PRF value
pub extern "C" fn get_prf_value(input: *const c_char, tweak: *const c_char) -> CString {
    let input = unsafe {
        assert!(!input.is_null());
        CStr::from_ptr(input)
    };
    let tweak = unsafe {
        assert!(!tweak.is_null());
        CStr::from_ptr(tweak)
    };
    let input = input.to_str().unwrap();
    let tweak = tweak.to_bytes();
    let mut core = tokio_core::reactor::Core::new().unwrap();
    let handle = core.handle();
    let mut client = PythiaClient::new(&handle);
    let output = client.get_prf_value(input, tweak);
    let output = core.run(output).unwrap();
    CString::new(base64url::encode(&output)).unwrap()
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pythia-0.0.3-x86_64-linux ext/rust/src/lib.rs
pythia-0.0.2-x86_64-linux rust/src/lib.rs