aboutsummaryrefslogtreecommitdiff
path: root/ctru-rs
diff options
context:
space:
mode:
authorpanicbit <[email protected]>2017-02-21 05:08:25 +0100
committerpanicbit <[email protected]>2017-02-21 05:36:52 +0100
commitfa59c30f211d0a7ab1275c11c433a948932f083f (patch)
tree1a9efe414af7ae991181c10de384dc81b541dbf4 /ctru-rs
parentMerge pull request #19 from FenrirWolf/thread_local (diff)
downloadarchived-ctru-rs-fa59c30f211d0a7ab1275c11c433a948932f083f.tar.xz
archived-ctru-rs-fa59c30f211d0a7ab1275c11c433a948932f083f.zip
Partial sslc service implementation
Diffstat (limited to 'ctru-rs')
-rw-r--r--ctru-rs/src/services/mod.rs2
-rw-r--r--ctru-rs/src/services/sslc.rs38
2 files changed, 40 insertions, 0 deletions
diff --git a/ctru-rs/src/services/mod.rs b/ctru-rs/src/services/mod.rs
index bb96484..f8c99d2 100644
--- a/ctru-rs/src/services/mod.rs
+++ b/ctru-rs/src/services/mod.rs
@@ -2,6 +2,8 @@ pub mod apt;
pub mod fs;
pub mod hid;
pub mod gspgpu;
+pub mod sslc;
pub use self::hid::Hid;
pub use self::apt::Apt;
+pub use self::sslc::SslC;
diff --git a/ctru-rs/src/services/sslc.rs b/ctru-rs/src/services/sslc.rs
new file mode 100644
index 0000000..b3ce848
--- /dev/null
+++ b/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() };
+ }
+}