11//! KEM API
22//!
33//! See [`Kem`] for the main functionality
4- use crate :: ffi:: kem as ffi;
5- use crate :: * ;
6- use std:: os:: raw;
7- use std:: ptr:: NonNull ;
4+ use alloc:: borrow;
5+ use alloc:: vec:: Vec ;
6+
7+ use core:: ptr:: NonNull ;
8+
9+ #[ cfg( feature = "no_std" ) ]
10+ use cstr_core:: CStr ;
11+ #[ cfg( not( feature = "no_std" ) ) ]
12+ use std:: ffi:: CStr ;
813
914#[ cfg( feature = "serde" ) ]
1015use serde:: { Deserialize , Serialize } ;
1116
17+ use crate :: ffi:: kem as ffi;
1218use crate :: newtype_buffer;
19+ use crate :: * ;
1320
1421newtype_buffer ! ( PublicKey , PublicKeyRef ) ;
1522newtype_buffer ! ( SecretKey , SecretKeyRef ) ;
@@ -33,7 +40,7 @@ macro_rules! implement_kems {
3340 ) *
3441 }
3542
36- fn algorithm_to_id( algorithm: Algorithm ) -> * const raw :: c_char {
43+ fn algorithm_to_id( algorithm: Algorithm ) -> * const libc :: c_char {
3744 let id: & [ u8 ] = match algorithm {
3845 $(
3946 Algorithm :: $kem => & ffi:: $oqs_id[ ..] ,
@@ -130,7 +137,7 @@ implement_kems! {
130137 SikeP751Compressed : OQS_KEM_alg_sike_p751_compressed ,
131138}
132139
133- impl std :: default:: Default for Algorithm {
140+ impl core :: default:: Default for Algorithm {
134141 fn default ( ) -> Self {
135142 Algorithm :: Default
136143 }
@@ -146,7 +153,7 @@ impl Algorithm {
146153 /// Provides a pointer to the id of the algorithm
147154 ///
148155 /// For use with the FFI api methods
149- pub fn to_id ( self ) -> * const raw :: c_char {
156+ pub fn to_id ( self ) -> * const libc :: c_char {
150157 algorithm_to_id ( self )
151158 }
152159}
@@ -172,16 +179,16 @@ impl Kem {
172179 }
173180
174181 /// Get the name of the algorithm
175- pub fn name ( & self ) -> std :: borrow:: Cow < str > {
182+ pub fn name ( & self ) -> borrow:: Cow < str > {
176183 let kem = unsafe { self . kem . as_ref ( ) } ;
177- let cstr = unsafe { std :: ffi :: CStr :: from_ptr ( kem. method_name ) } ;
184+ let cstr = unsafe { CStr :: from_ptr ( kem. method_name ) } ;
178185 cstr. to_string_lossy ( )
179186 }
180187
181188 /// Get the version of the implementation
182- pub fn version ( & self ) -> std :: borrow:: Cow < str > {
189+ pub fn version ( & self ) -> borrow:: Cow < str > {
183190 let kem = unsafe { self . kem . as_ref ( ) } ;
184- let cstr = unsafe { std :: ffi :: CStr :: from_ptr ( kem. method_name ) } ;
191+ let cstr = unsafe { CStr :: from_ptr ( kem. method_name ) } ;
185192 cstr. to_string_lossy ( )
186193 }
187194
0 commit comments