Skip to content

Commit

Permalink
Vendor crypto/tls in the scan package (replace cf-tls)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob H. Haven committed Feb 19, 2016
1 parent d81c136 commit af4ffaa
Show file tree
Hide file tree
Showing 161 changed files with 13,533 additions and 4,371 deletions.
2 changes: 1 addition & 1 deletion scan/broad.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package scan

import (
"crypto/tls"
"crypto/x509"
"net"
"sync"
"time"

"github.com/cloudflare/cf-tls/tls"
"github.com/cloudflare/cfssl/bundler"
)

Expand Down
3 changes: 1 addition & 2 deletions scan/connectivity.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ package scan

import (
"bufio"
"crypto/tls"
"errors"
"fmt"
"io"
"net"
"strings"

"github.com/cloudflare/cf-tls/tls"
)

// Connectivity contains scanners testing basic connectivity to the host
Expand Down
2 changes: 1 addition & 1 deletion scan/pki.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package scan

import (
"bytes"
"crypto/tls"
"crypto/x509"
"fmt"
"time"

"github.com/cloudflare/cf-tls/tls"
"github.com/cloudflare/cfssl/helpers"
"github.com/cloudflare/cfssl/revoke"
)
Expand Down
2 changes: 1 addition & 1 deletion scan/scan_common.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package scan

import (
"crypto/tls"
"crypto/x509"
"net"
"net/http"
"regexp"
"sync"
"time"

"github.com/cloudflare/cf-tls/tls"
"github.com/cloudflare/cfssl/helpers"
"github.com/cloudflare/cfssl/log"
)
Expand Down
2 changes: 1 addition & 1 deletion scan/tls_handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package scan

import (
"bytes"
"crypto/tls"
"errors"
"fmt"
"net"
"strings"

"github.com/cloudflare/cf-tls/tls"
"github.com/cloudflare/cfssl/helpers"
)

Expand Down
2 changes: 1 addition & 1 deletion scan/tls_session.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scan

import "github.com/cloudflare/cf-tls/tls"
import "crypto/tls"

// TLSSession contains tests of host TLS Session Resumption via
// Session Tickets and Session IDs
Expand Down
150 changes: 150 additions & 0 deletions scan/vendor/crypto/crypto.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Package crypto collects common cryptographic constants.
package crypto

import (
"hash"
"io"
"strconv"
)

// Hash identifies a cryptographic hash function that is implemented in another
// package.
type Hash uint

// HashFunc simply returns the value of h so that Hash implements SignerOpts.
func (h Hash) HashFunc() Hash {
return h
}

const (
MD4 Hash = 1 + iota // import golang.org/x/crypto/md4
MD5 // import crypto/md5
SHA1 // import crypto/sha1
SHA224 // import crypto/sha256
SHA256 // import crypto/sha256
SHA384 // import crypto/sha512
SHA512 // import crypto/sha512
MD5SHA1 // no implementation; MD5+SHA1 used for TLS RSA
RIPEMD160 // import golang.org/x/crypto/ripemd160
SHA3_224 // import golang.org/x/crypto/sha3
SHA3_256 // import golang.org/x/crypto/sha3
SHA3_384 // import golang.org/x/crypto/sha3
SHA3_512 // import golang.org/x/crypto/sha3
SHA512_224 // import crypto/sha512
SHA512_256 // import crypto/sha512
maxHash
)

var digestSizes = []uint8{
MD4: 16,
MD5: 16,
SHA1: 20,
SHA224: 28,
SHA256: 32,
SHA384: 48,
SHA512: 64,
SHA512_224: 28,
SHA512_256: 32,
SHA3_224: 28,
SHA3_256: 32,
SHA3_384: 48,
SHA3_512: 64,
MD5SHA1: 36,
RIPEMD160: 20,
}

// Size returns the length, in bytes, of a digest resulting from the given hash
// function. It doesn't require that the hash function in question be linked
// into the program.
func (h Hash) Size() int {
if h > 0 && h < maxHash {
return int(digestSizes[h])
}
panic("crypto: Size of unknown hash function")
}

var hashes = make([]func() hash.Hash, maxHash)

// New returns a new hash.Hash calculating the given hash function. New panics
// if the hash function is not linked into the binary.
func (h Hash) New() hash.Hash {
if h > 0 && h < maxHash {
f := hashes[h]
if f != nil {
return f()
}
}
panic("crypto: requested hash function #" + strconv.Itoa(int(h)) + " is unavailable")
}

// Available reports whether the given hash function is linked into the binary.
func (h Hash) Available() bool {
return h < maxHash && hashes[h] != nil
}

// RegisterHash registers a function that returns a new instance of the given
// hash function. This is intended to be called from the init function in
// packages that implement hash functions.
func RegisterHash(h Hash, f func() hash.Hash) {
if h >= maxHash {
panic("crypto: RegisterHash of unknown hash function")
}
hashes[h] = f
}

// PublicKey represents a public key using an unspecified algorithm.
type PublicKey interface{}

// PrivateKey represents a private key using an unspecified algorithm.
type PrivateKey interface{}

// Signer is an interface for an opaque private key that can be used for
// signing operations. For example, an RSA key kept in a hardware module.
type Signer interface {
// Public returns the public key corresponding to the opaque,
// private key.
Public() PublicKey

// Sign signs digest with the private key, possibly using entropy from
// rand. For an RSA key, the resulting signature should be either a
// PKCS#1 v1.5 or PSS signature (as indicated by opts). For an (EC)DSA
// key, it should be a DER-serialised, ASN.1 signature structure.
//
// Hash implements the SignerOpts interface and, in most cases, one can
// simply pass in the hash function used as opts. Sign may also attempt
// to type assert opts to other types in order to obtain algorithm
// specific values. See the documentation in each package for details.
//
// Note that when a signature of a hash of a larger message is needed,
// the caller is responsible for hashing the larger message and passing
// the hash (as digest) and the hash function (as opts) to Sign.
Sign(rand io.Reader, digest []byte, opts SignerOpts) (signature []byte, err error)
}

// SignerOpts contains options for signing with a Signer.
type SignerOpts interface {
// HashFunc returns an identifier for the hash function used to produce
// the message passed to Signer.Sign, or else zero to indicate that no
// hashing was done.
HashFunc() Hash
}

// Decrypter is an interface for an opaque private key that can be used for
// asymmetric decryption operations. An example would be an RSA key
// kept in a hardware module.
type Decrypter interface {
// Public returns the public key corresponding to the opaque,
// private key.
Public() PublicKey

// Decrypt decrypts msg. The opts argument should be appropriate for
// the primitive used. See the documentation in each implementation for
// details.
Decrypt(rand io.Reader, msg []byte, opts DecrypterOpts) (plaintext []byte, err error)
}

type DecrypterOpts interface{}
25 changes: 25 additions & 0 deletions scan/vendor/crypto/md5/example_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package md5_test

import (
"crypto/md5"
"fmt"
"io"
)

func ExampleNew() {
h := md5.New()
io.WriteString(h, "The fog is getting thicker!")
io.WriteString(h, "And Leon's getting laaarger!")
fmt.Printf("%x", h.Sum(nil))
// Output: e2c569be17396eca2a2e3c11578123ed
}

func ExampleSum() {
data := []byte("These pretzels are making me thirsty.")
fmt.Printf("%x", md5.Sum(data))
// Output: b0804ec967f48520697662a204f5fe72
}
Loading

0 comments on commit af4ffaa

Please sign in to comment.