Skip to content

Commit 5d9d8a5

Browse files
committed
newtypes support
1 parent 0d0369f commit 5d9d8a5

File tree

3 files changed

+44
-19
lines changed

3 files changed

+44
-19
lines changed

Cargo.lock

+3-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ members = [
2727

2828
[profile.dev]
2929
opt-level = 2
30+
31+
[patch.crates-io]
32+
digest = { path = "../traits/digest" }
33+
#digest = { git = "https://github.com/baloo/traits.git", branch = "baloo/digest/new-type" }

sha2/src/lib.rs

+37-12
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,40 @@ impl_oid_carrier!(OidSha224, "2.16.840.1.101.3.4.2.4");
4646
impl_oid_carrier!(OidSha512_224, "2.16.840.1.101.3.4.2.5");
4747
impl_oid_carrier!(OidSha512_256, "2.16.840.1.101.3.4.2.6");
4848

49-
/// SHA-224 hasher.
50-
pub type Sha224 = CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, U28, OidSha224>>;
51-
/// SHA-256 hasher.
52-
pub type Sha256 = CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, U32, OidSha256>>;
53-
/// SHA-512/224 hasher.
54-
pub type Sha512_224 = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, U28, OidSha512_224>>;
55-
/// SHA-512/256 hasher.
56-
pub type Sha512_256 = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, U32, OidSha512_256>>;
57-
/// SHA-384 hasher.
58-
pub type Sha384 = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, U48, OidSha384>>;
59-
/// SHA-512 hasher.
60-
pub type Sha512 = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, U64, OidSha512>>;
49+
digest::newtype!(
50+
"SHA-224 hasher",
51+
Sha224,
52+
CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, U28, OidSha224>>
53+
);
54+
55+
digest::newtype!(
56+
"SHA-256 hasher",
57+
Sha256,
58+
CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, U32, OidSha256>>
59+
);
60+
61+
digest::newtype!(
62+
"SHA-512/224 hasher",
63+
Sha512_224,
64+
CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, U28, OidSha512_224>>
65+
);
66+
67+
digest::newtype!(
68+
"SHA-512/256 hasher",
69+
Sha512_256,
70+
CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, U32, OidSha512_256>>
71+
);
72+
73+
digest::newtype!(
74+
"SHA-384 hasher",
75+
Sha384,
76+
CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, U48, OidSha384>>
77+
);
78+
79+
digest::newtype!(
80+
"SHA-512 hasher",
81+
Sha512,
82+
CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, U64, OidSha512>>
83+
);
84+
85+

0 commit comments

Comments
 (0)