func NewRSAPublicKey(
	algorithm Algorithm,
	publicKey rsa.PublicKey,
) (*RSAPublicKey, error) {

	var verify rsaVerifyFunc
	switch algorithm {
	case AlgorithmRS1:
		verify = getRSAVerifyPKCS1v15Func(crypto.SHA1)
	case AlgorithmRS256:
		verify = getRSAVerifyPKCS1v15Func(crypto.SHA256)
	case AlgorithmRS384:
		verify = getRSAVerifyPKCS1v15Func(crypto.SHA384)
	case AlgorithmRS512:
		verify = getRSAVerifyPKCS1v15Func(crypto.SHA512)
	case AlgorithmPS256:
		verify = getRSAVerifyPSSFunc(crypto.SHA256)
	case AlgorithmPS384:
		verify = getRSAVerifyPSSFunc(crypto.SHA384)
	case AlgorithmPS512:
		verify = getRSAVerifyPSSFunc(crypto.SHA512)
	default:
		return nil, fmt.Errorf("%w: %d", ErrUnsupportedAlgorithm, algorithm)
	}

	return &RSAPublicKey{
		algorithm: algorithm,
		key:       publicKey,
		verify:    verify,
	}, nil
}
// NewRSAPublicKey creates a new RSAPublicKey.
NewRSAPublicKey creates a new RSAPublicKey.
// NewRSAPublicKey creates a new RSAPublicKey .
func NewRSAPublicKey(
	algorithm Algorithm,
	publicKey rsa.PublicKey,
) (*RSAPublicKey, error) {
	var verify rsaVerifyFunc
	switch algorithm {
	case AlgorithmRS1:
		verify = getRSAVerifyPKCS1v15Func(crypto.SHA1)
	case AlgorithmRS256:
		verify = getRSAVerifyPKCS1v15Func(crypto.SHA256)
	case AlgorithmRS384:
		verify = getRSAVerifyPKCS1v15Func(crypto.SHA384)
	case AlgorithmRS512:
		verify = getRSAVerifyPKCS1v15Func(crypto.SHA512)
	case AlgorithmPS256:
		verify = getRSAVerifyPSSFunc(crypto.SHA256)
	case AlgorithmPS384:
		verify = getRSAVerifyPSSFunc(crypto.SHA384)
	case AlgorithmPS512:
		verify = getRSAVerifyPSSFunc(crypto.SHA512)
	default:
		return nil, fmt.Errorf("%w: %d", ErrUnsupportedAlgorithm, algorithm)
	}
	return &RSAPublicKey{
		algorithm: algorithm,
		key:       publicKey,
		verify:    verify,
	}, nil
}
func NewRSAPublicKey ( algorithm Algorithm , publicKey rsa . PublicKey , ) ( * RSAPublicKey , error ) { var verify rsaVerifyFunc switch algorithm { case AlgorithmRS1 : verify = getRSAVerifyPKCS1v15Func ( crypto . SHA1 ) case AlgorithmRS256 : verify = getRSAVerifyPKCS1v15Func ( crypto . SHA256 ) case AlgorithmRS384 : verify = getRSAVerifyPKCS1v15Func ( crypto . SHA384 ) case AlgorithmRS512 : verify = getRSAVerifyPKCS1v15Func ( crypto . SHA512 ) case AlgorithmPS256 : verify = getRSAVerifyPSSFunc ( crypto . SHA256 ) case AlgorithmPS384 : verify = getRSAVerifyPSSFunc ( crypto . SHA384 ) case AlgorithmPS512 : verify = getRSAVerifyPSSFunc ( crypto . SHA512 ) default : return nil , fmt . Errorf ( " " , ErrUnsupportedAlgorithm , algorithm ) } return & RSAPublicKey { algorithm : algorithm , key : publicKey , verify : verify , } , nil }
NewRSAPublicKey creates a new RSAPublicKey.
NewRSAPublicKey creates a new RSAPublicKey .