keys/rsa/rsa.go
func ReadPublic(raw []byte) (key *rsa.PublicKey,err error)  {
	var encoded *pem.Block
	
	if encoded, _ = pem.Decode(raw); encoded == nil {
		return nil, errors.New("Rsa.NewPublic(): Key must be PEM encoded PKCS1 X509 certificate or PKIX public key")
	}
		
	var parsedKey interface{}
	var cert *x509.Certificate
	
	if parsedKey, err = x509.ParsePKIXPublicKey(encoded.Bytes); err != nil {
		if cert,err = x509.ParseCertificate(encoded.Bytes);err!=nil {
			return nil, err
		}
		
		parsedKey=cert.PublicKey
	}
	
	var ok bool
	
	if key, ok = parsedKey.(*rsa.PublicKey); !ok {
		return nil, errors.New("Rsa.NewPublic(): Key is not a valid RSA public key")
	}
	
	return key, nil
}
func ReadPublic(raw []byte) (key *rsa.PublicKey,err error)  {
	var encoded *pem.Block
	
	if encoded, _ = pem.Decode(raw); encoded == nil {
		return nil, errors.New("Rsa.NewPublic(): Key must be PEM encoded PKCS1 X509 certificate or PKIX public key")
	}
		
	var parsedKey interface{}
	var cert *x509.Certificate
	
	if parsedKey, err = x509.ParsePKIXPublicKey(encoded.Bytes); err != nil {
		if cert,err = x509.ParseCertificate(encoded.Bytes);err!=nil {
			return nil, err
		}
		
		parsedKey=cert.PublicKey
	}
	
	var ok bool
	
	if key, ok = parsedKey.(*rsa.PublicKey); !ok {
		return nil, errors.New("Rsa.NewPublic(): Key is not a valid RSA public key")
	}
	
	return key, nil
}
// ReadPublic loads rsa.PublicKey from PKIX or PKCS1 X509 blobs