Browse Source

Partial sslc service implementation

pull/10/head
panicbit 8 years ago
parent
commit
fa59c30f21
  1. 2
      ctru-rs/src/services/mod.rs
  2. 38
      ctru-rs/src/services/sslc.rs

2
ctru-rs/src/services/mod.rs

@ -2,6 +2,8 @@ pub mod apt;
pub mod fs; pub mod fs;
pub mod hid; pub mod hid;
pub mod gspgpu; pub mod gspgpu;
pub mod sslc;
pub use self::hid::Hid; pub use self::hid::Hid;
pub use self::apt::Apt; pub use self::apt::Apt;
pub use self::sslc::SslC;

38
ctru-rs/src/services/sslc.rs

@ -0,0 +1,38 @@
use libctru::services::sslc::*;
use Result;
// TODO: Implement remaining functions
pub struct SslC(());
impl SslC {
/// Initialize sslc
pub fn init() -> Result<Self> {
unsafe {
let r = sslcInit(0);
if r < 0 {
Err(r.into())
} else {
Ok(SslC(()))
}
}
}
/// Fill `buf` with `buf.len()` random bytes
pub fn generate_random_data(&self, buf: &mut [u8]) -> Result<()> {
unsafe {
let r = sslcGenerateRandomData(buf.as_ptr() as _, buf.len() as u32);
if r < 0 {
Err(r.into())
} else {
Ok(())
}
}
}
}
impl Drop for SslC {
fn drop(&mut self) {
unsafe { sslcExit() };
}
}
Loading…
Cancel
Save