rust-pkcs11 icon indicating copy to clipboard operation
rust-pkcs11 copied to clipboard

CK_ATTRIBUTE get_biginteger mixes up endianness

Open nickray opened this issue 4 years ago • 3 comments

Cryptoki base spec defines "Big integer (...) a string of CK_BYTEs representing an unsigned integer of arbitrary size, most-significant byte first (e.g., the integer 32768 is represented as the 2-byte string 0x80 0x00)".

Meanwhile, this library parses as little endian: https://github.com/mheese/rust-pkcs11/blob/1323d5f4cc4774235ef327d0f819804e2b6f2894/src/types.rs#L853-L858

nickray avatar Jan 24 '21 01:01 nickray

Yeah I just hit this too... was super confused that the lib assumes LE... which is totally not what all my other sources say including the spec.

mrodden avatar Feb 11 '21 06:02 mrodden

It's just a typo, ASN1 is definitely BE.

nickray avatar Feb 11 '21 10:02 nickray

yeah, good find guys! 👍

mheese avatar Sep 04 '21 20:09 mheese

Please switch to the cryptoki crate: https://github.com/parallaxsecond/rust-cryptoki

mheese avatar Oct 27 '22 07:10 mheese