Skip to content

Conversation

@lumag
Copy link
Contributor

@lumag lumag commented Oct 3, 2022

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.

Copy link
Member

@newpavlov newpavlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

{
const OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.643.2.2.9");
}

Copy link
Member

@newpavlov newpavlov Oct 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect something like:

impl<P> AssociatedOid for Gost94Core<P>
where
    P: Gost94Params + AssociatedOid,
{
    const OID: ObjectIdentifier = P::OID;
}

Or maybe even:

impl AssociatedOid for Gost94Core<TestParam> {
    const OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.643.2.2.30.0");
}

impl AssociatedOid for Gost94Core<CryptoProParam> {
    const OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.643.2.2.30.1");
}

The latter approach would not be extensible for parameters defined in third-party crates, but I am not sure we need such capability.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that the GOST 34.311-95 is referenced using the 1.2.643.2.2.9 OID rather than individual params OIDs. See, for example, the RFC4490 and its examples. Or likewise the examples from MR 26.2.002-2012.

In the worst case, we can use the 1.2.643.2.2.9 OID for Gost94Core<CryptoProParam>.

I'm waiting for @IvashchenkoSerhii to sched the light on 1.2.804.2.1.1.1.1.2.1 usage.

Copy link
Member

@newpavlov newpavlov Oct 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh... The situation is quite annoying. We generally use OIDs for a "complete" function. It's not clear how we can support a function which has OID in a parametrized form and separate OIDs for its parameters.

The problem is that the GOST 34.311-95 is referenced using the 1.2.643.2.2.9 OID rather than individual params OIDs. See, for example, the RFC4490 and its examples. Or likewise the examples from MR 26.2.002-2012.

IIUC in the RFC 4490 case the OID is given for the CryptoPro paramset:

This function is always used with default parameters id-GostR3411-94-CryptoProParamSet (see Section 8.2 of [CPALGS]).

Maybe MR 26.2.002-2012 is the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the mentioned MR document doesn't specify any other params (or a way to specify them), so only CryptoPro params can be used with 1.2.643.2.2.9.

@lumag
Copy link
Contributor Author

lumag commented Oct 5, 2022

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
Copy link
Member

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 lumag force-pushed the gost94-oid branch 2 times, most recently from edec2c6 to 1266d94 Compare October 5, 2022 13:42
@lumag
Copy link
Contributor Author

lumag commented Oct 5, 2022

Done

@lumag lumag changed the title RFC: gost94: add OID support gost94: add OID support Oct 5, 2022
impl AssociatedOid for CryptoProParam {
/// Per the RFC 4490, this OID is used for the GOST R 34.11-94 hash with CryptoPro params.
/// The OID 1.2.643.2.2.30.1 is used in the PublicKey params to denote CryptoPro paramset, but
/// not the hash function itself.
Copy link
Member

@newpavlov newpavlov Oct 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to this description we should use:

impl AssociatedOid for Gost94Core<CryptoProParam> {
    const OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.643.2.2.9");
}

impl AssociatedOid for CryptoProParam {
    const OID: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.643.2.2.30.1");
}

Of course, the blanket impl would be removed with code like this. It does create a certain ambiguity, but I think it's the best we can do.

Also comment like this probably should go the crate docs, otherwise it will be hard for users to discover it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: Dmitry Baryshkov <[email protected]>
@newpavlov
Copy link
Member

Thank you!

@newpavlov newpavlov merged commit 5b67e73 into RustCrypto:master Oct 5, 2022
@IvashchenkoSerhii
Copy link
Contributor

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
Copy link
Contributor Author

lumag commented Oct 5, 2022

@IvashchenkoSerhii thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants