<commit_before>package testauthority

import (
	"crypto/rand"
	//"crypto/rsa"
	//"crypto/x509"
	"encoding/hex"
	//"encoding/pem"
	//"fmt"
	"time"

	"github.com/gravitational/teleport/Godeps/_workspace/src/github.com/gravitational/trace"
	"github.com/gravitational/teleport/Godeps/_workspace/src/golang.org/x/crypto/ssh"
)

type nauth struct {
}

func New() *nauth {
	return &nauth{}
}

const (
	privPem  = "2d2d2d2d2d424547494e205253412050524956415445204b45592d2d2d2d2d0a4d4949456f77494241414b4341514541764a4748636d514e57556a5932654b61736d77313731715a52304235464f6e7a792f6e414742314a41452b516f6b46650a426a6f38476b6b334c32545375564e6e304e4935756f354a777037475974626653626f776f3131453932324277703073466f567a6565554d794c75643945507a0a486c382b56764538574561316c43344434617172617641665465656550724f4e49596f42747458356f59585137615a6b4d384e377953374b574e4f5a707939660a6e31766b534370444f4b323965644c48575679694463587a554c784562586850466c394c79397368754562716963324c52676778426e683366687935337538580a35716a3862702b3231474773514a615a595a74633969654e59616d6f2f4b516341306846665567546d56373465685930765a3779516b2b3264573232634671770a44762b784e6d6e4e486c66755968484e43666b38726e7a747866627148666966674341725151494441514142416f494241446871386a4e76612b3843744a36380a42627a4d553362426a497163353530795168634e4b6b514d76774b777933314151586c7267762f36562b422b4d653377336d62442f7a4770304c66422b576b700a454c566d5635634a474e464f6d6a77332b6a44697a4b487a7664647843746c4357304d44444176484d563759435176456d4c537a38345754516b7030756776590a664b6c454f533853356856466a44554f5333795253442f78462b6c72496c595561523467586e44414a5a7839747467665a6c484f70386568786b2b31626e35390a3346763166435863434b6d4b556c546b316b4661734438502b324d334d4b50343249683561703963664c5356506942532f364a524278496c5a72484d392f32610a77367645702b714d777767436d784c504d775a66656d364c4e484f2f68755472574b66346c7456756262356255584965323275644b7032574b344e5763334b610a754738456c654543675945413441394d776430514a73306a316b70754a444e496a6646783649524f763351416230515071302b3139325a4638503941456a38420a544e4451567a622f736b4d2b324e446476685a3576342b4f4a5163554e7045736b68582b35696b6b3851484741555936765438724f366f6949524d61784c754a0a4f45446332516d73314f6d6374546d6753567961786658494b322f474464764f697a74305a37593761627a6134626967456d343968794d436759454131334d490a48343239556130746e56566d474a2f344f6a6e4b62677446376930327235307644566b745072754b574e79316268526b5279614f6f4348375a7439575846326a0a4761705a5a4e314e2f636c4f3476663967696b483056436f345463324a523633356458646649536c74384e4c586d523830304d73315543414b6c77494f516a7a0a646748637645627646775365314d46674f4a56474c383247327255412f7a44564f4b646a584573436759415a78796a5a6c516c7172576457484449583042366b0a31675a3437642f7866764d6432674c44667551386c6e4f74696e42677151634a51327a303238734851313154724a51576270654c526f5467466252706f7349780a2f4833624652692b38616c4b4e4435467a364b3174706b2b6e4f6754676c4144504e4d72315555684b633978756a4f4b7654444258636d7431616f2f7065355a0a626e6d794250464939515670757367503173635661514b426745356d4a59615635565a62566b587956587951655a7432664273664c7774456d4b6d2b344f68530a6b777849346b63447957474e4f68424b4434786c305433563932385641387a4c474579443232574759355a6a39335074796c4a3472337545773863754c6d304d0a4c645370304550575a5136734d6d414f43627077426a4e6a32666f6e4c374335624d4632626e704a7a434a50573977374e5a63666976723638716e7038797a790a66453252416f4742414c57766c4856482f32394b4f566d4d3532734f6b34397463796333637a6a732f59414e76626f6b694974784f4238565059365151516e530a2f434273435a785575576567596d6b556e737448446d59314c59716a785734676f4f71697a496b736152656976506d735475513171642b6171585466673270740a7579366336583137786b503571324c7134693930696b79576d334f6332356155457734387052794b2f3672414252557a70444c420a2d2d2d2d2d454e44205253412050524956415445204b45592d2d2d2d2d0a"
	pubBytes = "7373682d727361204141414142334e7a6143317963324541414141444151414241414142415143386b5964795a41315a534e6a5a347071796244587657706c4851486b553666504c2b63415948556b4154354369515634474f6a7761535463765a4e4b3555326651306a6d366a6b6e436e735a693174394a756a436a58555433625948436e53775768584e3535517a4975353330512f4d65587a355738547859527257554c675068717174713842394e3535342b733430686967473231666d6868644474706d517a7733764a4c73705930356d6e4c312b66572b52494b6b4d34726231353073645a584b494e78664e5176455274654538575830764c327947345275714a7a597447434445476548642b484c6e653778666d715078756e376255596178416c706c686d317a324a34316871616a38704277445345563953424f5a58766836466a53396e764a4354375a3162625a775772414f2f37453261633065562b35694563304a2b547975664f334639756f642b4a2b41494374420a"
)

