mirror of
https://github.com/LBRYFoundation/lbcd.git
synced 2025-08-23 17:47:24 +00:00
Remove workaround for certs on go1.1.2.
btcd now requires go1.2. A note to that effect is in README.md.
This commit is contained in:
parent
0bee8478a9
commit
3f37e881dc
3 changed files with 3 additions and 61 deletions
|
@ -35,6 +35,8 @@ https://github.com/conformal/btcd/releases
|
||||||
|
|
||||||
- Install Go according to the installation instructions here:
|
- Install Go according to the installation instructions here:
|
||||||
http://golang.org/doc/install
|
http://golang.org/doc/install
|
||||||
|
btcd requires features only available in go1.2 or later. At
|
||||||
|
present, that means you must install go1.2rc5 or later.
|
||||||
|
|
||||||
- Run the following command to obtain btcd, all dependencies, and install it:
|
- Run the following command to obtain btcd, all dependencies, and install it:
|
||||||
```$ go get github.com/conformal/btcd```
|
```$ go get github.com/conformal/btcd```
|
||||||
|
|
60
ofc.go
60
ofc.go
|
@ -1,60 +0,0 @@
|
||||||
// Copyright 2012 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the Golang LICENSE file.
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/ecdsa"
|
|
||||||
"crypto/elliptic"
|
|
||||||
"encoding/asn1"
|
|
||||||
"errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ecPrivateKey reflects an ASN.1 Elliptic Curve Private Key Structure.
|
|
||||||
// References:
|
|
||||||
// RFC5915
|
|
||||||
// SEC1 - http://www.secg.org/download/aid-780/sec1-v2.pdf
|
|
||||||
// Per RFC5915 the NamedCurveOID is marked as ASN.1 OPTIONAL, however in
|
|
||||||
// most cases it is not.
|
|
||||||
type ecPrivateKey struct {
|
|
||||||
Version int
|
|
||||||
PrivateKey []byte
|
|
||||||
NamedCurveOID asn1.ObjectIdentifier `asn1:"optional,explicit,tag:0"`
|
|
||||||
PublicKey asn1.BitString `asn1:"optional,explicit,tag:1"`
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
oidNamedCurveP224 = asn1.ObjectIdentifier{1, 3, 132, 0, 33}
|
|
||||||
oidNamedCurveP256 = asn1.ObjectIdentifier{1, 2, 840, 10045, 3, 1, 7}
|
|
||||||
oidNamedCurveP384 = asn1.ObjectIdentifier{1, 3, 132, 0, 34}
|
|
||||||
oidNamedCurveP521 = asn1.ObjectIdentifier{1, 3, 132, 0, 35}
|
|
||||||
)
|
|
||||||
|
|
||||||
func oidFromNamedCurve(curve elliptic.Curve) (asn1.ObjectIdentifier, bool) {
|
|
||||||
switch curve {
|
|
||||||
case elliptic.P224():
|
|
||||||
return oidNamedCurveP224, true
|
|
||||||
case elliptic.P256():
|
|
||||||
return oidNamedCurveP256, true
|
|
||||||
case elliptic.P384():
|
|
||||||
return oidNamedCurveP384, true
|
|
||||||
case elliptic.P521():
|
|
||||||
return oidNamedCurveP521, true
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
|
|
||||||
func MarshalECPrivateKey(key *ecdsa.PrivateKey) ([]byte, error) {
|
|
||||||
oid, ok := oidFromNamedCurve(key.Curve)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("x509: unknown elliptic curve")
|
|
||||||
}
|
|
||||||
return asn1.Marshal(ecPrivateKey{
|
|
||||||
Version: 1,
|
|
||||||
PrivateKey: key.D.Bytes(),
|
|
||||||
NamedCurveOID: oid,
|
|
||||||
PublicKey: asn1.BitString{Bytes: elliptic.Marshal(key.Curve, key.X, key.Y)},
|
|
||||||
})
|
|
||||||
}
|
|
|
@ -410,7 +410,7 @@ func genKey(key, cert string) error {
|
||||||
os.Remove(cert)
|
os.Remove(cert)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
keybytes, err := MarshalECPrivateKey(priv)
|
keybytes, err := x509.MarshalECPrivateKey(priv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Remove(key)
|
os.Remove(key)
|
||||||
os.Remove(cert)
|
os.Remove(cert)
|
||||||
|
|
Loading…
Add table
Reference in a new issue