gitee.com/lh-her-team/common@v1.5.1/helper/libp2pcrypto/rsa_common.go (about) 1 package libp2pcrypto 2 3 import ( 4 "fmt" 5 "os" 6 ) 7 8 // WeakRsaKeyEnv is an environment variable which, when set, lowers the 9 // minimum required bits of RSA keys to 512. This should be used exclusively in 10 // test situations. 11 const WeakRsaKeyEnv = "LIBP2P_ALLOW_WEAK_RSA_KEYS" 12 13 var MinRsaKeyBits = 2048 14 15 // ErrRsaKeyTooSmall is returned when trying to generate or parse an RSA key 16 // that's smaller than MinRsaKeyBits bits. In test 17 var ErrRsaKeyTooSmall error 18 19 func init() { 20 if _, ok := os.LookupEnv(WeakRsaKeyEnv); ok { 21 MinRsaKeyBits = 512 22 } 23 ErrRsaKeyTooSmall = fmt.Errorf("rsa keys must be >= %d bits to be useful", MinRsaKeyBits) 24 }