func (n *nauth) GenerateKeyPair(passphrase string) ([]byte, []byte, error) {
	priv, err := hex.DecodeString(privPem)
	if err != nil {
		return nil, nil, trace.Wrap(err)
	}
	pub, err := hex.DecodeString(pubBytes)
	if err != nil {
		return nil, nil, trace.Wrap(err)
	}
	return priv, pub, nil
}

func (n *nauth) GenerateHostCert(pkey, key []byte, id, hostname string, ttl time.Duration) ([]byte, error) {
	pubKey, _, _, _, err := ssh.ParseAuthorizedKey(key)
	if err != nil {
		return nil, err
	}
	validBefore := uint64(ssh.CertTimeInfinity)
	if ttl != 0 {
		b := time.Now().Add(ttl)
		validBefore = uint64(b.UnixNano())
	}
	cert := &ssh.Certificate{
		ValidPrincipals: []string{hostname},
		Key:             pubKey,
		ValidBefore:     validBefore,
		CertType:        ssh.HostCert,
	}
	signer, err := ssh.ParsePrivateKey(pkey)
	if err != nil {
		return nil, err
	}
	if err := cert.SignCert(rand.Reader, signer); err != nil {
		return nil, err<commit_msg>Storing precompiled tesing auth keys without encoding<commit_after>package testauthority

import (
	"crypto/rand"
	"time"

	"github.com/gravitational/teleport/Godeps/_workspace/src/golang.org/x/crypto/ssh"
)

type nauth struct {
}

func New() *nauth {
	return &nauth{}
}

const (
	privPem = `-----<KEY> KEY-----`

	pubBytes = `ssh-rsa A<KEY>`
)

func (n *nauth) GenerateKeyPair(passphrase string) ([]byte, []byte, error) {
	return []byte(privPem), []byte(pubBytes), nil
}

func (n *nauth) GenerateHostCert(pkey, key []byte, id, hostname string, ttl time.Duration) ([]byte, error) {
	pubKey, _, _, _, err := ssh.ParseAuthorizedKey(key)
	if err != nil {
		return nil, err
	}
	validBefore := uint64(ssh.CertTimeInfinity)
	if ttl != 0 {
		b := time.Now().Add(ttl)
		validBefore = uint64(b.UnixNano())
	}
	cert := &ssh.Certificate{
		ValidPrincipals: []string{hostname},
		Key:             pubKey,
		ValidBefore:     validBefore,
		CertType:        ssh.HostCert,
	}
	signer, err := ssh.ParsePrivateKey(pkey)
	if err != nil {
		return nil, err
	}
	if err := cert.SignCert(rand.Reader, signer); err != nil {
		return nil, err
{'fraction_non_alphanumeric': 0.06008778568185258, 'fraction_numerical': 0.5421522627516271, 'mean_word_length': 11.562737642585551, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1199703', 'n_tokens_mistral': 5114, 'n_tokens_neox': 3121, 'n_words': 213}