keys/ecc/ecc.go
func ReadPrivate(raw []byte) (key *ecdsa.PrivateKey,err error) {
	var encoded *pem.Block

	if encoded, _ = pem.Decode(raw); encoded == nil {
		return nil, errors.New("Ecc.ReadPrivate(): Key must be PEM encoded PKCS1 or PKCS8 EC private key")
	}

	var parsedKey interface{}

	if parsedKey,err=x509.ParseECPrivateKey(encoded.Bytes);err!=nil {
		if parsedKey, err = x509.ParsePKCS8PrivateKey(encoded.Bytes);err!=nil {
			return nil,err
		}
	}

	var ok bool
		
	if key,ok=parsedKey.(*ecdsa.PrivateKey);!ok {
		return nil, errors.New("Ecc.ReadPrivate(): Key is not valid *ecdsa.PrivateKey")
	}
	
	return key,nil
}
func ReadPrivate(raw []byte) (key *ecdsa.PrivateKey,err error) {
	var encoded *pem.Block

	if encoded, _ = pem.Decode(raw); encoded == nil {
		return nil, errors.New("Ecc.ReadPrivate(): Key must be PEM encoded PKCS1 or PKCS8 EC private key")
	}

	var parsedKey interface{}

	if parsedKey,err=x509.ParseECPrivateKey(encoded.Bytes);err!=nil {
		if parsedKey, err = x509.ParsePKCS8PrivateKey(encoded.Bytes);err!=nil {
			return nil,err
		}
	}

	var ok bool
		
	if key,ok=parsedKey.(*ecdsa.PrivateKey);!ok {
		return nil, errors.New("Ecc.ReadPrivate(): Key is not valid *ecdsa.PrivateKey")
	}
	
	return key,nil
}
func ReadPrivate ( raw [ ] byte ) ( key * ecdsa . PrivateKey , err error ) { var encoded * pem . Block if encoded , _ = pem . Decode ( raw ) ; encoded == nil { return nil , errors . New ( " " ) } var parsedKey interface { } if parsedKey , err = x509 . ParseECPrivateKey ( encoded . Bytes ) ; err != nil { if parsedKey , err = x509 . ParsePKCS8PrivateKey ( encoded . Bytes ) ; err != nil { return nil , err } } var ok bool if key , ok = parsedKey . ( * ecdsa . PrivateKey ) ; ! ok { return nil , errors . New ( " " ) } return key , nil }
// ReadPrivate loads ecdsa.PrivateKey from given PKCS1 or PKCS8 blobs
ReadPrivate loads ecdsa . PrivateKey from given PKCS1 or PKCS8 blobs