RustCrypto / hashes

Collection of cryptographic hash functions written in pure Rust
1.83k stars 247 forks source link

gost94: add OID support #417

Closed lumag closed 1 year ago

lumag commented 1 year ago

This is an RFC for the 'oid' feature. I do not have example files with the DSTU usage, but hopefully @IvashchenkoSerhii can comment whether 1.2.804.2.1.1.1.1.2.1 is used as a separate digest parameter OID or if it is an OID of the GOST 34.311-95 with the DSTU sBox.

Additional notice. I have added AssociatedOid implementation for the individual params, howeve I do not see a way to get such OID given only the upper-level Gost94 type (CoreWrapper<Gost945Core<Gost94Params>>). Suggestions would be appreciated.

lumag commented 1 year ago

I wonder how the retracted TC26 OID 1.2.643.7.1.1.2.1 relates to the ones used in this PR. IIUC the OIDs are introduced by the CryptoPro company and it's not clear how "official" they are.

If I understand correctly this started in the same way as the story of RIPEMD OIDs. However unlike RIPEMD, the TC26 retracted duplicating OIDs.

Now back to usage question. The OID 1.2.643.2.2.30.1 was actively used in the public key params. The OID 1.2.643.2.2.9 was used in the signed CMS files to denote hashing algorithm. I haven't seen retracted TC26 OIDs in wild.

newpavlov commented 1 year ago

For now I think we should use 1.2.643.2.2.9 for Gost94Core<CryptoProParam> with a reference to RFC 4490 and remove the impl for TestParams (either way, test paramset should not be used in the wild). @IvashchenkoSerhii or someone else may add impl for the DSTU params later if such need will arise.

It may be worth to add a comment to the crate docs about 1.2.643.2.2.30.1 vs 1.2.643.2.2.9.

lumag commented 1 year ago

Done

newpavlov commented 1 year ago

Thank you!

IvashchenkoSerhii commented 1 year ago

OID 1.2.804.2.1.1.1.1.2.1 defined in this law https://zakon.rada.gov.ua/laws/show/z1399-12#Text.

It really is a GOST 34.311-95 with the DSTU sBox (https://zakon.rada.gov.ua/laws/show/z0729-07#Text search by ДКЕ N 1)

lumag commented 1 year ago

@IvashchenkoSerhii thank you!