1use super::{Blake2b, Blake2s, LengthBounds};
2
3#[allow(private_bounds)]
6pub trait SupportsKeyLen<const LEN: usize>: SupportsKeyLenInternal<LEN> {}
7
8#[allow(private_bounds)]
11pub trait SupportsOutLen<const LEN: usize>: SupportsOutLenInternal<LEN> {}
12
13pub(super) trait SupportsOutLenInternal<const LEN: usize> {}
16
17pub(super) trait SupportsKeyLenInternal<const LEN: usize> {}
20
21#[allow(private_bounds)]
23impl<T, const LEN: usize> SupportsKeyLen<LEN> for T where T: SupportsKeyLenInternal<LEN> {}
24
25#[allow(private_bounds)]
27impl<T, const LEN: usize> SupportsOutLen<LEN> for T where T: SupportsOutLenInternal<LEN> {}
28
29macro_rules! support_lens {
31 ($ty:ty, $trait:ident, $($supported:expr),*) => {
32 $( impl $trait<$supported> for $ty {})*
33 };
34}
35
36#[rustfmt::skip]
39support_lens!(
40 Blake2b<LengthBounds>, SupportsOutLenInternal,
41 1, 2, 3, 4, 5, 6, 7, 8,
42 9, 10, 11, 12, 13, 14, 15, 16,
43 17, 18, 19, 20, 21, 22, 23, 24,
44 25, 26, 27, 28, 29, 30, 31, 32,
45 33, 34, 35, 36, 37, 38, 39, 40,
46 41, 42, 43, 44, 45, 46, 47, 48,
47 49, 50, 51, 52, 53, 54, 55, 56,
48 57, 58, 59, 60, 61, 62, 63, 64
49);
50
51#[rustfmt::skip]
52support_lens!(
53 Blake2s<LengthBounds>, SupportsOutLenInternal,
54 1, 2, 3, 4, 5, 6, 7, 8,
55 9, 10, 11, 12, 13, 14, 15, 16,
56 17, 18, 19, 20, 21, 22, 23, 24,
57 25, 26, 27, 28, 29, 30, 31, 32
58);
59
60#[rustfmt::skip]
61support_lens!(
62 Blake2b<LengthBounds>, SupportsKeyLenInternal,
63 0,
64 1, 2, 3, 4, 5, 6, 7, 8,
65 9, 10, 11, 12, 13, 14, 15, 16,
66 17, 18, 19, 20, 21, 22, 23, 24,
67 25, 26, 27, 28, 29, 30, 31, 32,
68 33, 34, 35, 36, 37, 38, 39, 40,
69 41, 42, 43, 44, 45, 46, 47, 48,
70 49, 50, 51, 52, 53, 54, 55, 56,
71 57, 58, 59, 60, 61, 62, 63, 64
72);
73
74#[rustfmt::skip]
75support_lens!(
76 Blake2s<LengthBounds>, SupportsKeyLenInternal,
77 0,
78 1, 2, 3, 4, 5, 6, 7, 8,
79 9, 10, 11, 12, 13, 14, 15, 16,
80 17, 18, 19, 20, 21, 22, 23, 24,
81 25, 26, 27, 28, 29, 30, 31, 32
82);