Use chinese crypto

This commit is contained in:
Liyi Meng
2022-10-08 21:15:47 +02:00
parent 401fafb7e6
commit e425269f0e
4 changed files with 80 additions and 14 deletions

View File

@@ -17,6 +17,7 @@ limitations under the License.
package cert
import (
"crypto/ecdsa"
cryptorand "crypto/rand"
"crypto/rsa"
"crypto/x509"
@@ -60,8 +61,11 @@ func MakeCSRFromTemplate(privateKey interface{}, template *x509.CertificateReque
func sigType(privateKey interface{}) x509.SignatureAlgorithm {
// Customize the signature for RSA keys, depending on the key size
if privateKey, ok := privateKey.(*rsa.PrivateKey); ok {
keySize := privateKey.N.BitLen()
switch privK := privateKey.(type) {
case *ecdsa.PrivateKey:
return x509.ECDSAWithSHA256
case *rsa.PrivateKey:
keySize := privK.N.BitLen()
switch {
case keySize >= 4096:
return x509.SHA512WithRSA