Debian Codegraph @

src/ffi.rs

raw symbols SCIP
1 /* automatically generated by rust-bindgen, manually modified */
2
3 /// Use, if no supported device is connected
4 pub const NK_device_model_NK_DISCONNECTED: NK_device_model = 0;
5 /// Nitrokey Pro.
6 pub const NK_device_model_NK_PRO: NK_device_model = 1;
7 /// Nitrokey Storage.
8 pub const NK_device_model_NK_STORAGE: NK_device_model = 2;
9 /// The Nitrokey device models supported by the API.
10 pub type NK_device_model = u32;
11 /// Stores the status of a Storage device.
12 #[repr(C)]
13 #[derive(Debug, Copy, Clone)]
14 pub struct NK_storage_status {
15 /// Indicates whether the unencrypted volume is read-only.
16 pub unencrypted_volume_read_only: bool,
17 /// Indicates whether the unencrypted volume is active.
18 pub unencrypted_volume_active: bool,
19 /// Indicates whether the encrypted volume is read-only.
20 pub encrypted_volume_read_only: bool,
21 /// Indicates whether the encrypted volume is active.
22 pub encrypted_volume_active: bool,
23 /// Indicates whether the hidden volume is read-only.
24 pub hidden_volume_read_only: bool,
25 /// Indicates whether the hidden volume is active.
26 pub hidden_volume_active: bool,
27 /// The major firmware version, e. g. 0 in v0.40.
28 pub firmware_version_major: u8,
29 /// The minor firmware version, e. g. 40 in v0.40.
30 pub firmware_version_minor: u8,
31 /// Indicates whether the firmware is locked.
32 pub firmware_locked: bool,
33 /// The serial number of the SD card in the Storage stick.
34 pub serial_number_sd_card: u32,
35 /// The serial number of the smart card in the Storage stick.
36 pub serial_number_smart_card: u32,
37 /// The number of remaining login attempts for the user PIN.
38 pub user_retry_count: u8,
39 /// The number of remaining login attempts for the admin PIN.
40 pub admin_retry_count: u8,
41 /// Indicates whether a new SD card was found.
42 pub new_sd_card_found: bool,
43 /// Indicates whether the SD card is filled with random characters.
44 pub filled_with_random: bool,
45 /// Indicates whether the stick has been initialized by generating
46 /// the AES keys.
47 pub stick_initialized: bool,
48 }
49 #[test]
50 fn bindgen_test_layout_NK_storage_status() {
51 assert_eq!(
52 ::std::mem::size_of::<NK_storage_status>(),
53 28usize,
54 concat!("Size of: ", stringify!(NK_storage_status))
55 );
56 assert_eq!(
57 ::std::mem::align_of::<NK_storage_status>(),
58 4usize,
59 concat!("Alignment of ", stringify!(NK_storage_status))
60 );
61 assert_eq!(
62 unsafe {
63 &(*(::std::ptr::null::<NK_storage_status>())).unencrypted_volume_read_only as *const _
64 as usize
65 },
66 0usize,
67 concat!(
68 "Offset of field: ",
69 stringify!(NK_storage_status),
70 "::",
71 stringify!(unencrypted_volume_read_only)
72 )
73 );
74 assert_eq!(
75 unsafe {
76 &(*(::std::ptr::null::<NK_storage_status>())).unencrypted_volume_active as *const _
77 as usize
78 },
79 1usize,
80 concat!(
81 "Offset of field: ",
82 stringify!(NK_storage_status),
83 "::",
84 stringify!(unencrypted_volume_active)
85 )
86 );
87 assert_eq!(
88 unsafe {
89 &(*(::std::ptr::null::<NK_storage_status>())).encrypted_volume_read_only as *const _
90 as usize
91 },
92 2usize,
93 concat!(
94 "Offset of field: ",
95 stringify!(NK_storage_status),
96 "::",
97 stringify!(encrypted_volume_read_only)
98 )
99 );
100 assert_eq!(
101 unsafe {
102 &(*(::std::ptr::null::<NK_storage_status>())).encrypted_volume_active as *const _
103 as usize
104 },
105 3usize,
106 concat!(
107 "Offset of field: ",
108 stringify!(NK_storage_status),
109 "::",
110 stringify!(encrypted_volume_active)
111 )
112 );
113 assert_eq!(
114 unsafe {
115 &(*(::std::ptr::null::<NK_storage_status>())).hidden_volume_read_only as *const _
116 as usize
117 },
118 4usize,
119 concat!(
120 "Offset of field: ",
121 stringify!(NK_storage_status),
122 "::",
123 stringify!(hidden_volume_read_only)
124 )
125 );
126 assert_eq!(
127 unsafe {
128 &(*(::std::ptr::null::<NK_storage_status>())).hidden_volume_active as *const _ as usize
129 },
130 5usize,
131 concat!(
132 "Offset of field: ",
133 stringify!(NK_storage_status),
134 "::",
135 stringify!(hidden_volume_active)
136 )
137 );
138 assert_eq!(
139 unsafe {
140 &(*(::std::ptr::null::<NK_storage_status>())).firmware_version_major as *const _
141 as usize
142 },
143 6usize,
144 concat!(
145 "Offset of field: ",
146 stringify!(NK_storage_status),
147 "::",
148 stringify!(firmware_version_major)
149 )
150 );
151 assert_eq!(
152 unsafe {
153 &(*(::std::ptr::null::<NK_storage_status>())).firmware_version_minor as *const _
154 as usize
155 },
156 7usize,
157 concat!(
158 "Offset of field: ",
159 stringify!(NK_storage_status),
160 "::",
161 stringify!(firmware_version_minor)
162 )
163 );
164 assert_eq!(
165 unsafe {
166 &(*(::std::ptr::null::<NK_storage_status>())).firmware_locked as *const _ as usize
167 },
168 8usize,
169 concat!(
170 "Offset of field: ",
171 stringify!(NK_storage_status),
172 "::",
173 stringify!(firmware_locked)
174 )
175 );
176 assert_eq!(
177 unsafe {
178 &(*(::std::ptr::null::<NK_storage_status>())).serial_number_sd_card as *const _ as usize
179 },
180 12usize,
181 concat!(
182 "Offset of field: ",
183 stringify!(NK_storage_status),
184 "::",
185 stringify!(serial_number_sd_card)
186 )
187 );
188 assert_eq!(
189 unsafe {
190 &(*(::std::ptr::null::<NK_storage_status>())).serial_number_smart_card as *const _
191 as usize
192 },
193 16usize,
194 concat!(
195 "Offset of field: ",
196 stringify!(NK_storage_status),
197 "::",
198 stringify!(serial_number_smart_card)
199 )
200 );
201 assert_eq!(
202 unsafe {
203 &(*(::std::ptr::null::<NK_storage_status>())).user_retry_count as *const _ as usize
204 },
205 20usize,
206 concat!(
207 "Offset of field: ",
208 stringify!(NK_storage_status),
209 "::",
210 stringify!(user_retry_count)
211 )
212 );
213 assert_eq!(
214 unsafe {
215 &(*(::std::ptr::null::<NK_storage_status>())).admin_retry_count as *const _ as usize
216 },
217 21usize,
218 concat!(
219 "Offset of field: ",
220 stringify!(NK_storage_status),
221 "::",
222 stringify!(admin_retry_count)
223 )
224 );
225 assert_eq!(
226 unsafe {
227 &(*(::std::ptr::null::<NK_storage_status>())).new_sd_card_found as *const _ as usize
228 },
229 22usize,
230 concat!(
231 "Offset of field: ",
232 stringify!(NK_storage_status),
233 "::",
234 stringify!(new_sd_card_found)
235 )
236 );
237 assert_eq!(
238 unsafe {
239 &(*(::std::ptr::null::<NK_storage_status>())).filled_with_random as *const _ as usize
240 },
241 23usize,
242 concat!(
243 "Offset of field: ",
244 stringify!(NK_storage_status),
245 "::",
246 stringify!(filled_with_random)
247 )
248 );
249 assert_eq!(
250 unsafe {
251 &(*(::std::ptr::null::<NK_storage_status>())).stick_initialized as *const _ as usize
252 },
253 24usize,
254 concat!(
255 "Offset of field: ",
256 stringify!(NK_storage_status),
257 "::",
258 stringify!(stick_initialized)
259 )
260 );
261 }
262 #[repr(C)]
263 #[derive(Debug, Copy, Clone)]
264 pub struct NK_storage_ProductionTest {
265 pub FirmwareVersion_au8: [u8; 2usize],
266 pub FirmwareVersionInternal_u8: u8,
267 pub SD_Card_Size_u8: u8,
268 pub CPU_CardID_u32: u32,
269 pub SmartCardID_u32: u32,
270 pub SD_CardID_u32: u32,
271 pub SC_UserPwRetryCount: u8,
272 pub SC_AdminPwRetryCount: u8,
273 pub SD_Card_ManufacturingYear_u8: u8,
274 pub SD_Card_ManufacturingMonth_u8: u8,
275 pub SD_Card_OEM_u16: u16,
276 pub SD_WriteSpeed_u16: u16,
277 pub SD_Card_Manufacturer_u8: u8,
278 }
279 #[test]
280 fn bindgen_test_layout_NK_storage_ProductionTest() {
281 assert_eq!(
282 ::std::mem::size_of::<NK_storage_ProductionTest>(),
283 28usize,
284 concat!("Size of: ", stringify!(NK_storage_ProductionTest))
285 );
286 assert_eq!(
287 ::std::mem::align_of::<NK_storage_ProductionTest>(),
288 4usize,
289 concat!("Alignment of ", stringify!(NK_storage_ProductionTest))
290 );
291 assert_eq!(
292 unsafe {
293 &(*(::std::ptr::null::<NK_storage_ProductionTest>())).FirmwareVersion_au8 as *const _
294 as usize
295 },
296 0usize,
297 concat!(
298 "Offset of field: ",
299 stringify!(NK_storage_ProductionTest),
300 "::",
301 stringify!(FirmwareVersion_au8)
302 )
303 );
304 assert_eq!(
305 unsafe {
306 &(*(::std::ptr::null::<NK_storage_ProductionTest>())).FirmwareVersionInternal_u8
307 as *const _ as usize
308 },
309 2usize,
310 concat!(
311 "Offset of field: ",
312 stringify!(NK_storage_ProductionTest),
313 "::",
314 stringify!(FirmwareVersionInternal_u8)
315 )
316 );
317 assert_eq!(
318 unsafe {
319 &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SD_Card_Size_u8 as *const _
320 as usize
321 },
322 3usize,
323 concat!(
324 "Offset of field: ",
325 stringify!(NK_storage_ProductionTest),
326 "::",
327 stringify!(SD_Card_Size_u8)
328 )
329 );
330 assert_eq!(
331 unsafe {
332 &(*(::std::ptr::null::<NK_storage_ProductionTest>())).CPU_CardID_u32 as *const _
333 as usize
334 },
335 4usize,
336 concat!(
337 "Offset of field: ",
338 stringify!(NK_storage_ProductionTest),
339 "::",
340 stringify!(CPU_CardID_u32)
341 )
342 );
343 assert_eq!(
344 unsafe {
345 &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SmartCardID_u32 as *const _
346 as usize
347 },
348 8usize,
349 concat!(
350 "Offset of field: ",
351 stringify!(NK_storage_ProductionTest),
352 "::",
353 stringify!(SmartCardID_u32)
354 )
355 );
356 assert_eq!(
357 unsafe {
358 &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SD_CardID_u32 as *const _ as usize
359 },
360 12usize,
361 concat!(
362 "Offset of field: ",
363 stringify!(NK_storage_ProductionTest),
364 "::",
365 stringify!(SD_CardID_u32)
366 )
367 );
368 assert_eq!(
369 unsafe {
370 &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SC_UserPwRetryCount as *const _
371 as usize
372 },
373 16usize,
374 concat!(
375 "Offset of field: ",
376 stringify!(NK_storage_ProductionTest),
377 "::",
378 stringify!(SC_UserPwRetryCount)
379 )
380 );
381 assert_eq!(
382 unsafe {
383 &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SC_AdminPwRetryCount as *const _
384 as usize
385 },
386 17usize,
387 concat!(
388 "Offset of field: ",
389 stringify!(NK_storage_ProductionTest),
390 "::",
391 stringify!(SC_AdminPwRetryCount)
392 )
393 );
394 assert_eq!(
395 unsafe {
396 &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SD_Card_ManufacturingYear_u8
397 as *const _ as usize
398 },
399 18usize,
400 concat!(
401 "Offset of field: ",
402 stringify!(NK_storage_ProductionTest),
403 "::",
404 stringify!(SD_Card_ManufacturingYear_u8)
405 )
406 );
407 assert_eq!(
408 unsafe {
409 &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SD_Card_ManufacturingMonth_u8
410 as *const _ as usize
411 },
412 19usize,
413 concat!(
414 "Offset of field: ",
415 stringify!(NK_storage_ProductionTest),
416 "::",
417 stringify!(SD_Card_ManufacturingMonth_u8)
418 )
419 );
420 assert_eq!(
421 unsafe {
422 &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SD_Card_OEM_u16 as *const _
423 as usize
424 },
425 20usize,
426 concat!(
427 "Offset of field: ",
428 stringify!(NK_storage_ProductionTest),
429 "::",
430 stringify!(SD_Card_OEM_u16)
431 )
432 );
433 assert_eq!(
434 unsafe {
435 &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SD_WriteSpeed_u16 as *const _
436 as usize
437 },
438 22usize,
439 concat!(
440 "Offset of field: ",
441 stringify!(NK_storage_ProductionTest),
442 "::",
443 stringify!(SD_WriteSpeed_u16)
444 )
445 );
446 assert_eq!(
447 unsafe {
448 &(*(::std::ptr::null::<NK_storage_ProductionTest>())).SD_Card_Manufacturer_u8
449 as *const _ as usize
450 },
451 24usize,
452 concat!(
453 "Offset of field: ",
454 stringify!(NK_storage_ProductionTest),
455 "::",
456 stringify!(SD_Card_Manufacturer_u8)
457 )
458 );
459 }
460 extern "C" {
461 pub fn NK_get_storage_production_info(
462 out: *mut NK_storage_ProductionTest,
463 ) -> ::std::os::raw::c_int;
464 }
465 extern "C" {
466 /// Set debug level of messages written on stderr
467 /// @param state state=True - most messages, state=False - only errors level
468 pub fn NK_set_debug(state: bool);
469 }
470 extern "C" {
471 /// Set debug level of messages written on stderr
472 /// @param level (int) 0-lowest verbosity, 5-highest verbosity
473 pub fn NK_set_debug_level(level: ::std::os::raw::c_int);
474 }
475 extern "C" {
476 /// Get the major library version, e. g. the 3 in v3.2.
477 /// @return the major library version
478 pub fn NK_get_major_library_version() -> ::std::os::raw::c_uint;
479 }
480 extern "C" {
481 /// Get the minor library version, e. g. the 2 in v3.2.
482 /// @return the minor library version
483 pub fn NK_get_minor_library_version() -> ::std::os::raw::c_uint;
484 }
485 extern "C" {
486 /// Get the library version as a string. This is the output of
487 /// `git describe --always` at compile time, for example "v3.3" or
488 /// "v3.3-19-gaee920b".
489 /// The return value is a string literal and must not be freed.
490 /// @return the library version as a string
491 pub fn NK_get_library_version() -> *const ::std::os::raw::c_char;
492 }
493 extern "C" {
494 /// Connect to device of given model. Currently library can be connected only to one device at once.
495 /// @param device_model char 'S': Nitrokey Storage, 'P': Nitrokey Pro
496 /// @return 1 if connected, 0 if wrong model or cannot connect
497 pub fn NK_login(device_model: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
498 }
499 extern "C" {
500 /// Connect to device of given model. Currently library can be connected only to one device at once.
501 /// @param device_model NK_device_model: NK_PRO: Nitrokey Pro, NK_STORAGE: Nitrokey Storage
502 /// @return 1 if connected, 0 if wrong model or cannot connect
503 pub fn NK_login_enum(device_model: NK_device_model) -> ::std::os::raw::c_int;
504 }
505 extern "C" {
506 /// Connect to first available device, starting checking from Pro 1st to Storage 2nd.
507 /// @return 1 if connected, 0 if wrong model or cannot connect
508 pub fn NK_login_auto() -> ::std::os::raw::c_int;
509 }
510 extern "C" {
511 /// Disconnect from the device.
512 /// @return command processing error code
513 pub fn NK_logout() -> ::std::os::raw::c_int;
514 }
515 extern "C" {
516 /// Query the model of the connected device.
517 /// Returns the model of the connected device or NK_DISCONNECTED.
518 ///
519 /// @return true if a device is connected and the out argument has been set
520 pub fn NK_get_device_model() -> NK_device_model;
521 }
522 extern "C" {
523 /// Return the debug status string. Debug purposes.
524 /// @return command processing error code
525 pub fn NK_status() -> *mut ::std::os::raw::c_char;
526 }
527 extern "C" {
528 /// Return the device's serial number string in hex.
529 /// @return string device's serial number in hex
530 pub fn NK_device_serial_number() -> *mut ::std::os::raw::c_char;
531 }
532 extern "C" {
533 /// Get last command processing status. Useful for commands which returns the results of their own and could not return
534 /// an error code.
535 /// @return previous command processing error code
536 pub fn NK_get_last_command_status() -> u8;
537 }
538 extern "C" {
539 /// Lock device - cancel any user device unlocking.
540 /// @return command processing error code
541 pub fn NK_lock_device() -> ::std::os::raw::c_int;
542 }
543 extern "C" {
544 /// Authenticates the user on USER privilages with user_password and sets user's temporary password on device to user_temporary_password.
545 /// @param user_password char[25] current user password
546 /// @param user_temporary_password char[25] user temporary password to be set on device for further communication (authentication command)
547 /// @return command processing error code
548 pub fn NK_user_authenticate(
549 user_password: *const ::std::os::raw::c_char,
550 user_temporary_password: *const ::std::os::raw::c_char,
551 ) -> ::std::os::raw::c_int;
552 }
553 extern "C" {
554 /// Authenticates the user on ADMIN privilages with admin_password and sets user's temporary password on device to admin_temporary_password.
555 /// @param admin_password char[25] current administrator PIN
556 /// @param admin_temporary_password char[25] admin temporary password to be set on device for further communication (authentication command)
557 /// @return command processing error code
558 pub fn NK_first_authenticate(
559 admin_password: *const ::std::os::raw::c_char,
560 admin_temporary_password: *const ::std::os::raw::c_char,
561 ) -> ::std::os::raw::c_int;
562 }
563 extern "C" {
564 /// Execute a factory reset.
565 /// @param admin_password char[20] current administrator PIN
566 /// @return command processing error code
567 pub fn NK_factory_reset(admin_password: *const ::std::os::raw::c_char)
568 -> ::std::os::raw::c_int;
569 }
570 extern "C" {
571 /// Generates AES key on the device
572 /// @param admin_password char[20] current administrator PIN
573 /// @return command processing error code
574 pub fn NK_build_aes_key(admin_password: *const ::std::os::raw::c_char)
575 -> ::std::os::raw::c_int;
576 }
577 extern "C" {
578 /// Unlock user PIN locked after 3 incorrect codes tries.
579 /// @param admin_password char[20] current administrator PIN
580 /// @return command processing error code
581 pub fn NK_unlock_user_password(
582 admin_password: *const ::std::os::raw::c_char,
583 new_user_password: *const ::std::os::raw::c_char,
584 ) -> ::std::os::raw::c_int;
585 }
586 extern "C" {
587 /// Write general config to the device
588 /// @param numlock set value in range [0-1] to send HOTP code from slot 'numlock' after double pressing numlock
589 /// or outside the range to disable this function
590 /// @param capslock similar to numlock but with capslock
591 /// @param scrolllock similar to numlock but with scrolllock
592 /// @param enable_user_password set True to enable OTP PIN protection (require PIN each OTP code request)
593 /// @param delete_user_password (unused)
594 /// @param admin_temporary_password current admin temporary password
595 /// @return command processing error code
596 pub fn NK_write_config(
597 numlock: u8,
598 capslock: u8,
599 scrolllock: u8,
600 enable_user_password: bool,
601 delete_user_password: bool,
602 admin_temporary_password: *const ::std::os::raw::c_char,
603 ) -> ::std::os::raw::c_int;
604 }
605 extern "C" {
606 /// Get currently set config - status of function Numlock/Capslock/Scrollock OTP sending and is enabled PIN protected OTP
607 /// @see NK_write_config
608 /// @return uint8_t general_config[5]:
609 /// uint8_t numlock;
610 /// uint8_t capslock;
611 /// uint8_t scrolllock;
612 /// uint8_t enable_user_password;
613 /// uint8_t delete_user_password;
614 pub fn NK_read_config() -> *mut u8;
615 }
616 extern "C" {
617 /// Get name of given TOTP slot
618 /// @param slot_number TOTP slot number, slot_number<15
619 /// @return char[20] the name of the slot
620 pub fn NK_get_totp_slot_name(slot_number: u8) -> *mut ::std::os::raw::c_char;
621 }
622 extern "C" {
623 /// @param slot_number HOTP slot number, slot_number<3
624 /// @return char[20] the name of the slot
625 pub fn NK_get_hotp_slot_name(slot_number: u8) -> *mut ::std::os::raw::c_char;
626 }
627 extern "C" {
628 /// Erase HOTP slot data from the device
629 /// @param slot_number HOTP slot number, slot_number<3
630 /// @param temporary_password admin temporary password
631 /// @return command processing error code
632 pub fn NK_erase_hotp_slot(
633 slot_number: u8,
634 temporary_password: *const ::std::os::raw::c_char,
635 ) -> ::std::os::raw::c_int;
636 }
637 extern "C" {
638 /// Erase TOTP slot data from the device
639 /// @param slot_number TOTP slot number, slot_number<15
640 /// @param temporary_password admin temporary password
641 /// @return command processing error code
642 pub fn NK_erase_totp_slot(
643 slot_number: u8,
644 temporary_password: *const ::std::os::raw::c_char,
645 ) -> ::std::os::raw::c_int;
646 }
647 extern "C" {
648 /// Write HOTP slot data to the device
649 /// @param slot_number HOTP slot number, slot_number<3, 0-numbered
650 /// @param slot_name char[15] desired slot name. C string (requires ending '\0'; 16 bytes).
651 /// @param secret char[40] 160-bit or 320-bit (currently Pro v0.8 only) secret as a hex string. C string (requires ending '\0'; 41 bytes).
652 /// See NitrokeyManager::is_320_OTP_secret_supported.
653 /// @param hotp_counter uint32_t starting value of HOTP counter
654 /// @param use_8_digits should returned codes be 6 (false) or 8 digits (true)
655 /// @param use_enter press ENTER key after sending OTP code using double-pressed scroll/num/capslock
656 /// @param use_tokenID @see token_ID
657 /// @param token_ID @see https://openauthentication.org/token-specs/, 'Class A' section
658 /// @param temporary_password char[25] admin temporary password
659 /// @return command processing error code
660 pub fn NK_write_hotp_slot(
661 slot_number: u8,
662 slot_name: *const ::std::os::raw::c_char,
663 secret: *const ::std::os::raw::c_char,
664 hotp_counter: u64,
665 use_8_digits: bool,
666 use_enter: bool,
667 use_tokenID: bool,
668 token_ID: *const ::std::os::raw::c_char,
669 temporary_password: *const ::std::os::raw::c_char,
670 ) -> ::std::os::raw::c_int;
671 }
672 extern "C" {
673 /// Write TOTP slot data to the device
674 /// @param slot_number TOTP slot number, slot_number<15, 0-numbered
675 /// @param slot_name char[15] desired slot name. C string (requires ending '\0'; 16 bytes).
676 /// @param secret char[40] 160-bit or 320-bit (currently Pro v0.8 only) secret as a hex string. C string (requires ending '\0'; 41 bytes).
677 /// See NitrokeyManager::is_320_OTP_secret_supported.
678 /// @param time_window uint16_t time window for this TOTP
679 /// @param use_8_digits should returned codes be 6 (false) or 8 digits (true)
680 /// @param use_enter press ENTER key after sending OTP code using double-pressed scroll/num/capslock
681 /// @param use_tokenID @see token_ID
682 /// @param token_ID @see https://openauthentication.org/token-specs/, 'Class A' section
683 /// @param temporary_password char[20] admin temporary password
684 /// @return command processing error code
685 pub fn NK_write_totp_slot(
686 slot_number: u8,
687 slot_name: *const ::std::os::raw::c_char,
688 secret: *const ::std::os::raw::c_char,
689 time_window: u16,
690 use_8_digits: bool,
691 use_enter: bool,
692 use_tokenID: bool,
693 token_ID: *const ::std::os::raw::c_char,
694 temporary_password: *const ::std::os::raw::c_char,
695 ) -> ::std::os::raw::c_int;
696 }
697 extern "C" {
698 /// Get HOTP code from the device
699 /// @param slot_number HOTP slot number, slot_number<3
700 /// @return HOTP code
701 pub fn NK_get_hotp_code(slot_number: u8) -> *mut ::std::os::raw::c_char;
702 }
703 extern "C" {
704 /// Get HOTP code from the device (PIN protected)
705 /// @param slot_number HOTP slot number, slot_number<3
706 /// @param user_temporary_password char[25] user temporary password if PIN protected OTP codes are enabled,
707 /// otherwise should be set to empty string - ''
708 /// @return HOTP code
709 pub fn NK_get_hotp_code_PIN(
710 slot_number: u8,
711 user_temporary_password: *const ::std::os::raw::c_char,
712 ) -> *mut ::std::os::raw::c_char;
713 }
714 extern "C" {
715 /// Get TOTP code from the device
716 /// @param slot_number TOTP slot number, slot_number<15
717 /// @param challenge TOTP challenge -- unused
718 /// @param last_totp_time last time -- unused
719 /// @param last_interval last interval --unused
720 /// @return TOTP code
721 pub fn NK_get_totp_code(
722 slot_number: u8,
723 challenge: u64,
724 last_totp_time: u64,
725 last_interval: u8,
726 ) -> *mut ::std::os::raw::c_char;
727 }
728 extern "C" {
729 /// Get TOTP code from the device (PIN protected)
730 /// @param slot_number TOTP slot number, slot_number<15
731 /// @param challenge TOTP challenge -- unused
732 /// @param last_totp_time last time -- unused
733 /// @param last_interval last interval -- unused
734 /// @param user_temporary_password char[25] user temporary password if PIN protected OTP codes are enabled,
735 /// otherwise should be set to empty string - ''
736 /// @return TOTP code
737 pub fn NK_get_totp_code_PIN(
738 slot_number: u8,
739 challenge: u64,
740 last_totp_time: u64,
741 last_interval: u8,
742 user_temporary_password: *const ::std::os::raw::c_char,
743 ) -> *mut ::std::os::raw::c_char;
744 }
745 extern "C" {
746 /// Set time on the device (for TOTP requests)
747 /// @param time seconds in unix epoch (from 01.01.1970)
748 /// @return command processing error code
749 pub fn NK_totp_set_time(time: u64) -> ::std::os::raw::c_int;
750 }
751 extern "C" {
752 /// Set the device time used for TOTP to the given time. Contrary to
753 /// {@code set_time(uint64_t)}, this command fails if {@code old_time}
754 /// &gt; {@code time} or if {@code old_time} is zero (where {@code
755 /// old_time} is the current time on the device).
756 ///
757 /// @param time new device time as Unix timestamp (seconds since
758 /// 1970-01-01)
759 /// @return command processing error code
760 pub fn NK_totp_set_time_soft(time: u64) -> ::std::os::raw::c_int;
761 }
762 extern "C" {
763 pub fn NK_totp_get_time() -> ::std::os::raw::c_int;
764 }
765 extern "C" {
766 /// Change administrator PIN
767 /// @param current_PIN char[25] current PIN
768 /// @param new_PIN char[25] new PIN
769 /// @return command processing error code
770 pub fn NK_change_admin_PIN(
771 current_PIN: *const ::std::os::raw::c_char,
772 new_PIN: *const ::std::os::raw::c_char,
773 ) -> ::std::os::raw::c_int;
774 }
775 extern "C" {
776 /// Change user PIN
777 /// @param current_PIN char[25] current PIN
778 /// @param new_PIN char[25] new PIN
779 /// @return command processing error code
780 pub fn NK_change_user_PIN(
781 current_PIN: *const ::std::os::raw::c_char,
782 new_PIN: *const ::std::os::raw::c_char,
783 ) -> ::std::os::raw::c_int;
784 }
785 extern "C" {
786 /// Get retry count of user PIN
787 /// @return user PIN retry count
788 pub fn NK_get_user_retry_count() -> u8;
789 }
790 extern "C" {
791 /// Get retry count of admin PIN
792 /// @return admin PIN retry count
793 pub fn NK_get_admin_retry_count() -> u8;
794 }
795 extern "C" {
796 /// Enable password safe access
797 /// @param user_pin char[30] current user PIN
798 /// @return command processing error code
799 pub fn NK_enable_password_safe(
800 user_pin: *const ::std::os::raw::c_char,
801 ) -> ::std::os::raw::c_int;
802 }
803 extern "C" {
804 /// Get password safe slots' status
805 /// @return uint8_t[16] slot statuses - each byte represents one slot with 0 (not programmed) and 1 (programmed)
806 pub fn NK_get_password_safe_slot_status() -> *mut u8;
807 }
808 extern "C" {
809 /// Get password safe slot name
810 /// @param slot_number password safe slot number, slot_number<16
811 /// @return slot name
812 pub fn NK_get_password_safe_slot_name(slot_number: u8) -> *mut ::std::os::raw::c_char;
813 }
814 extern "C" {
815 /// Get password safe slot login
816 /// @param slot_number password safe slot number, slot_number<16
817 /// @return login from the PWS slot
818 pub fn NK_get_password_safe_slot_login(slot_number: u8) -> *mut ::std::os::raw::c_char;
819 }
820 extern "C" {
821 /// Get the password safe slot password
822 /// @param slot_number password safe slot number, slot_number<16
823 /// @return password from the PWS slot
824 pub fn NK_get_password_safe_slot_password(slot_number: u8) -> *mut ::std::os::raw::c_char;
825 }
826 extern "C" {
827 /// Write password safe data to the slot
828 /// @param slot_number password safe slot number, slot_number<16
829 /// @param slot_name char[11] name of the slot
830 /// @param slot_login char[32] login string
831 /// @param slot_password char[20] password string
832 /// @return command processing error code
833 pub fn NK_write_password_safe_slot(
834 slot_number: u8,
835 slot_name: *const ::std::os::raw::c_char,
836 slot_login: *const ::std::os::raw::c_char,
837 slot_password: *const ::std::os::raw::c_char,
838 ) -> ::std::os::raw::c_int;
839 }
840 extern "C" {
841 /// Erase the password safe slot from the device
842 /// @param slot_number password safe slot number, slot_number<16
843 /// @return command processing error code
844 pub fn NK_erase_password_safe_slot(slot_number: u8) -> ::std::os::raw::c_int;
845 }
846 extern "C" {
847 /// Check whether AES is supported by the device
848 /// @return 0 for no and 1 for yes
849 pub fn NK_is_AES_supported(
850 user_password: *const ::std::os::raw::c_char,
851 ) -> ::std::os::raw::c_int;
852 }
853 extern "C" {
854 /// Get device's major firmware version
855 /// @return major part of the version number (e.g. 0 from 0.48, 0 from 0.7 etc.)
856 pub fn NK_get_major_firmware_version() -> ::std::os::raw::c_int;
857 }
858 extern "C" {
859 /// Get device's minor firmware version
860 /// @return minor part of the version number (e.g. 7 from 0.7, 48 from 0.48 etc.)
861 pub fn NK_get_minor_firmware_version() -> ::std::os::raw::c_int;
862 }
863 extern "C" {
864 /// Function to determine unencrypted volume PIN type
865 /// @param minor_firmware_version
866 /// @return Returns 1, if set unencrypted volume ro/rw pin type is User, 0 otherwise.
867 pub fn NK_set_unencrypted_volume_rorw_pin_type_user() -> ::std::os::raw::c_int;
868 }
869 extern "C" {
870 /// This command is typically run to initiate
871 /// communication with the device (altough not required).
872 /// It sets time on device and returns its current status
873 /// - a combination of set_time and get_status_storage commands
874 /// Storage only
875 /// @param seconds_from_epoch date and time expressed in seconds
876 pub fn NK_send_startup(seconds_from_epoch: u64) -> ::std::os::raw::c_int;
877 }
878 extern "C" {
879 /// Unlock encrypted volume.
880 /// Storage only
881 /// @param user_pin user pin 20 characters
882 /// @return command processing error code
883 pub fn NK_unlock_encrypted_volume(
884 user_pin: *const ::std::os::raw::c_char,
885 ) -> ::std::os::raw::c_int;
886 }
887 extern "C" {
888 /// Locks encrypted volume
889 /// @return command processing error code
890 pub fn NK_lock_encrypted_volume() -> ::std::os::raw::c_int;
891 }
892 extern "C" {
893 /// Unlock hidden volume and lock encrypted volume.
894 /// Requires encrypted volume to be unlocked.
895 /// Storage only
896 /// @param hidden_volume_password 20 characters
897 /// @return command processing error code
898 pub fn NK_unlock_hidden_volume(
899 hidden_volume_password: *const ::std::os::raw::c_char,
900 ) -> ::std::os::raw::c_int;
901 }
902 extern "C" {
903 /// Locks hidden volume
904 /// @return command processing error code
905 pub fn NK_lock_hidden_volume() -> ::std::os::raw::c_int;
906 }
907 extern "C" {
908 /// Create hidden volume.
909 /// Requires encrypted volume to be unlocked.
910 /// Storage only
911 /// @param slot_nr slot number in range 0-3
912 /// @param start_percent volume begin expressed in percent of total available storage, int in range 0-99
913 /// @param end_percent volume end expressed in percent of total available storage, int in range 1-100
914 /// @param hidden_volume_password 20 characters
915 /// @return command processing error code
916 pub fn NK_create_hidden_volume(
917 slot_nr: u8,
918 start_percent: u8,
919 end_percent: u8,
920 hidden_volume_password: *const ::std::os::raw::c_char,
921 ) -> ::std::os::raw::c_int;
922 }
923 extern "C" {
924 /// Make unencrypted volume read-only.
925 /// Device hides unencrypted volume for a second therefore make sure
926 /// buffers are flushed before running.
927 /// Does nothing if firmware version is not matched
928 /// Firmware range: Storage v0.50, v0.48 and below
929 /// Storage only
930 /// @param user_pin 20 characters User PIN
931 /// @return command processing error code
932 pub fn NK_set_unencrypted_read_only(
933 user_pin: *const ::std::os::raw::c_char,
934 ) -> ::std::os::raw::c_int;
935 }
936 extern "C" {
937 /// Make unencrypted volume read-write.
938 /// Device hides unencrypted volume for a second therefore make sure
939 /// buffers are flushed before running.
940 /// Does nothing if firmware version is not matched
941 /// Firmware range: Storage v0.50, v0.48 and below
942 /// Storage only
943 /// @param user_pin 20 characters User PIN
944 /// @return command processing error code
945 pub fn NK_set_unencrypted_read_write(
946 user_pin: *const ::std::os::raw::c_char,
947 ) -> ::std::os::raw::c_int;
948 }
949 extern "C" {
950 /// Make unencrypted volume read-only.
951 /// Device hides unencrypted volume for a second therefore make sure
952 /// buffers are flushed before running.
953 /// Does nothing if firmware version is not matched
954 /// Firmware range: Storage v0.49, v0.51+
955 /// Storage only
956 /// @param admin_pin 20 characters Admin PIN
957 /// @return command processing error code
958 pub fn NK_set_unencrypted_read_only_admin(
959 admin_pin: *const ::std::os::raw::c_char,
960 ) -> ::std::os::raw::c_int;
961 }
962 extern "C" {
963 /// Make unencrypted volume read-write.
964 /// Device hides unencrypted volume for a second therefore make sure
965 /// buffers are flushed before running.
966 /// Does nothing if firmware version is not matched
967 /// Firmware range: Storage v0.49, v0.51+
968 /// Storage only
969 /// @param admin_pin 20 characters Admin PIN
970 /// @return command processing error code
971 pub fn NK_set_unencrypted_read_write_admin(
972 admin_pin: *const ::std::os::raw::c_char,
973 ) -> ::std::os::raw::c_int;
974 }
975 extern "C" {
976 /// Make encrypted volume read-only.
977 /// Device hides encrypted volume for a second therefore make sure
978 /// buffers are flushed before running.
979 /// Firmware range: v0.49 only, future (see firmware release notes)
980 /// Storage only
981 /// @param admin_pin 20 characters
982 /// @return command processing error code
983 pub fn NK_set_encrypted_read_only(
984 admin_pin: *const ::std::os::raw::c_char,
985 ) -> ::std::os::raw::c_int;
986 }
987 extern "C" {
988 /// Make encrypted volume read-write.
989 /// Device hides encrypted volume for a second therefore make sure
990 /// buffers are flushed before running.
991 /// Firmware range: v0.49 only, future (see firmware release notes)
992 /// Storage only
993 /// @param admin_pin 20 characters
994 /// @return command processing error code
995 pub fn NK_set_encrypted_read_write(
996 admin_pin: *const ::std::os::raw::c_char,
997 ) -> ::std::os::raw::c_int;
998 }
999 extern "C" {
1000 /// Exports device's firmware to unencrypted volume.
1001 /// Storage only
1002 /// @param admin_pin 20 characters
1003 /// @return command processing error code
1004 pub fn NK_export_firmware(admin_pin: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
1005 }
1006 extern "C" {
1007 /// Clear new SD card notification. It is set after factory reset.
1008 /// Storage only
1009 /// @param admin_pin 20 characters
1010 /// @return command processing error code
1011 pub fn NK_clear_new_sd_card_warning(
1012 admin_pin: *const ::std::os::raw::c_char,
1013 ) -> ::std::os::raw::c_int;
1014 }
1015 extern "C" {
1016 /// Fill SD card with random data.
1017 /// Should be done on first stick initialization after creating keys.
1018 /// Storage only
1019 /// @param admin_pin 20 characters
1020 /// @return command processing error code
1021 pub fn NK_fill_SD_card_with_random_data(
1022 admin_pin: *const ::std::os::raw::c_char,
1023 ) -> ::std::os::raw::c_int;
1024 }
1025 extern "C" {
1026 /// Change update password.
1027 /// Update password is used for entering update mode, where firmware
1028 /// could be uploaded using dfu-programmer or other means.
1029 /// Storage only
1030 /// @param current_update_password 20 characters
1031 /// @param new_update_password 20 characters
1032 /// @return command processing error code
1033 pub fn NK_change_update_password(
1034 current_update_password: *const ::std::os::raw::c_char,
1035 new_update_password: *const ::std::os::raw::c_char,
1036 ) -> ::std::os::raw::c_int;
1037 }
1038 extern "C" {
1039 /// Enter update mode. Needs update password.
1040 /// When device is in update mode it no longer accepts any HID commands until
1041 /// firmware is launched (regardless of being updated or not).
1042 /// Smartcard (through CCID interface) and its all volumes are not visible as well.
1043 /// Its VID and PID are changed to factory-default (03eb:2ff1 Atmel Corp.)
1044 /// to be detected by flashing software. Result of this command can be reversed
1045 /// by using 'launch' command.
1046 /// For dfu-programmer it would be: 'dfu-programmer at32uc3a3256s launch'.
1047 /// Storage only
1048 /// @param update_password 20 characters
1049 /// @return command processing error code
1050 pub fn NK_enable_firmware_update(
1051 update_password: *const ::std::os::raw::c_char,
1052 ) -> ::std::os::raw::c_int;
1053 }
1054 extern "C" {
1055 /// Get Storage stick status as string.
1056 /// Storage only
1057 /// @return string with devices attributes
1058 pub fn NK_get_status_storage_as_string() -> *mut ::std::os::raw::c_char;
1059 }
1060 extern "C" {
1061 /// Get the Storage stick status and return the command processing
1062 /// error code. If the code is zero, i. e. the command was successful,
1063 /// the storage status is written to the output pointer's target.
1064 /// The output pointer must not be null.
1065 ///
1066 /// @param out the output pointer for the storage status
1067 /// @return command processing error code
1068 pub fn NK_get_status_storage(out: *mut NK_storage_status) -> ::std::os::raw::c_int;
1069 }
1070 extern "C" {
1071 /// Get SD card usage attributes as string.
1072 /// Usable during hidden volumes creation.
1073 /// Storage only
1074 /// @return string with SD card usage attributes
1075 pub fn NK_get_SD_usage_data_as_string() -> *mut ::std::os::raw::c_char;
1076 }
1077 extern "C" {
1078 /// Get progress value of current long operation.
1079 /// Storage only
1080 /// @return int in range 0-100 or -1 if device is not busy
1081 pub fn NK_get_progress_bar_value() -> ::std::os::raw::c_int;
1082 }
1083 extern "C" {
1084 /// Returns a list of connected devices' id's, delimited by ';' character. Empty string is returned on no device found.
1085 /// Each ID could consist of:
1086 /// 1. SC_id:SD_id_p_path (about 40 bytes)
1087 /// 2. path (about 10 bytes)
1088 /// where 'path' is USB path (bus:num), 'SC_id' is smartcard ID, 'SD_id' is storage card ID and
1089 /// '_p_' and ':' are field delimiters.
1090 /// Case 2 (USB path only) is used, when the device cannot be asked about its status data (e.g. during a long operation,
1091 /// like clearing SD card.
1092 /// Internally connects to all available devices and creates a map between ids and connection objects.
1093 /// Side effects: changes active device to last detected Storage device.
1094 /// Storage only
1095 /// @example Example of returned data: '00005d19:dacc2cb4_p_0001:0010:02;000037c7:4cf12445_p_0001:000f:02;0001:000c:02'
1096 /// @return string delimited id's of connected devices
1097 pub fn NK_list_devices_by_cpuID() -> *mut ::std::os::raw::c_char;
1098 }
1099 extern "C" {
1100 /// Connects to the device with given ID. ID's list could be created with NK_list_devices_by_cpuID.
1101 /// Requires calling to NK_list_devices_by_cpuID first. Connecting to arbitrary ID/USB path is not handled.
1102 /// On connection requests status from device and disconnects it / removes from map on connection failure.
1103 /// Storage only
1104 /// @param id Target device ID (example: '00005d19:dacc2cb4_p_0001:0010:02')
1105 /// @return 1 on successful connection, 0 otherwise
1106 pub fn NK_connect_with_ID(id: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int;
1107 }
1108 extern "C" {
1109 /// Blink red and green LED alternatively and infinitely (until device is reconnected).
1110 /// @return command processing error code
1111 pub fn NK_wink() -> ::std::os::raw::c_int;
1112 }