File tree Expand file tree Collapse file tree 5 files changed +73
-2
lines changed
Expand file tree Collapse file tree 5 files changed +73
-2
lines changed Original file line number Diff line number Diff line change 4949 strategy :
5050 matrix :
5151 rust :
52- - 1.41 .0 # MSRV
52+ - 1.57 .0 # MSRV
5353 - stable
5454 steps :
5555 - uses : actions/checkout@v3
6363 - run : cargo test --no-default-features
6464 - run : cargo test
6565 - run : cargo test --all-features
66+
67+ # TODO: merge with test on MSRV bump to 1.57 or higher
68+ test-msrv-41 :
69+ runs-on : ubuntu-latest
70+ strategy :
71+ matrix :
72+ rust :
73+ - 1.41.0 # MSRV
74+ steps :
75+ - uses : actions/checkout@v3
76+ - uses : RustCrypto/actions/cargo-cache@master
77+ - uses : actions-rs/toolchain@v1
78+ with :
79+ profile : minimal
80+ toolchain : ${{ matrix.rust }}
81+ override : true
82+ - run : cargo test
83+ - run : cargo test --no-default-features
Original file line number Diff line number Diff line change @@ -15,9 +15,10 @@ categories = ["cryptography", "no-std"]
1515digest = " 0.10.3"
1616
1717[dev-dependencies ]
18- digest = { version = " 0.10.3 " , features = [" dev" ] }
18+ digest = { version = " 0.10.4 " , features = [" dev" ] }
1919hex-literal = " 0.2.2"
2020
2121[features ]
2222default = [" std" ]
2323std = [" digest/std" ]
24+ oid = [" digest/oid" ] # Enable OID support. WARNING: Bumps MSRV to 1.57
Original file line number Diff line number Diff line change 2121//!
2222//! Also see [RustCrypto/hashes][2] readme.
2323//!
24+ //! # Associated OIDs.
25+ //! There can be a confusion regarding OIDs associated with declared types. According to the
26+ //! [RFC 4357][3], the OIDs 1.2.643.2.2.30.1 and 1.2.643.2.2.30.0 are used to identify the hash
27+ //! function parameter sets (CryptoPro vs Test ones). According to [RFC 4490][4] the OID
28+ //! 1.2.643.2.2.9 identifies the GOST 34.311-95 (former GOST R 34.11-94) function, but then it
29+ //! continues that this function MUST be used only with the CryptoPro parameter set.
30+ //!
2431//! [1]: https://en.wikipedia.org/wiki/GOST_(hash_function)
2532//! [2]: https://github.com/RustCrypto/hashes
33+ //! [3]: https://www.rfc-editor.org/rfc/rfc4357
34+ //! [4]: https://www.rfc-editor.org/rfc/rfc4490
2635
2736#![ no_std]
2837#![ doc(
3544#[ cfg( feature = "std" ) ]
3645extern crate std;
3746
47+ #[ cfg( feature = "oid" ) ]
48+ use digest:: const_oid:: { AssociatedOid , ObjectIdentifier } ;
3849use digest:: core_api:: CoreWrapper ;
3950
4051mod gost94_core;
@@ -45,6 +56,17 @@ pub use digest::{self, Digest};
4556
4657pub use gost94_core:: Gost94Core ;
4758
59+ #[ cfg( feature = "oid" ) ]
60+ impl AssociatedOid for Gost94Core < params:: CryptoProParam > {
61+ /// Per RFC 4490
62+ const OID : ObjectIdentifier = ObjectIdentifier :: new_unwrap ( "1.2.643.2.2.9" ) ;
63+ }
64+
65+ #[ cfg( feature = "oid" ) ]
66+ impl AssociatedOid for Gost94Core < params:: GOST28147UAParam > {
67+ const OID : ObjectIdentifier = ObjectIdentifier :: new_unwrap ( "1.2.804.2.1.1.1.1.2.1" ) ;
68+ }
69+
4870/// GOST94 hash function with CryptoPro parameters.
4971pub type Gost94CryptoPro = CoreWrapper < Gost94Core < params:: CryptoProParam > > ;
5072/// GOST94 hash function with S-box defined in GOST R 34.12-2015.
Original file line number Diff line number Diff line change 1+ #[ cfg( feature = "oid" ) ]
2+ use digest:: const_oid:: { AssociatedOid , ObjectIdentifier } ;
3+
14pub ( crate ) type Block = [ u8 ; 32 ] ;
25pub ( crate ) type SBox = [ [ u8 ; 16 ] ; 8 ] ;
36
@@ -31,6 +34,12 @@ impl Gost94Params for CryptoProParam {
3134 const NAME : & ' static str = "Gost94CryptoPro" ;
3235}
3336
37+ #[ cfg( feature = "oid" ) ]
38+ impl AssociatedOid for CryptoProParam {
39+ /// Per RFC 4357
40+ const OID : ObjectIdentifier = ObjectIdentifier :: new_unwrap ( "1.2.643.2.2.30.1" ) ;
41+ }
42+
3443/// S-Box defined in GOST R 34.12-2015.
3544#[ derive( Copy , Clone , Default ) ]
3645pub struct S2015Param ;
@@ -69,6 +78,12 @@ impl Gost94Params for TestParam {
6978 const NAME : & ' static str = "Gost94Test" ;
7079}
7180
81+ #[ cfg( feature = "oid" ) ]
82+ impl AssociatedOid for TestParam {
83+ /// Per RFC 4357
84+ const OID : ObjectIdentifier = ObjectIdentifier :: new_unwrap ( "1.2.643.2.2.30.0" ) ;
85+ }
86+
7287/// S-Box defined in GOST 34.311-95 & GOST 28147:2009.
7388#[ derive( Copy , Clone , Default ) ]
7489pub struct GOST28147UAParam ;
Original file line number Diff line number Diff line change 1+ #[ cfg( feature = "oid" ) ]
2+ use digest:: const_oid:: { AssociatedOid , ObjectIdentifier } ;
13use digest:: dev:: { feed_rand_16mib, fixed_reset_test} ;
24use digest:: new_test;
35use gost94:: { Digest , Gost94CryptoPro , Gost94Test , Gost94UA } ;
@@ -91,3 +93,16 @@ fn gost_ua_engine_tests() {
9193 hex!( "7c536414f8b5b9cc649fdf3cccb2685c1a12622956308e34f31c50ed7b3af56c" ) ,
9294 ) ;
9395}
96+
97+ #[ cfg( feature = "oid" ) ]
98+ #[ test]
99+ fn gost_oid_tests ( ) {
100+ assert_eq ! (
101+ Gost94CryptoPro :: OID ,
102+ ObjectIdentifier :: new_unwrap( "1.2.643.2.2.9" )
103+ ) ;
104+ assert_eq ! (
105+ Gost94UA :: OID ,
106+ ObjectIdentifier :: new_unwrap( "1.2.804.2.1.1.1.1.2.1" )
107+ ) ;
108+ }
You can’t perform that action at this time.
0 commit comments