Skip to content

Commit

Permalink
Merge pull request #20 from SermoDigital/v1
Browse files Browse the repository at this point in the history
V1
  • Loading branch information
ericlagergren committed May 4, 2016
2 parents 1ada734 + 5e08177 commit 2a2a700
Show file tree
Hide file tree
Showing 18 changed files with 381 additions and 480 deletions.
268 changes: 0 additions & 268 deletions cover.html

This file was deleted.

4 changes: 3 additions & 1 deletion crypto/ecdsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ func (m *SigningMethodECDSA) sum(b []byte) []byte {
}

// Hasher implements the Hasher method from SigningMethod.
func (m *SigningMethodECDSA) Hasher() crypto.Hash { return m.Hash }
func (m *SigningMethodECDSA) Hasher() crypto.Hash {
return m.Hash
}

// MarshalJSON is in case somebody decides to place SigningMethodECDSA
// inside the Header, presumably because they (wrongly) decided it was a good
Expand Down
28 changes: 18 additions & 10 deletions crypto/none.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,28 @@ import (
"io"
)

func init() { crypto.RegisterHash(crypto.Hash(0), h) }
func init() {
crypto.RegisterHash(crypto.Hash(0), h)
}

// h is passed to crypto.RegisterHash.
func h() hash.Hash { return &f{Writer: nil} }
func h() hash.Hash {
return &f{Writer: nil}
}

type f struct{ io.Writer }

// Sum helps implement the hash.Hash interface.
func (f *f) Sum(b []byte) []byte { return nil }
func (_ *f) Sum(b []byte) []byte { return nil }

// Reset helps implement the hash.Hash interface.
func (f *f) Reset() {}
func (_ *f) Reset() {}

// Size helps implement the hash.Hash interface.
func (f *f) Size() int { return -1 }
func (_ *f) Size() int { return -1 }

// BlockSize helps implement the hash.Hash interface.
func (f *f) BlockSize() int { return -1 }
func (_ *f) BlockSize() int { return -1 }

// Unsecured is the default "none" algorithm.
var Unsecured = &SigningMethodNone{
Expand All @@ -40,20 +44,24 @@ type SigningMethodNone struct {
}

// Verify helps implement the SigningMethod interface.
func (m *SigningMethodNone) Verify(_ []byte, _ Signature, _ interface{}) error {
func (_ *SigningMethodNone) Verify(_ []byte, _ Signature, _ interface{}) error {
return nil
}

// Sign helps implement the SigningMethod interface.
func (m *SigningMethodNone) Sign(_ []byte, _ interface{}) (Signature, error) {
func (_ *SigningMethodNone) Sign(_ []byte, _ interface{}) (Signature, error) {
return nil, nil
}

// Alg helps implement the SigningMethod interface.
func (m *SigningMethodNone) Alg() string { return m.Name }
func (m *SigningMethodNone) Alg() string {
return m.Name
}

// Hasher helps implement the SigningMethod interface.
func (m *SigningMethodNone) Hasher() crypto.Hash { return m.Hash }
func (m *SigningMethodNone) Hasher() crypto.Hash {
return m.Hash
}

// MarshalJSON implements json.Marshaler.
// See SigningMethodECDSA.MarshalJSON() for information.
Expand Down
7 changes: 4 additions & 3 deletions crypto/rsa_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import (

// Errors specific to rsa_utils.
var (
ErrKeyMustBePEMEncoded = errors.New("Invalid Key: Key must be PEM encoded PKCS1 or PKCS8 private key")
ErrNotRSAPrivateKey = errors.New("Key is not a valid RSA private key")
ErrKeyMustBePEMEncoded = errors.New("invalid key: Key must be PEM encoded PKCS1 or PKCS8 private key")
ErrNotRSAPrivateKey = errors.New("key is not a valid RSA private key")
ErrNotRSAPublicKey = errors.New("key is not a valid RSA public key")
)

// ParseRSAPrivateKeyFromPEM parses a PEM encoded PKCS1 or PKCS8 private key.
Expand Down Expand Up @@ -62,7 +63,7 @@ func ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error) {
var pkey *rsa.PublicKey
var ok bool
if pkey, ok = parsedKey.(*rsa.PublicKey); !ok {
return nil, ErrNotRSAPrivateKey
return nil, ErrNotRSAPublicKey
}

return pkey, nil
Expand Down
Loading

0 comments on commit 2a2a700

Please sign in to comment.