Rewrite translated code to use the pcsc crate
This commit contains a "big bang" refactor/rewrite which does the following: - Replaces all `SCard*` FFI calls with the `pcsc` crate, which provides a safe, portable PC/SC API across Windows, macOS, and Linux - Refactors the `util` module into modules representing the various device functions and concepts, e.g. `certificate`, `key`, `mgm` - Replaces all usage of `libc` with `std` functionality, and in many places rewriting functionality to use safe code. - Removes `ykpiv_` from all function names, and `Piv*` from type names. In 20/20 hindsight I wish I had done this commit more incrementally so as to make it easier to review. Que sera sera. However, realistically we need to test all functionality on the device to ensure that it actually works. Going forward I would like to put pretty much all of the current code behind an `untested` cargo feature, and then remove it for each bit of functionality we test.
This commit is contained in:
+15
-2
@@ -42,14 +42,23 @@ pub const ADMIN_FLAGS_1_PROTECTED_MGM: u8 = 0x02;
|
||||
pub const CB_ADMIN_TIMESTAMP: usize = 0x04;
|
||||
pub const CB_ADMIN_SALT: usize = 16;
|
||||
|
||||
pub const CB_ATR_MAX: usize = 33;
|
||||
|
||||
pub const CB_BUF_MAX_NEO: usize = 2048;
|
||||
|
||||
pub const CB_ECC_POINTP256: usize = 65;
|
||||
pub const CB_ECC_POINTP384: usize = 97;
|
||||
|
||||
pub const CB_OBJ_MAX: usize = 3063;
|
||||
pub const CB_OBJ_MAX_NEO: usize = CB_BUF_MAX_NEO - 9;
|
||||
|
||||
pub const CB_OBJ_TAG_MIN: usize = 2; // 1 byte tag + 1 byte len
|
||||
pub const CB_OBJ_TAG_MAX: usize = (CB_OBJ_TAG_MIN + 2); // 1 byte tag + 3 bytes len
|
||||
|
||||
pub const CB_PAGE: usize = 4096;
|
||||
pub const CB_PIN_MAX: usize = 8;
|
||||
pub const CB_ECC_POINTP256: usize = 65;
|
||||
pub const CB_ECC_POINTP384: usize = 97;
|
||||
|
||||
pub const CCC_ID_OFFS: usize = 9;
|
||||
|
||||
pub const CHUID_GUID_OFFS: usize = 29;
|
||||
|
||||
@@ -57,6 +66,9 @@ pub const CHREF_ACT_CHANGE_PIN: i32 = 0;
|
||||
pub const CHREF_ACT_UNBLOCK_PIN: i32 = 1;
|
||||
pub const CHREF_ACT_CHANGE_PUK: i32 = 2;
|
||||
|
||||
pub const CONTAINER_NAME_LEN: usize = 40;
|
||||
pub const CONTAINER_REC_LEN: usize = (2 * CONTAINER_NAME_LEN) + 27; // 80 + 1 + 1 + 2 + 1 + 1 + 1 + 20
|
||||
|
||||
pub const DES_TYPE_3DES: u8 = 1;
|
||||
|
||||
pub const DES_LEN_DES: usize = 8;
|
||||
@@ -132,6 +144,7 @@ pub const YKPIV_INS_SELECT_APPLICATION: u8 = 0xa4;
|
||||
pub const YKPIV_INS_GET_RESPONSE_APDU: u8 = 0xc0;
|
||||
|
||||
// Yubico vendor specific instructions
|
||||
// <https://developers.yubico.com/PIV/Introduction/Yubico_extensions.html>
|
||||
pub const YKPIV_INS_SET_MGMKEY: u8 = 0xff;
|
||||
pub const YKPIV_INS_IMPORT_KEY: u8 = 0xfe;
|
||||
pub const YKPIV_INS_GET_VERSION: u8 = 0xfd;
|
||||
|
||||
Reference in New Issue
Block a user