1- //! Groups from [RFC5054](https://tools.ietf.org/html/rfc5054)
1+ //! Groups from [RFC5054].
22//!
3- //! It is strongly recommended to use them instead of custom generated
4- //! groups. Additionally, it is not recommended to use `G1024` and `G1536`,
3+ //! It is strongly recommended to use them instead of custom generated groups.
4+ //!
5+ //! Additionally, it is NOT recommended to use [`G1024`] and [`G1536`],
56//! they are provided only for compatibility with the legacy software.
7+ //!
8+ //! [RFC5054]: https://tools.ietf.org/html/rfc5054
69
710use core:: {
811 any,
@@ -35,12 +38,39 @@ macro_rules! define_group {
3538 #[ doc = $doc]
3639 #[ derive( Clone , Copy ) ]
3740 pub struct $name;
41+ group_trait_impls!( $name, $g, $n) ;
42+ } ;
43+ }
44+
45+ macro_rules! define_deprecated_group {
46+ ( $name: ident, $g: expr, $n: expr, $doc: expr) => {
47+ /// DEPRECATED:
48+ #[ doc = $doc]
49+ ///
50+ /// <div class="warning">
51+ /// <b>Warning: small group size!</b>
52+ ///
53+ /// It is recommended to use a group which is 2048-bits or larger.
54+ /// </div>
55+ #[ derive( Clone , Copy ) ]
56+ #[ deprecated(
57+ since = "0.7.0" ,
58+ note = "this group is too small to be secure. Prefer to use G2048+"
59+ ) ]
60+ pub struct $name;
61+ group_trait_impls!( $name, $g, $n) ;
62+ } ;
63+ }
3864
65+ macro_rules! group_trait_impls {
66+ ( $name: ident, $g: expr, $n: expr) => {
67+ #[ allow( deprecated) ]
3968 impl Group for $name {
4069 const G : u64 = $g;
41- const N : & ' static [ u8 ] = include_bytes!( "groups/1024.bin" ) ;
70+ const N : & ' static [ u8 ] = include_bytes!( $n ) ;
4271 }
4372
73+ #[ allow( deprecated) ]
4474 impl Debug for $name {
4575 fn fmt( & self , f: & mut fmt:: Formatter <' _>) -> fmt:: Result {
4676 let name = any:: type_name:: <$name>( ) ;
@@ -54,6 +84,7 @@ macro_rules! define_group {
5484 }
5585 }
5686
87+ #[ allow( deprecated) ]
5788 impl <Rhs : Group > PartialEq <Rhs > for $name {
5889 fn eq( & self , _other: & Rhs ) -> bool {
5990 Self :: G == Rhs :: G && Self :: N == Rhs :: N
@@ -62,13 +93,14 @@ macro_rules! define_group {
6293 } ;
6394}
6495
65- define_group ! ( G1024 , 2 , "groups/1024.bin" , "1024-bit group." ) ;
66- define_group ! ( G1536 , 2 , "groups/1536.bin" , "1536-bit group." ) ;
96+ define_deprecated_group ! ( G1024 , 2 , "groups/1024.bin" , "1024-bit group." ) ;
97+ define_deprecated_group ! ( G1536 , 2 , "groups/1536.bin" , "1536-bit group." ) ;
6798define_group ! ( G2048 , 2 , "groups/2048.bin" , "2048-bit group." ) ;
6899define_group ! ( G3072 , 5 , "groups/3072.bin" , "3072-bit group." ) ;
69100define_group ! ( G4096 , 5 , "groups/4096.bin" , "4096-bit group." ) ;
70101
71102#[ cfg( test) ]
103+ #[ allow( deprecated) ]
72104mod tests {
73105 use super :: { G1024 , Group } ;
74106 use crate :: utils:: compute_k;
0 commit comments