@@ -83,11 +83,13 @@ pub fn generate_cid() -> u32 {
83
83
84
84
// U2FWS (U2F WebSocket framing protocol) writes u2fhid header and payload as single package (up to
85
85
// 7+7609 bytes)
86
+ #[ cfg( feature = "wasm" ) ]
86
87
pub struct U2fWs {
87
88
cid : u32 ,
88
89
cmd : u8 ,
89
90
}
90
91
92
+ #[ cfg( feature = "wasm" ) ]
91
93
impl U2fWs {
92
94
pub fn new ( cmd : u8 ) -> Self {
93
95
U2fWs {
@@ -102,12 +104,14 @@ impl U2fWs {
102
104
}
103
105
}
104
106
107
+ #[ cfg( feature = "wasm" ) ]
105
108
impl Default for U2fWs {
106
109
fn default ( ) -> Self {
107
110
Self :: new ( 0 )
108
111
}
109
112
}
110
113
114
+ #[ cfg( feature = "wasm" ) ]
111
115
impl U2FFraming for U2fWs {
112
116
fn encode ( & self , message : & [ u8 ] , mut buf : & mut [ u8 ] ) -> io:: Result < usize > {
113
117
let len = encode_header_init ( self . cid , self . cmd , message. len ( ) as u16 , buf) ?;
@@ -314,6 +318,7 @@ mod tests {
314
318
assert_eq ! ( & data[ ..] , & payload[ ..] ) ;
315
319
}
316
320
321
+ #[ cfg( feature = "wasm" ) ]
317
322
#[ test]
318
323
fn test_u2fws_encode_single ( ) {
319
324
let codec = U2fWs :: with_cid ( 0xEEEEEEEE , 0x55 ) ;
@@ -326,6 +331,7 @@ mod tests {
326
331
) ;
327
332
}
328
333
334
+ #[ cfg( feature = "wasm" ) ]
329
335
#[ test]
330
336
fn test_u2fws_encode_multi ( ) {
331
337
let payload: Vec < u8 > = ( 0 ..65u8 ) . collect ( ) ;
@@ -339,6 +345,7 @@ mod tests {
339
345
assert_eq ! ( & data[ ..len] , & expect[ ..] ) ;
340
346
}
341
347
348
+ #[ cfg( feature = "wasm" ) ]
342
349
#[ test]
343
350
fn test_u2fws_decode_single ( ) {
344
351
let codec = U2fWs :: with_cid ( 0xEEEEEEEE , 0x55 ) ;
@@ -349,6 +356,7 @@ mod tests {
349
356
assert_eq ! ( & data[ ..] , b"\x01 \x02 \x03 \x04 " ) ;
350
357
}
351
358
359
+ #[ cfg( feature = "wasm" ) ]
352
360
#[ test]
353
361
fn test_u2fws_decode_multi ( ) {
354
362
let payload: Vec < u8 > = ( 0 ..65u8 ) . collect ( ) ;
0 commit comments