id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
161,300 | src-d/go-git | plumbing/format/config/common.go | Section | func (c *Config) Section(name string) *Section {
for i := len(c.Sections) - 1; i >= 0; i-- {
s := c.Sections[i]
if s.IsName(name) {
return s
}
}
s := &Section{Name: name}
c.Sections = append(c.Sections, s)
return s
} | go | func (c *Config) Section(name string) *Section {
for i := len(c.Sections) - 1; i >= 0; i-- {
s := c.Sections[i]
if s.IsName(name) {
return s
}
}
s := &Section{Name: name}
c.Sections = append(c.Sections, s)
return s
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"Section",
"(",
"name",
"string",
")",
"*",
"Section",
"{",
"for",
"i",
":=",
"len",
"(",
"c",
".",
"Sections",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"s",
":=",
"c",
".",
"Sections",
... | // Section returns a existing section with the given name or creates a new one. | [
"Section",
"returns",
"a",
"existing",
"section",
"with",
"the",
"given",
"name",
"or",
"creates",
"a",
"new",
"one",
"."
] | e17ee112ca6cc7db0a732c0676b61511e84ec899 | https://github.com/src-d/go-git/blob/e17ee112ca6cc7db0a732c0676b61511e84ec899/plumbing/format/config/common.go#L34-L45 |
161,301 | src-d/go-git | plumbing/format/config/common.go | AddOption | func (c *Config) AddOption(section string, subsection string, key string, value string) *Config {
if subsection == "" {
c.Section(section).AddOption(key, value)
} else {
c.Section(section).Subsection(subsection).AddOption(key, value)
}
return c
} | go | func (c *Config) AddOption(section string, subsection string, key string, value string) *Config {
if subsection == "" {
c.Section(section).AddOption(key, value)
} else {
c.Section(section).Subsection(subsection).AddOption(key, value)
}
return c
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"AddOption",
"(",
"section",
"string",
",",
"subsection",
"string",
",",
"key",
"string",
",",
"value",
"string",
")",
"*",
"Config",
"{",
"if",
"subsection",
"==",
"\"",
"\"",
"{",
"c",
".",
"Section",
"(",
"sec... | // AddOption adds an option to a given section and subsection. Use the
// NoSubsection constant for the subsection argument if no subsection is wanted. | [
"AddOption",
"adds",
"an",
"option",
"to",
"a",
"given",
"section",
"and",
"subsection",
".",
"Use",
"the",
"NoSubsection",
"constant",
"for",
"the",
"subsection",
"argument",
"if",
"no",
"subsection",
"is",
"wanted",
"."
] | e17ee112ca6cc7db0a732c0676b61511e84ec899 | https://github.com/src-d/go-git/blob/e17ee112ca6cc7db0a732c0676b61511e84ec899/plumbing/format/config/common.go#L49-L57 |
161,302 | src-d/go-git | plumbing/format/config/common.go | RemoveSection | func (c *Config) RemoveSection(name string) *Config {
result := Sections{}
for _, s := range c.Sections {
if !s.IsName(name) {
result = append(result, s)
}
}
c.Sections = result
return c
} | go | func (c *Config) RemoveSection(name string) *Config {
result := Sections{}
for _, s := range c.Sections {
if !s.IsName(name) {
result = append(result, s)
}
}
c.Sections = result
return c
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"RemoveSection",
"(",
"name",
"string",
")",
"*",
"Config",
"{",
"result",
":=",
"Sections",
"{",
"}",
"\n",
"for",
"_",
",",
"s",
":=",
"range",
"c",
".",
"Sections",
"{",
"if",
"!",
"s",
".",
"IsName",
"(",... | // RemoveSection removes a section from a config file. | [
"RemoveSection",
"removes",
"a",
"section",
"from",
"a",
"config",
"file",
"."
] | e17ee112ca6cc7db0a732c0676b61511e84ec899 | https://github.com/src-d/go-git/blob/e17ee112ca6cc7db0a732c0676b61511e84ec899/plumbing/format/config/common.go#L72-L82 |
161,303 | src-d/go-git | plumbing/format/config/common.go | RemoveSubsection | func (c *Config) RemoveSubsection(section string, subsection string) *Config {
for _, s := range c.Sections {
if s.IsName(section) {
result := Subsections{}
for _, ss := range s.Subsections {
if !ss.IsName(subsection) {
result = append(result, ss)
}
}
s.Subsections = result
}
}
return c... | go | func (c *Config) RemoveSubsection(section string, subsection string) *Config {
for _, s := range c.Sections {
if s.IsName(section) {
result := Subsections{}
for _, ss := range s.Subsections {
if !ss.IsName(subsection) {
result = append(result, ss)
}
}
s.Subsections = result
}
}
return c... | [
"func",
"(",
"c",
"*",
"Config",
")",
"RemoveSubsection",
"(",
"section",
"string",
",",
"subsection",
"string",
")",
"*",
"Config",
"{",
"for",
"_",
",",
"s",
":=",
"range",
"c",
".",
"Sections",
"{",
"if",
"s",
".",
"IsName",
"(",
"section",
")",
... | // RemoveSubsection remove s a subsection from a config file. | [
"RemoveSubsection",
"remove",
"s",
"a",
"subsection",
"from",
"a",
"config",
"file",
"."
] | e17ee112ca6cc7db0a732c0676b61511e84ec899 | https://github.com/src-d/go-git/blob/e17ee112ca6cc7db0a732c0676b61511e84ec899/plumbing/format/config/common.go#L85-L99 |
161,304 | src-d/go-git | _examples/tag/main.go | main | func main() {
CheckArgs("<path>")
path := os.Args[1]
// We instanciate a new repository targeting the given path (the .git folder)
r, err := git.PlainOpen(path)
CheckIfError(err)
// List all tag references, both lightweight tags and annotated tags
Info("git show-ref --tag")
tagrefs, err := r.Tags()
CheckIfE... | go | func main() {
CheckArgs("<path>")
path := os.Args[1]
// We instanciate a new repository targeting the given path (the .git folder)
r, err := git.PlainOpen(path)
CheckIfError(err)
// List all tag references, both lightweight tags and annotated tags
Info("git show-ref --tag")
tagrefs, err := r.Tags()
CheckIfE... | [
"func",
"main",
"(",
")",
"{",
"CheckArgs",
"(",
"\"",
"\"",
")",
"\n",
"path",
":=",
"os",
".",
"Args",
"[",
"1",
"]",
"\n\n",
"// We instanciate a new repository targeting the given path (the .git folder)",
"r",
",",
"err",
":=",
"git",
".",
"PlainOpen",
"("... | // Basic example of how to list tags. | [
"Basic",
"example",
"of",
"how",
"to",
"list",
"tags",
"."
] | e17ee112ca6cc7db0a732c0676b61511e84ec899 | https://github.com/src-d/go-git/blob/e17ee112ca6cc7db0a732c0676b61511e84ec899/_examples/tag/main.go#L14-L43 |
161,305 | src-d/go-git | references.go | sortCommits | func sortCommits(l []*object.Commit) {
s := &commitSorterer{l}
sort.Sort(s)
} | go | func sortCommits(l []*object.Commit) {
s := &commitSorterer{l}
sort.Sort(s)
} | [
"func",
"sortCommits",
"(",
"l",
"[",
"]",
"*",
"object",
".",
"Commit",
")",
"{",
"s",
":=",
"&",
"commitSorterer",
"{",
"l",
"}",
"\n",
"sort",
".",
"Sort",
"(",
"s",
")",
"\n",
"}"
] | // SortCommits sorts a commit list by commit date, from older to newer. | [
"SortCommits",
"sorts",
"a",
"commit",
"list",
"by",
"commit",
"date",
"from",
"older",
"to",
"newer",
"."
] | e17ee112ca6cc7db0a732c0676b61511e84ec899 | https://github.com/src-d/go-git/blob/e17ee112ca6cc7db0a732c0676b61511e84ec899/references.go#L60-L63 |
161,306 | src-d/go-git | references.go | walkGraph | func walkGraph(result *[]*object.Commit, seen *map[plumbing.Hash]struct{}, current *object.Commit, path string) error {
// check and update seen
if _, ok := (*seen)[current.Hash]; ok {
return nil
}
(*seen)[current.Hash] = struct{}{}
// if the path is not in the current commit, stop searching.
if _, err := curr... | go | func walkGraph(result *[]*object.Commit, seen *map[plumbing.Hash]struct{}, current *object.Commit, path string) error {
// check and update seen
if _, ok := (*seen)[current.Hash]; ok {
return nil
}
(*seen)[current.Hash] = struct{}{}
// if the path is not in the current commit, stop searching.
if _, err := curr... | [
"func",
"walkGraph",
"(",
"result",
"*",
"[",
"]",
"*",
"object",
".",
"Commit",
",",
"seen",
"*",
"map",
"[",
"plumbing",
".",
"Hash",
"]",
"struct",
"{",
"}",
",",
"current",
"*",
"object",
".",
"Commit",
",",
"path",
"string",
")",
"error",
"{",... | // Recursive traversal of the commit graph, generating a linear history of the
// path. | [
"Recursive",
"traversal",
"of",
"the",
"commit",
"graph",
"generating",
"a",
"linear",
"history",
"of",
"the",
"path",
"."
] | e17ee112ca6cc7db0a732c0676b61511e84ec899 | https://github.com/src-d/go-git/blob/e17ee112ca6cc7db0a732c0676b61511e84ec899/references.go#L67-L115 |
161,307 | src-d/go-git | references.go | differentContents | func differentContents(path string, c *object.Commit, cs []*object.Commit) ([]*object.Commit, error) {
result := make([]*object.Commit, 0, len(cs))
h, found := blobHash(path, c)
if !found {
return nil, object.ErrFileNotFound
}
for _, cx := range cs {
if hx, found := blobHash(path, cx); found && h != hx {
re... | go | func differentContents(path string, c *object.Commit, cs []*object.Commit) ([]*object.Commit, error) {
result := make([]*object.Commit, 0, len(cs))
h, found := blobHash(path, c)
if !found {
return nil, object.ErrFileNotFound
}
for _, cx := range cs {
if hx, found := blobHash(path, cx); found && h != hx {
re... | [
"func",
"differentContents",
"(",
"path",
"string",
",",
"c",
"*",
"object",
".",
"Commit",
",",
"cs",
"[",
"]",
"*",
"object",
".",
"Commit",
")",
"(",
"[",
"]",
"*",
"object",
".",
"Commit",
",",
"error",
")",
"{",
"result",
":=",
"make",
"(",
... | // Returns an slice of the commits in "cs" that has the file "path", but with different
// contents than what can be found in "c". | [
"Returns",
"an",
"slice",
"of",
"the",
"commits",
"in",
"cs",
"that",
"has",
"the",
"file",
"path",
"but",
"with",
"different",
"contents",
"than",
"what",
"can",
"be",
"found",
"in",
"c",
"."
] | e17ee112ca6cc7db0a732c0676b61511e84ec899 | https://github.com/src-d/go-git/blob/e17ee112ca6cc7db0a732c0676b61511e84ec899/references.go#L138-L150 |
161,308 | src-d/go-git | references.go | blobHash | func blobHash(path string, commit *object.Commit) (hash plumbing.Hash, found bool) {
file, err := commit.File(path)
if err != nil {
var empty plumbing.Hash
return empty, found
}
return file.Hash, true
} | go | func blobHash(path string, commit *object.Commit) (hash plumbing.Hash, found bool) {
file, err := commit.File(path)
if err != nil {
var empty plumbing.Hash
return empty, found
}
return file.Hash, true
} | [
"func",
"blobHash",
"(",
"path",
"string",
",",
"commit",
"*",
"object",
".",
"Commit",
")",
"(",
"hash",
"plumbing",
".",
"Hash",
",",
"found",
"bool",
")",
"{",
"file",
",",
"err",
":=",
"commit",
".",
"File",
"(",
"path",
")",
"\n",
"if",
"err",... | // blobHash returns the hash of a path in a commit | [
"blobHash",
"returns",
"the",
"hash",
"of",
"a",
"path",
"in",
"a",
"commit"
] | e17ee112ca6cc7db0a732c0676b61511e84ec899 | https://github.com/src-d/go-git/blob/e17ee112ca6cc7db0a732c0676b61511e84ec899/references.go#L153-L160 |
161,309 | src-d/go-git | references.go | removeComp | func removeComp(path string, cs []*object.Commit, comp contentsComparatorFn) ([]*object.Commit, error) {
result := make([]*object.Commit, 0, len(cs))
if len(cs) == 0 {
return result, nil
}
result = append(result, cs[0])
for i := 1; i < len(cs); i++ {
equals, err := comp(path, cs[i], cs[i-1])
if err != nil {
... | go | func removeComp(path string, cs []*object.Commit, comp contentsComparatorFn) ([]*object.Commit, error) {
result := make([]*object.Commit, 0, len(cs))
if len(cs) == 0 {
return result, nil
}
result = append(result, cs[0])
for i := 1; i < len(cs); i++ {
equals, err := comp(path, cs[i], cs[i-1])
if err != nil {
... | [
"func",
"removeComp",
"(",
"path",
"string",
",",
"cs",
"[",
"]",
"*",
"object",
".",
"Commit",
",",
"comp",
"contentsComparatorFn",
")",
"(",
"[",
"]",
"*",
"object",
".",
"Commit",
",",
"error",
")",
"{",
"result",
":=",
"make",
"(",
"[",
"]",
"*... | // Returns a new slice of commits, with duplicates removed. Expects a
// sorted commit list. Duplication is defined according to "comp". It
// will always keep the first commit of a series of duplicated commits. | [
"Returns",
"a",
"new",
"slice",
"of",
"commits",
"with",
"duplicates",
"removed",
".",
"Expects",
"a",
"sorted",
"commit",
"list",
".",
"Duplication",
"is",
"defined",
"according",
"to",
"comp",
".",
"It",
"will",
"always",
"keep",
"the",
"first",
"commit",
... | e17ee112ca6cc7db0a732c0676b61511e84ec899 | https://github.com/src-d/go-git/blob/e17ee112ca6cc7db0a732c0676b61511e84ec899/references.go#L167-L183 |
161,310 | src-d/go-git | references.go | equivalent | func equivalent(path string, a, b *object.Commit) (bool, error) {
numParentsA := a.NumParents()
numParentsB := b.NumParents()
// the first commit is not equivalent to anyone
// and "I think" merges can not be equivalent to anything
if numParentsA != 1 || numParentsB != 1 {
return false, nil
}
diffsA, err := ... | go | func equivalent(path string, a, b *object.Commit) (bool, error) {
numParentsA := a.NumParents()
numParentsB := b.NumParents()
// the first commit is not equivalent to anyone
// and "I think" merges can not be equivalent to anything
if numParentsA != 1 || numParentsB != 1 {
return false, nil
}
diffsA, err := ... | [
"func",
"equivalent",
"(",
"path",
"string",
",",
"a",
",",
"b",
"*",
"object",
".",
"Commit",
")",
"(",
"bool",
",",
"error",
")",
"{",
"numParentsA",
":=",
"a",
".",
"NumParents",
"(",
")",
"\n",
"numParentsB",
":=",
"b",
".",
"NumParents",
"(",
... | // Equivalent commits are commits whose patch is the same. | [
"Equivalent",
"commits",
"are",
"commits",
"whose",
"patch",
"is",
"the",
"same",
"."
] | e17ee112ca6cc7db0a732c0676b61511e84ec899 | https://github.com/src-d/go-git/blob/e17ee112ca6cc7db0a732c0676b61511e84ec899/references.go#L186-L206 |
161,311 | src-d/go-git | plumbing/format/gitignore/dir.go | readIgnoreFile | func readIgnoreFile(fs billy.Filesystem, path []string, ignoreFile string) (ps []Pattern, err error) {
f, err := fs.Open(fs.Join(append(path, ignoreFile)...))
if err == nil {
defer f.Close()
if data, err := ioutil.ReadAll(f); err == nil {
for _, s := range strings.Split(string(data), eol) {
if !strings.Ha... | go | func readIgnoreFile(fs billy.Filesystem, path []string, ignoreFile string) (ps []Pattern, err error) {
f, err := fs.Open(fs.Join(append(path, ignoreFile)...))
if err == nil {
defer f.Close()
if data, err := ioutil.ReadAll(f); err == nil {
for _, s := range strings.Split(string(data), eol) {
if !strings.Ha... | [
"func",
"readIgnoreFile",
"(",
"fs",
"billy",
".",
"Filesystem",
",",
"path",
"[",
"]",
"string",
",",
"ignoreFile",
"string",
")",
"(",
"ps",
"[",
"]",
"Pattern",
",",
"err",
"error",
")",
"{",
"f",
",",
"err",
":=",
"fs",
".",
"Open",
"(",
"fs",
... | // readIgnoreFile reads a specific git ignore file. | [
"readIgnoreFile",
"reads",
"a",
"specific",
"git",
"ignore",
"file",
"."
] | e17ee112ca6cc7db0a732c0676b61511e84ec899 | https://github.com/src-d/go-git/blob/e17ee112ca6cc7db0a732c0676b61511e84ec899/plumbing/format/gitignore/dir.go#L27-L44 |
161,312 | src-d/go-git | plumbing/object/change.go | Action | func (c *Change) Action() (merkletrie.Action, error) {
if c.From == empty && c.To == empty {
return merkletrie.Action(0),
fmt.Errorf("malformed change: empty from and to")
}
if c.From == empty {
return merkletrie.Insert, nil
}
if c.To == empty {
return merkletrie.Delete, nil
}
return merkletrie.Modify,... | go | func (c *Change) Action() (merkletrie.Action, error) {
if c.From == empty && c.To == empty {
return merkletrie.Action(0),
fmt.Errorf("malformed change: empty from and to")
}
if c.From == empty {
return merkletrie.Insert, nil
}
if c.To == empty {
return merkletrie.Delete, nil
}
return merkletrie.Modify,... | [
"func",
"(",
"c",
"*",
"Change",
")",
"Action",
"(",
")",
"(",
"merkletrie",
".",
"Action",
",",
"error",
")",
"{",
"if",
"c",
".",
"From",
"==",
"empty",
"&&",
"c",
".",
"To",
"==",
"empty",
"{",
"return",
"merkletrie",
".",
"Action",
"(",
"0",
... | // Action returns the kind of action represented by the change, an
// insertion, a deletion or a modification. | [
"Action",
"returns",
"the",
"kind",
"of",
"action",
"represented",
"by",
"the",
"change",
"an",
"insertion",
"a",
"deletion",
"or",
"a",
"modification",
"."
] | e17ee112ca6cc7db0a732c0676b61511e84ec899 | https://github.com/src-d/go-git/blob/e17ee112ca6cc7db0a732c0676b61511e84ec899/plumbing/object/change.go#L25-L38 |
161,313 | src-d/go-git | plumbing/object/change.go | Files | func (c *Change) Files() (from, to *File, err error) {
action, err := c.Action()
if err != nil {
return
}
if action == merkletrie.Insert || action == merkletrie.Modify {
to, err = c.To.Tree.TreeEntryFile(&c.To.TreeEntry)
if !c.To.TreeEntry.Mode.IsFile() {
return nil, nil, nil
}
if err != nil {
ret... | go | func (c *Change) Files() (from, to *File, err error) {
action, err := c.Action()
if err != nil {
return
}
if action == merkletrie.Insert || action == merkletrie.Modify {
to, err = c.To.Tree.TreeEntryFile(&c.To.TreeEntry)
if !c.To.TreeEntry.Mode.IsFile() {
return nil, nil, nil
}
if err != nil {
ret... | [
"func",
"(",
"c",
"*",
"Change",
")",
"Files",
"(",
")",
"(",
"from",
",",
"to",
"*",
"File",
",",
"err",
"error",
")",
"{",
"action",
",",
"err",
":=",
"c",
".",
"Action",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
... | // Files return the files before and after a change.
// For insertions from will be nil. For deletions to will be nil. | [
"Files",
"return",
"the",
"files",
"before",
"and",
"after",
"a",
"change",
".",
"For",
"insertions",
"from",
"will",
"be",
"nil",
".",
"For",
"deletions",
"to",
"will",
"be",
"nil",
"."
] | e17ee112ca6cc7db0a732c0676b61511e84ec899 | https://github.com/src-d/go-git/blob/e17ee112ca6cc7db0a732c0676b61511e84ec899/plumbing/object/change.go#L42-L71 |
161,314 | src-d/go-git | plumbing/object/change.go | PatchContext | func (c Changes) PatchContext(ctx context.Context) (*Patch, error) {
return getPatchContext(ctx, "", c...)
} | go | func (c Changes) PatchContext(ctx context.Context) (*Patch, error) {
return getPatchContext(ctx, "", c...)
} | [
"func",
"(",
"c",
"Changes",
")",
"PatchContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"Patch",
",",
"error",
")",
"{",
"return",
"getPatchContext",
"(",
"ctx",
",",
"\"",
"\"",
",",
"c",
"...",
")",
"\n",
"}"
] | // Patch returns a Patch with all the changes in chunks. This
// representation can be used to create several diff outputs.
// If context expires, an non-nil error will be returned
// Provided context must be non-nil | [
"Patch",
"returns",
"a",
"Patch",
"with",
"all",
"the",
"changes",
"in",
"chunks",
".",
"This",
"representation",
"can",
"be",
"used",
"to",
"create",
"several",
"diff",
"outputs",
".",
"If",
"context",
"expires",
"an",
"non",
"-",
"nil",
"error",
"will",
... | e17ee112ca6cc7db0a732c0676b61511e84ec899 | https://github.com/src-d/go-git/blob/e17ee112ca6cc7db0a732c0676b61511e84ec899/plumbing/object/change.go#L155-L157 |
161,315 | cloudflare/cfssl | ocsp/universal/universal.go | NewSignerFromConfig | func NewSignerFromConfig(cfg ocspConfig.Config) (ocsp.Signer, error) {
return ocsp.NewSignerFromFile(cfg.CACertFile, cfg.ResponderCertFile,
cfg.KeyFile, cfg.Interval)
} | go | func NewSignerFromConfig(cfg ocspConfig.Config) (ocsp.Signer, error) {
return ocsp.NewSignerFromFile(cfg.CACertFile, cfg.ResponderCertFile,
cfg.KeyFile, cfg.Interval)
} | [
"func",
"NewSignerFromConfig",
"(",
"cfg",
"ocspConfig",
".",
"Config",
")",
"(",
"ocsp",
".",
"Signer",
",",
"error",
")",
"{",
"return",
"ocsp",
".",
"NewSignerFromFile",
"(",
"cfg",
".",
"CACertFile",
",",
"cfg",
".",
"ResponderCertFile",
",",
"cfg",
".... | // NewSignerFromConfig generates a new OCSP signer from a config object. | [
"NewSignerFromConfig",
"generates",
"a",
"new",
"OCSP",
"signer",
"from",
"a",
"config",
"object",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/ocsp/universal/universal.go#L9-L12 |
161,316 | cloudflare/cfssl | cmd/cfssl-certinfo/cfssl-certinfo.go | main | func main() {
var certinfoFlagSet = flag.NewFlagSet("certinfo", flag.ExitOnError)
var c cli.Config
registerFlags(&c, certinfoFlagSet)
var usageText = `cfssl-certinfo -- output certinfo about the given cert
Usage of certinfo:
- Data from local certificate files
certinfo -cert file
- Data from certifi... | go | func main() {
var certinfoFlagSet = flag.NewFlagSet("certinfo", flag.ExitOnError)
var c cli.Config
registerFlags(&c, certinfoFlagSet)
var usageText = `cfssl-certinfo -- output certinfo about the given cert
Usage of certinfo:
- Data from local certificate files
certinfo -cert file
- Data from certifi... | [
"func",
"main",
"(",
")",
"{",
"var",
"certinfoFlagSet",
"=",
"flag",
".",
"NewFlagSet",
"(",
"\"",
"\"",
",",
"flag",
".",
"ExitOnError",
")",
"\n",
"var",
"c",
"cli",
".",
"Config",
"\n",
"registerFlags",
"(",
"&",
"c",
",",
"certinfoFlagSet",
")",
... | // main defines the newkey usage and registers all defined commands and flags. | [
"main",
"defines",
"the",
"newkey",
"usage",
"and",
"registers",
"all",
"defined",
"commands",
"and",
"flags",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/cmd/cfssl-certinfo/cfssl-certinfo.go#L18-L57 |
161,317 | cloudflare/cfssl | cmd/cfssl-certinfo/cfssl-certinfo.go | printDefaultValue | func printDefaultValue(f *flag.Flag) {
format := " -%s=%s: %s\n"
if f.DefValue == "" {
format = " -%s=%q: %s\n"
}
fmt.Fprintf(os.Stderr, format, f.Name, f.DefValue, f.Usage)
} | go | func printDefaultValue(f *flag.Flag) {
format := " -%s=%s: %s\n"
if f.DefValue == "" {
format = " -%s=%q: %s\n"
}
fmt.Fprintf(os.Stderr, format, f.Name, f.DefValue, f.Usage)
} | [
"func",
"printDefaultValue",
"(",
"f",
"*",
"flag",
".",
"Flag",
")",
"{",
"format",
":=",
"\"",
"\\n",
"\"",
"\n",
"if",
"f",
".",
"DefValue",
"==",
"\"",
"\"",
"{",
"format",
"=",
"\"",
"\\n",
"\"",
"\n",
"}",
"\n",
"fmt",
".",
"Fprintf",
"(",
... | // printDefaultValue is a helper function to print out a user friendly
// usage message of a flag. It's useful since we want to write customized
// usage message on selected subsets of the global flag set. It is
// borrowed from standard library source code. Since flag value type is
// not exported, default string flag... | [
"printDefaultValue",
"is",
"a",
"helper",
"function",
"to",
"print",
"out",
"a",
"user",
"friendly",
"usage",
"message",
"of",
"a",
"flag",
".",
"It",
"s",
"useful",
"since",
"we",
"want",
"to",
"write",
"customized",
"usage",
"message",
"on",
"selected",
... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/cmd/cfssl-certinfo/cfssl-certinfo.go#L65-L71 |
161,318 | cloudflare/cfssl | csr/csr.go | Generate | func (kr *BasicKeyRequest) Generate() (crypto.PrivateKey, error) {
log.Debugf("generate key from request: algo=%s, size=%d", kr.Algo(), kr.Size())
switch kr.Algo() {
case "rsa":
if kr.Size() < 2048 {
return nil, errors.New("RSA key is too weak")
}
if kr.Size() > 8192 {
return nil, errors.New("RSA key siz... | go | func (kr *BasicKeyRequest) Generate() (crypto.PrivateKey, error) {
log.Debugf("generate key from request: algo=%s, size=%d", kr.Algo(), kr.Size())
switch kr.Algo() {
case "rsa":
if kr.Size() < 2048 {
return nil, errors.New("RSA key is too weak")
}
if kr.Size() > 8192 {
return nil, errors.New("RSA key siz... | [
"func",
"(",
"kr",
"*",
"BasicKeyRequest",
")",
"Generate",
"(",
")",
"(",
"crypto",
".",
"PrivateKey",
",",
"error",
")",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"kr",
".",
"Algo",
"(",
")",
",",
"kr",
".",
"Size",
"(",
")",
")",
"\n"... | // Generate generates a key as specified in the request. Currently,
// only ECDSA and RSA are supported. | [
"Generate",
"generates",
"a",
"key",
"as",
"specified",
"in",
"the",
"request",
".",
"Currently",
"only",
"ECDSA",
"and",
"RSA",
"are",
"supported",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/csr/csr.go#L72-L99 |
161,319 | cloudflare/cfssl | csr/csr.go | SigAlgo | func (kr *BasicKeyRequest) SigAlgo() x509.SignatureAlgorithm {
switch kr.Algo() {
case "rsa":
switch {
case kr.Size() >= 4096:
return x509.SHA512WithRSA
case kr.Size() >= 3072:
return x509.SHA384WithRSA
case kr.Size() >= 2048:
return x509.SHA256WithRSA
default:
return x509.SHA1WithRSA
}
case ... | go | func (kr *BasicKeyRequest) SigAlgo() x509.SignatureAlgorithm {
switch kr.Algo() {
case "rsa":
switch {
case kr.Size() >= 4096:
return x509.SHA512WithRSA
case kr.Size() >= 3072:
return x509.SHA384WithRSA
case kr.Size() >= 2048:
return x509.SHA256WithRSA
default:
return x509.SHA1WithRSA
}
case ... | [
"func",
"(",
"kr",
"*",
"BasicKeyRequest",
")",
"SigAlgo",
"(",
")",
"x509",
".",
"SignatureAlgorithm",
"{",
"switch",
"kr",
".",
"Algo",
"(",
")",
"{",
"case",
"\"",
"\"",
":",
"switch",
"{",
"case",
"kr",
".",
"Size",
"(",
")",
">=",
"4096",
":",... | // SigAlgo returns an appropriate X.509 signature algorithm given the
// key request's type and size. | [
"SigAlgo",
"returns",
"an",
"appropriate",
"X",
".",
"509",
"signature",
"algorithm",
"given",
"the",
"key",
"request",
"s",
"type",
"and",
"size",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/csr/csr.go#L103-L130 |
161,320 | cloudflare/cfssl | csr/csr.go | appendIf | func appendIf(s string, a *[]string) {
if s != "" {
*a = append(*a, s)
}
} | go | func appendIf(s string, a *[]string) {
if s != "" {
*a = append(*a, s)
}
} | [
"func",
"appendIf",
"(",
"s",
"string",
",",
"a",
"*",
"[",
"]",
"string",
")",
"{",
"if",
"s",
"!=",
"\"",
"\"",
"{",
"*",
"a",
"=",
"append",
"(",
"*",
"a",
",",
"s",
")",
"\n",
"}",
"\n",
"}"
] | // appendIf appends to a if s is not an empty string. | [
"appendIf",
"appends",
"to",
"a",
"if",
"s",
"is",
"not",
"an",
"empty",
"string",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/csr/csr.go#L160-L164 |
161,321 | cloudflare/cfssl | csr/csr.go | Name | func (cr *CertificateRequest) Name() pkix.Name {
var name pkix.Name
name.CommonName = cr.CN
for _, n := range cr.Names {
appendIf(n.C, &name.Country)
appendIf(n.ST, &name.Province)
appendIf(n.L, &name.Locality)
appendIf(n.O, &name.Organization)
appendIf(n.OU, &name.OrganizationalUnit)
}
name.SerialNumbe... | go | func (cr *CertificateRequest) Name() pkix.Name {
var name pkix.Name
name.CommonName = cr.CN
for _, n := range cr.Names {
appendIf(n.C, &name.Country)
appendIf(n.ST, &name.Province)
appendIf(n.L, &name.Locality)
appendIf(n.O, &name.Organization)
appendIf(n.OU, &name.OrganizationalUnit)
}
name.SerialNumbe... | [
"func",
"(",
"cr",
"*",
"CertificateRequest",
")",
"Name",
"(",
")",
"pkix",
".",
"Name",
"{",
"var",
"name",
"pkix",
".",
"Name",
"\n",
"name",
".",
"CommonName",
"=",
"cr",
".",
"CN",
"\n\n",
"for",
"_",
",",
"n",
":=",
"range",
"cr",
".",
"Nam... | // Name returns the PKIX name for the request. | [
"Name",
"returns",
"the",
"PKIX",
"name",
"for",
"the",
"request",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/csr/csr.go#L167-L180 |
161,322 | cloudflare/cfssl | csr/csr.go | ExtractCertificateRequest | func ExtractCertificateRequest(cert *x509.Certificate) *CertificateRequest {
req := New()
req.CN = cert.Subject.CommonName
req.Names = getNames(cert.Subject)
req.Hosts = getHosts(cert)
req.SerialNumber = cert.Subject.SerialNumber
if cert.IsCA {
req.CA = new(CAConfig)
// CA expiry length is calculated based o... | go | func ExtractCertificateRequest(cert *x509.Certificate) *CertificateRequest {
req := New()
req.CN = cert.Subject.CommonName
req.Names = getNames(cert.Subject)
req.Hosts = getHosts(cert)
req.SerialNumber = cert.Subject.SerialNumber
if cert.IsCA {
req.CA = new(CAConfig)
// CA expiry length is calculated based o... | [
"func",
"ExtractCertificateRequest",
"(",
"cert",
"*",
"x509",
".",
"Certificate",
")",
"*",
"CertificateRequest",
"{",
"req",
":=",
"New",
"(",
")",
"\n",
"req",
".",
"CN",
"=",
"cert",
".",
"Subject",
".",
"CommonName",
"\n",
"req",
".",
"Names",
"=",
... | // ExtractCertificateRequest extracts a CertificateRequest from
// x509.Certificate. It is aimed to used for generating a new certificate
// from an existing certificate. For a root certificate, the CA expiry
// length is calculated as the duration between cert.NotAfter and cert.NotBefore. | [
"ExtractCertificateRequest",
"extracts",
"a",
"CertificateRequest",
"from",
"x509",
".",
"Certificate",
".",
"It",
"is",
"aimed",
"to",
"used",
"for",
"generating",
"a",
"new",
"certificate",
"from",
"an",
"existing",
"certificate",
".",
"For",
"a",
"root",
"cer... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/csr/csr.go#L242-L259 |
161,323 | cloudflare/cfssl | csr/csr.go | getNames | func getNames(sub pkix.Name) []Name {
// anonymous func for finding the max of a list of interger
max := func(v1 int, vn ...int) (max int) {
max = v1
for i := 0; i < len(vn); i++ {
if vn[i] > max {
max = vn[i]
}
}
return max
}
nc := len(sub.Country)
norg := len(sub.Organization)
nou := len(sub.... | go | func getNames(sub pkix.Name) []Name {
// anonymous func for finding the max of a list of interger
max := func(v1 int, vn ...int) (max int) {
max = v1
for i := 0; i < len(vn); i++ {
if vn[i] > max {
max = vn[i]
}
}
return max
}
nc := len(sub.Country)
norg := len(sub.Organization)
nou := len(sub.... | [
"func",
"getNames",
"(",
"sub",
"pkix",
".",
"Name",
")",
"[",
"]",
"Name",
"{",
"// anonymous func for finding the max of a list of interger",
"max",
":=",
"func",
"(",
"v1",
"int",
",",
"vn",
"...",
"int",
")",
"(",
"max",
"int",
")",
"{",
"max",
"=",
... | // getNames returns an array of Names from the certificate
// It onnly cares about Country, Organization, OrganizationalUnit, Locality, Province | [
"getNames",
"returns",
"an",
"array",
"of",
"Names",
"from",
"the",
"certificate",
"It",
"onnly",
"cares",
"about",
"Country",
"Organization",
"OrganizationalUnit",
"Locality",
"Province"
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/csr/csr.go#L281-L320 |
161,324 | cloudflare/cfssl | csr/csr.go | ProcessRequest | func (g *Generator) ProcessRequest(req *CertificateRequest) (csr, key []byte, err error) {
log.Info("generate received request")
err = g.Validator(req)
if err != nil {
log.Warningf("invalid request: %v", err)
return nil, nil, err
}
csr, key, err = ParseRequest(req)
if err != nil {
return nil, nil, err
}
... | go | func (g *Generator) ProcessRequest(req *CertificateRequest) (csr, key []byte, err error) {
log.Info("generate received request")
err = g.Validator(req)
if err != nil {
log.Warningf("invalid request: %v", err)
return nil, nil, err
}
csr, key, err = ParseRequest(req)
if err != nil {
return nil, nil, err
}
... | [
"func",
"(",
"g",
"*",
"Generator",
")",
"ProcessRequest",
"(",
"req",
"*",
"CertificateRequest",
")",
"(",
"csr",
",",
"key",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n",
"err",
"=",
"g",
".",
... | // ProcessRequest validates and processes the incoming request. It is
// a wrapper around a validator and the ParseRequest function. | [
"ProcessRequest",
"validates",
"and",
"processes",
"the",
"incoming",
"request",
".",
"It",
"is",
"a",
"wrapper",
"around",
"a",
"validator",
"and",
"the",
"ParseRequest",
"function",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/csr/csr.go#L329-L343 |
161,325 | cloudflare/cfssl | csr/csr.go | IsNameEmpty | func IsNameEmpty(n Name) bool {
empty := func(s string) bool { return strings.TrimSpace(s) == "" }
if empty(n.C) && empty(n.ST) && empty(n.L) && empty(n.O) && empty(n.OU) {
return true
}
return false
} | go | func IsNameEmpty(n Name) bool {
empty := func(s string) bool { return strings.TrimSpace(s) == "" }
if empty(n.C) && empty(n.ST) && empty(n.L) && empty(n.O) && empty(n.OU) {
return true
}
return false
} | [
"func",
"IsNameEmpty",
"(",
"n",
"Name",
")",
"bool",
"{",
"empty",
":=",
"func",
"(",
"s",
"string",
")",
"bool",
"{",
"return",
"strings",
".",
"TrimSpace",
"(",
"s",
")",
"==",
"\"",
"\"",
"}",
"\n\n",
"if",
"empty",
"(",
"n",
".",
"C",
")",
... | // IsNameEmpty returns true if the name has no identifying information in it. | [
"IsNameEmpty",
"returns",
"true",
"if",
"the",
"name",
"has",
"no",
"identifying",
"information",
"in",
"it",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/csr/csr.go#L346-L353 |
161,326 | cloudflare/cfssl | csr/csr.go | Regenerate | func Regenerate(priv crypto.Signer, csr []byte) ([]byte, error) {
req, extra, err := helpers.ParseCSR(csr)
if err != nil {
return nil, err
} else if len(extra) > 0 {
return nil, errors.New("csr: trailing data in certificate request")
}
return x509.CreateCertificateRequest(rand.Reader, req, priv)
} | go | func Regenerate(priv crypto.Signer, csr []byte) ([]byte, error) {
req, extra, err := helpers.ParseCSR(csr)
if err != nil {
return nil, err
} else if len(extra) > 0 {
return nil, errors.New("csr: trailing data in certificate request")
}
return x509.CreateCertificateRequest(rand.Reader, req, priv)
} | [
"func",
"Regenerate",
"(",
"priv",
"crypto",
".",
"Signer",
",",
"csr",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"req",
",",
"extra",
",",
"err",
":=",
"helpers",
".",
"ParseCSR",
"(",
"csr",
")",
"\n",
"if",
"err",
... | // Regenerate uses the provided CSR as a template for signing a new
// CSR using priv. | [
"Regenerate",
"uses",
"the",
"provided",
"CSR",
"as",
"a",
"template",
"for",
"signing",
"a",
"new",
"CSR",
"using",
"priv",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/csr/csr.go#L357-L366 |
161,327 | cloudflare/cfssl | csr/csr.go | Generate | func Generate(priv crypto.Signer, req *CertificateRequest) (csr []byte, err error) {
sigAlgo := helpers.SignerAlgo(priv)
if sigAlgo == x509.UnknownSignatureAlgorithm {
return nil, cferr.New(cferr.PrivateKeyError, cferr.Unavailable)
}
var tpl = x509.CertificateRequest{
Subject: req.Name(),
Signatur... | go | func Generate(priv crypto.Signer, req *CertificateRequest) (csr []byte, err error) {
sigAlgo := helpers.SignerAlgo(priv)
if sigAlgo == x509.UnknownSignatureAlgorithm {
return nil, cferr.New(cferr.PrivateKeyError, cferr.Unavailable)
}
var tpl = x509.CertificateRequest{
Subject: req.Name(),
Signatur... | [
"func",
"Generate",
"(",
"priv",
"crypto",
".",
"Signer",
",",
"req",
"*",
"CertificateRequest",
")",
"(",
"csr",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"sigAlgo",
":=",
"helpers",
".",
"SignerAlgo",
"(",
"priv",
")",
"\n",
"if",
"sigAlgo",
... | // Generate creates a new CSR from a CertificateRequest structure and
// an existing key. The KeyRequest field is ignored. | [
"Generate",
"creates",
"a",
"new",
"CSR",
"from",
"a",
"CertificateRequest",
"structure",
"and",
"an",
"existing",
"key",
".",
"The",
"KeyRequest",
"field",
"is",
"ignored",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/csr/csr.go#L370-L415 |
161,328 | cloudflare/cfssl | csr/csr.go | appendCAInfoToCSR | func appendCAInfoToCSR(reqConf *CAConfig, csr *x509.CertificateRequest) error {
pathlen := reqConf.PathLength
if pathlen == 0 && !reqConf.PathLenZero {
pathlen = -1
}
val, err := asn1.Marshal(BasicConstraints{true, pathlen})
if err != nil {
return err
}
csr.ExtraExtensions = []pkix.Extension{
{
Id: ... | go | func appendCAInfoToCSR(reqConf *CAConfig, csr *x509.CertificateRequest) error {
pathlen := reqConf.PathLength
if pathlen == 0 && !reqConf.PathLenZero {
pathlen = -1
}
val, err := asn1.Marshal(BasicConstraints{true, pathlen})
if err != nil {
return err
}
csr.ExtraExtensions = []pkix.Extension{
{
Id: ... | [
"func",
"appendCAInfoToCSR",
"(",
"reqConf",
"*",
"CAConfig",
",",
"csr",
"*",
"x509",
".",
"CertificateRequest",
")",
"error",
"{",
"pathlen",
":=",
"reqConf",
".",
"PathLength",
"\n",
"if",
"pathlen",
"==",
"0",
"&&",
"!",
"reqConf",
".",
"PathLenZero",
... | // appendCAInfoToCSR appends CAConfig BasicConstraint extension to a CSR | [
"appendCAInfoToCSR",
"appends",
"CAConfig",
"BasicConstraint",
"extension",
"to",
"a",
"CSR"
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/csr/csr.go#L418-L438 |
161,329 | cloudflare/cfssl | signer/signer.go | Profile | func Profile(s Signer, profile string) (*config.SigningProfile, error) {
var p *config.SigningProfile
policy := s.Policy()
if policy != nil && policy.Profiles != nil && profile != "" {
p = policy.Profiles[profile]
}
if p == nil && policy != nil {
p = policy.Default
}
if p == nil {
return nil, cferr.Wrap(... | go | func Profile(s Signer, profile string) (*config.SigningProfile, error) {
var p *config.SigningProfile
policy := s.Policy()
if policy != nil && policy.Profiles != nil && profile != "" {
p = policy.Profiles[profile]
}
if p == nil && policy != nil {
p = policy.Default
}
if p == nil {
return nil, cferr.Wrap(... | [
"func",
"Profile",
"(",
"s",
"Signer",
",",
"profile",
"string",
")",
"(",
"*",
"config",
".",
"SigningProfile",
",",
"error",
")",
"{",
"var",
"p",
"*",
"config",
".",
"SigningProfile",
"\n",
"policy",
":=",
"s",
".",
"Policy",
"(",
")",
"\n",
"if",... | // Profile gets the specific profile from the signer | [
"Profile",
"gets",
"the",
"specific",
"profile",
"from",
"the",
"signer"
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/signer/signer.go#L122-L137 |
161,330 | cloudflare/cfssl | signer/signer.go | DefaultSigAlgo | func DefaultSigAlgo(priv crypto.Signer) x509.SignatureAlgorithm {
pub := priv.Public()
switch pub := pub.(type) {
case *rsa.PublicKey:
keySize := pub.N.BitLen()
switch {
case keySize >= 4096:
return x509.SHA512WithRSA
case keySize >= 3072:
return x509.SHA384WithRSA
case keySize >= 2048:
return x50... | go | func DefaultSigAlgo(priv crypto.Signer) x509.SignatureAlgorithm {
pub := priv.Public()
switch pub := pub.(type) {
case *rsa.PublicKey:
keySize := pub.N.BitLen()
switch {
case keySize >= 4096:
return x509.SHA512WithRSA
case keySize >= 3072:
return x509.SHA384WithRSA
case keySize >= 2048:
return x50... | [
"func",
"DefaultSigAlgo",
"(",
"priv",
"crypto",
".",
"Signer",
")",
"x509",
".",
"SignatureAlgorithm",
"{",
"pub",
":=",
"priv",
".",
"Public",
"(",
")",
"\n",
"switch",
"pub",
":=",
"pub",
".",
"(",
"type",
")",
"{",
"case",
"*",
"rsa",
".",
"Publi... | // DefaultSigAlgo returns an appropriate X.509 signature algorithm given
// the CA's private key. | [
"DefaultSigAlgo",
"returns",
"an",
"appropriate",
"X",
".",
"509",
"signature",
"algorithm",
"given",
"the",
"CA",
"s",
"private",
"key",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/signer/signer.go#L141-L170 |
161,331 | cloudflare/cfssl | signer/signer.go | ParseCertificateRequest | func ParseCertificateRequest(s Signer, csrBytes []byte) (template *x509.Certificate, err error) {
csrv, err := x509.ParseCertificateRequest(csrBytes)
if err != nil {
err = cferr.Wrap(cferr.CSRError, cferr.ParseFailed, err)
return
}
err = csrv.CheckSignature()
if err != nil {
err = cferr.Wrap(cferr.CSRError,... | go | func ParseCertificateRequest(s Signer, csrBytes []byte) (template *x509.Certificate, err error) {
csrv, err := x509.ParseCertificateRequest(csrBytes)
if err != nil {
err = cferr.Wrap(cferr.CSRError, cferr.ParseFailed, err)
return
}
err = csrv.CheckSignature()
if err != nil {
err = cferr.Wrap(cferr.CSRError,... | [
"func",
"ParseCertificateRequest",
"(",
"s",
"Signer",
",",
"csrBytes",
"[",
"]",
"byte",
")",
"(",
"template",
"*",
"x509",
".",
"Certificate",
",",
"err",
"error",
")",
"{",
"csrv",
",",
"err",
":=",
"x509",
".",
"ParseCertificateRequest",
"(",
"csrBytes... | // ParseCertificateRequest takes an incoming certificate request and
// builds a certificate template from it. | [
"ParseCertificateRequest",
"takes",
"an",
"incoming",
"certificate",
"request",
"and",
"builds",
"a",
"certificate",
"template",
"from",
"it",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/signer/signer.go#L174-L219 |
161,332 | cloudflare/cfssl | signer/signer.go | ComputeSKI | func ComputeSKI(template *x509.Certificate) ([]byte, error) {
pub := template.PublicKey
encodedPub, err := x509.MarshalPKIXPublicKey(pub)
if err != nil {
return nil, err
}
var subPKI subjectPublicKeyInfo
_, err = asn1.Unmarshal(encodedPub, &subPKI)
if err != nil {
return nil, err
}
pubHash := sha1.Sum(su... | go | func ComputeSKI(template *x509.Certificate) ([]byte, error) {
pub := template.PublicKey
encodedPub, err := x509.MarshalPKIXPublicKey(pub)
if err != nil {
return nil, err
}
var subPKI subjectPublicKeyInfo
_, err = asn1.Unmarshal(encodedPub, &subPKI)
if err != nil {
return nil, err
}
pubHash := sha1.Sum(su... | [
"func",
"ComputeSKI",
"(",
"template",
"*",
"x509",
".",
"Certificate",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"pub",
":=",
"template",
".",
"PublicKey",
"\n",
"encodedPub",
",",
"err",
":=",
"x509",
".",
"MarshalPKIXPublicKey",
"(",
"pub",
... | // ComputeSKI derives an SKI from the certificate's public key in a
// standard manner. This is done by computing the SHA-1 digest of the
// SubjectPublicKeyInfo component of the certificate. | [
"ComputeSKI",
"derives",
"an",
"SKI",
"from",
"the",
"certificate",
"s",
"public",
"key",
"in",
"a",
"standard",
"manner",
".",
"This",
"is",
"done",
"by",
"computing",
"the",
"SHA",
"-",
"1",
"digest",
"of",
"the",
"SubjectPublicKeyInfo",
"component",
"of",... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/signer/signer.go#L229-L244 |
161,333 | cloudflare/cfssl | signer/signer.go | addPolicies | func addPolicies(template *x509.Certificate, policies []config.CertificatePolicy) error {
asn1PolicyList := []policyInformation{}
for _, policy := range policies {
pi := policyInformation{
// The PolicyIdentifier is an OID assigned to a given issuer.
PolicyIdentifier: asn1.ObjectIdentifier(policy.ID),
}
... | go | func addPolicies(template *x509.Certificate, policies []config.CertificatePolicy) error {
asn1PolicyList := []policyInformation{}
for _, policy := range policies {
pi := policyInformation{
// The PolicyIdentifier is an OID assigned to a given issuer.
PolicyIdentifier: asn1.ObjectIdentifier(policy.ID),
}
... | [
"func",
"addPolicies",
"(",
"template",
"*",
"x509",
".",
"Certificate",
",",
"policies",
"[",
"]",
"config",
".",
"CertificatePolicy",
")",
"error",
"{",
"asn1PolicyList",
":=",
"[",
"]",
"policyInformation",
"{",
"}",
"\n\n",
"for",
"_",
",",
"policy",
"... | // addPolicies adds Certificate Policies and optional Policy Qualifiers to a
// certificate, based on the input config. Go's x509 library allows setting
// Certificate Policies easily, but does not support nested Policy Qualifiers
// under those policies. So we need to construct the ASN.1 structure ourselves. | [
"addPolicies",
"adds",
"Certificate",
"Policies",
"and",
"optional",
"Policy",
"Qualifiers",
"to",
"a",
"certificate",
"based",
"on",
"the",
"input",
"config",
".",
"Go",
"s",
"x509",
"library",
"allows",
"setting",
"Certificate",
"Policies",
"easily",
"but",
"d... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/signer/signer.go#L396-L438 |
161,334 | cloudflare/cfssl | cli/ocspserve/ocspserve.go | ocspServerMain | func ocspServerMain(args []string, c cli.Config) error {
var src ocsp.Source
// serve doesn't support arguments.
if len(args) > 0 {
return errors.New("argument is provided but not defined; please refer to the usage by flag -h")
}
if c.Responses != "" {
s, err := ocsp.NewSourceFromFile(c.Responses)
if err !=... | go | func ocspServerMain(args []string, c cli.Config) error {
var src ocsp.Source
// serve doesn't support arguments.
if len(args) > 0 {
return errors.New("argument is provided but not defined; please refer to the usage by flag -h")
}
if c.Responses != "" {
s, err := ocsp.NewSourceFromFile(c.Responses)
if err !=... | [
"func",
"ocspServerMain",
"(",
"args",
"[",
"]",
"string",
",",
"c",
"cli",
".",
"Config",
")",
"error",
"{",
"var",
"src",
"ocsp",
".",
"Source",
"\n",
"// serve doesn't support arguments.",
"if",
"len",
"(",
"args",
")",
">",
"0",
"{",
"return",
"error... | // ocspServerMain is the command line entry point to the OCSP responder.
// It sets up a new HTTP server that responds to OCSP requests. | [
"ocspServerMain",
"is",
"the",
"command",
"line",
"entry",
"point",
"to",
"the",
"OCSP",
"responder",
".",
"It",
"sets",
"up",
"a",
"new",
"HTTP",
"server",
"that",
"responds",
"to",
"OCSP",
"requests",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/cli/ocspserve/ocspserve.go#L28-L59 |
161,335 | cloudflare/cfssl | scan/crypto/tls/key_agreement.go | sha1Hash | func sha1Hash(slices [][]byte) []byte {
hsha1 := sha1.New()
for _, slice := range slices {
hsha1.Write(slice)
}
return hsha1.Sum(nil)
} | go | func sha1Hash(slices [][]byte) []byte {
hsha1 := sha1.New()
for _, slice := range slices {
hsha1.Write(slice)
}
return hsha1.Sum(nil)
} | [
"func",
"sha1Hash",
"(",
"slices",
"[",
"]",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"hsha1",
":=",
"sha1",
".",
"New",
"(",
")",
"\n",
"for",
"_",
",",
"slice",
":=",
"range",
"slices",
"{",
"hsha1",
".",
"Write",
"(",
"slice",
")",
"\n"... | // sha1Hash calculates a SHA1 hash over the given byte slices. | [
"sha1Hash",
"calculates",
"a",
"SHA1",
"hash",
"over",
"the",
"given",
"byte",
"slices",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/key_agreement.go#L89-L95 |
161,336 | cloudflare/cfssl | scan/crypto/tls/key_agreement.go | md5SHA1Hash | func md5SHA1Hash(slices [][]byte) []byte {
md5sha1 := make([]byte, md5.Size+sha1.Size)
hmd5 := md5.New()
for _, slice := range slices {
hmd5.Write(slice)
}
copy(md5sha1, hmd5.Sum(nil))
copy(md5sha1[md5.Size:], sha1Hash(slices))
return md5sha1
} | go | func md5SHA1Hash(slices [][]byte) []byte {
md5sha1 := make([]byte, md5.Size+sha1.Size)
hmd5 := md5.New()
for _, slice := range slices {
hmd5.Write(slice)
}
copy(md5sha1, hmd5.Sum(nil))
copy(md5sha1[md5.Size:], sha1Hash(slices))
return md5sha1
} | [
"func",
"md5SHA1Hash",
"(",
"slices",
"[",
"]",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"md5sha1",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"md5",
".",
"Size",
"+",
"sha1",
".",
"Size",
")",
"\n",
"hmd5",
":=",
"md5",
".",
"New",
"(",
... | // md5SHA1Hash implements TLS 1.0's hybrid hash function which consists of the
// concatenation of an MD5 and SHA1 hash. | [
"md5SHA1Hash",
"implements",
"TLS",
"1",
".",
"0",
"s",
"hybrid",
"hash",
"function",
"which",
"consists",
"of",
"the",
"concatenation",
"of",
"an",
"MD5",
"and",
"SHA1",
"hash",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/key_agreement.go#L99-L108 |
161,337 | cloudflare/cfssl | scan/crypto/tls/key_agreement.go | hashForServerKeyExchange | func hashForServerKeyExchange(sigAndHash signatureAndHash, version uint16, slices ...[]byte) ([]byte, crypto.Hash, error) {
if version >= VersionTLS12 {
if !isSupportedSignatureAndHash(sigAndHash, supportedSignatureAlgorithms) {
return nil, crypto.Hash(0), errors.New("tls: unsupported hash function used by peer")... | go | func hashForServerKeyExchange(sigAndHash signatureAndHash, version uint16, slices ...[]byte) ([]byte, crypto.Hash, error) {
if version >= VersionTLS12 {
if !isSupportedSignatureAndHash(sigAndHash, supportedSignatureAlgorithms) {
return nil, crypto.Hash(0), errors.New("tls: unsupported hash function used by peer")... | [
"func",
"hashForServerKeyExchange",
"(",
"sigAndHash",
"signatureAndHash",
",",
"version",
"uint16",
",",
"slices",
"...",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"crypto",
".",
"Hash",
",",
"error",
")",
"{",
"if",
"version",
">=",
"VersionTLS1... | // hashForServerKeyExchange hashes the given slices and returns their digest
// and the identifier of the hash function used. The sigAndHash argument is
// only used for >= TLS 1.2 and precisely identifies the hash function to use. | [
"hashForServerKeyExchange",
"hashes",
"the",
"given",
"slices",
"and",
"returns",
"their",
"digest",
"and",
"the",
"identifier",
"of",
"the",
"hash",
"function",
"used",
".",
"The",
"sigAndHash",
"argument",
"is",
"only",
"used",
"for",
">",
"=",
"TLS",
"1",
... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/key_agreement.go#L113-L133 |
161,338 | cloudflare/cfssl | scan/crypto/tls/key_agreement.go | pickTLS12HashForSignature | func pickTLS12HashForSignature(sigType uint8, clientList []signatureAndHash) (uint8, error) {
if len(clientList) == 0 {
// If the client didn't specify any signature_algorithms
// extension then we can assume that it supports SHA1. See
// http://tools.ietf.org/html/rfc5246#section-7.4.1.4.1
return hashSHA1, ni... | go | func pickTLS12HashForSignature(sigType uint8, clientList []signatureAndHash) (uint8, error) {
if len(clientList) == 0 {
// If the client didn't specify any signature_algorithms
// extension then we can assume that it supports SHA1. See
// http://tools.ietf.org/html/rfc5246#section-7.4.1.4.1
return hashSHA1, ni... | [
"func",
"pickTLS12HashForSignature",
"(",
"sigType",
"uint8",
",",
"clientList",
"[",
"]",
"signatureAndHash",
")",
"(",
"uint8",
",",
"error",
")",
"{",
"if",
"len",
"(",
"clientList",
")",
"==",
"0",
"{",
"// If the client didn't specify any signature_algorithms",... | // pickTLS12HashForSignature returns a TLS 1.2 hash identifier for signing a
// ServerKeyExchange given the signature type being used and the client's
// advertised list of supported signature and hash combinations. | [
"pickTLS12HashForSignature",
"returns",
"a",
"TLS",
"1",
".",
"2",
"hash",
"identifier",
"for",
"signing",
"a",
"ServerKeyExchange",
"given",
"the",
"signature",
"type",
"being",
"used",
"and",
"the",
"client",
"s",
"advertised",
"list",
"of",
"supported",
"sign... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/key_agreement.go#L138-L156 |
161,339 | cloudflare/cfssl | api/sign/sign.go | NewHandler | func NewHandler(caFile, caKeyFile string, policy *config.Signing) (http.Handler, error) {
root := universal.Root{
Config: map[string]string{
"cert-file": caFile,
"key-file": caKeyFile,
},
}
s, err := universal.NewSigner(root, policy)
if err != nil {
log.Errorf("setting up signer failed: %v", err)
ret... | go | func NewHandler(caFile, caKeyFile string, policy *config.Signing) (http.Handler, error) {
root := universal.Root{
Config: map[string]string{
"cert-file": caFile,
"key-file": caKeyFile,
},
}
s, err := universal.NewSigner(root, policy)
if err != nil {
log.Errorf("setting up signer failed: %v", err)
ret... | [
"func",
"NewHandler",
"(",
"caFile",
",",
"caKeyFile",
"string",
",",
"policy",
"*",
"config",
".",
"Signing",
")",
"(",
"http",
".",
"Handler",
",",
"error",
")",
"{",
"root",
":=",
"universal",
".",
"Root",
"{",
"Config",
":",
"map",
"[",
"string",
... | // NewHandler generates a new Handler using the certificate
// authority private key and certficate to sign certificates. If remote
// is not an empty string, the handler will send signature requests to
// the CFSSL instance contained in remote by default. | [
"NewHandler",
"generates",
"a",
"new",
"Handler",
"using",
"the",
"certificate",
"authority",
"private",
"key",
"and",
"certficate",
"to",
"sign",
"certificates",
".",
"If",
"remote",
"is",
"not",
"an",
"empty",
"string",
"the",
"handler",
"will",
"send",
"sig... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/api/sign/sign.go#L17-L31 |
161,340 | cloudflare/cfssl | scan/crypto/tls/conn.go | prepareCipherSpec | func (hc *halfConn) prepareCipherSpec(version uint16, cipher interface{}, mac macFunction) {
hc.version = version
hc.nextCipher = cipher
hc.nextMac = mac
} | go | func (hc *halfConn) prepareCipherSpec(version uint16, cipher interface{}, mac macFunction) {
hc.version = version
hc.nextCipher = cipher
hc.nextMac = mac
} | [
"func",
"(",
"hc",
"*",
"halfConn",
")",
"prepareCipherSpec",
"(",
"version",
"uint16",
",",
"cipher",
"interface",
"{",
"}",
",",
"mac",
"macFunction",
")",
"{",
"hc",
".",
"version",
"=",
"version",
"\n",
"hc",
".",
"nextCipher",
"=",
"cipher",
"\n",
... | // prepareCipherSpec sets the encryption and MAC states
// that a subsequent changeCipherSpec will use. | [
"prepareCipherSpec",
"sets",
"the",
"encryption",
"and",
"MAC",
"states",
"that",
"a",
"subsequent",
"changeCipherSpec",
"will",
"use",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/conn.go#L136-L140 |
161,341 | cloudflare/cfssl | scan/crypto/tls/conn.go | changeCipherSpec | func (hc *halfConn) changeCipherSpec() error {
if hc.nextCipher == nil {
return alertInternalError
}
hc.cipher = hc.nextCipher
hc.mac = hc.nextMac
hc.nextCipher = nil
hc.nextMac = nil
for i := range hc.seq {
hc.seq[i] = 0
}
return nil
} | go | func (hc *halfConn) changeCipherSpec() error {
if hc.nextCipher == nil {
return alertInternalError
}
hc.cipher = hc.nextCipher
hc.mac = hc.nextMac
hc.nextCipher = nil
hc.nextMac = nil
for i := range hc.seq {
hc.seq[i] = 0
}
return nil
} | [
"func",
"(",
"hc",
"*",
"halfConn",
")",
"changeCipherSpec",
"(",
")",
"error",
"{",
"if",
"hc",
".",
"nextCipher",
"==",
"nil",
"{",
"return",
"alertInternalError",
"\n",
"}",
"\n",
"hc",
".",
"cipher",
"=",
"hc",
".",
"nextCipher",
"\n",
"hc",
".",
... | // changeCipherSpec changes the encryption and MAC states
// to the ones previously passed to prepareCipherSpec. | [
"changeCipherSpec",
"changes",
"the",
"encryption",
"and",
"MAC",
"states",
"to",
"the",
"ones",
"previously",
"passed",
"to",
"prepareCipherSpec",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/conn.go#L144-L156 |
161,342 | cloudflare/cfssl | scan/crypto/tls/conn.go | incSeq | func (hc *halfConn) incSeq() {
for i := 7; i >= 0; i-- {
hc.seq[i]++
if hc.seq[i] != 0 {
return
}
}
// Not allowed to let sequence number wrap.
// Instead, must renegotiate before it does.
// Not likely enough to bother.
panic("TLS: sequence number wraparound")
} | go | func (hc *halfConn) incSeq() {
for i := 7; i >= 0; i-- {
hc.seq[i]++
if hc.seq[i] != 0 {
return
}
}
// Not allowed to let sequence number wrap.
// Instead, must renegotiate before it does.
// Not likely enough to bother.
panic("TLS: sequence number wraparound")
} | [
"func",
"(",
"hc",
"*",
"halfConn",
")",
"incSeq",
"(",
")",
"{",
"for",
"i",
":=",
"7",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"hc",
".",
"seq",
"[",
"i",
"]",
"++",
"\n",
"if",
"hc",
".",
"seq",
"[",
"i",
"]",
"!=",
"0",
"{",
"retu... | // incSeq increments the sequence number. | [
"incSeq",
"increments",
"the",
"sequence",
"number",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/conn.go#L159-L171 |
161,343 | cloudflare/cfssl | scan/crypto/tls/conn.go | removePadding | func removePadding(payload []byte) ([]byte, byte) {
if len(payload) < 1 {
return payload, 0
}
paddingLen := payload[len(payload)-1]
t := uint(len(payload)-1) - uint(paddingLen)
// if len(payload) >= (paddingLen - 1) then the MSB of t is zero
good := byte(int32(^t) >> 31)
toCheck := 255 // the maximum possibl... | go | func removePadding(payload []byte) ([]byte, byte) {
if len(payload) < 1 {
return payload, 0
}
paddingLen := payload[len(payload)-1]
t := uint(len(payload)-1) - uint(paddingLen)
// if len(payload) >= (paddingLen - 1) then the MSB of t is zero
good := byte(int32(^t) >> 31)
toCheck := 255 // the maximum possibl... | [
"func",
"removePadding",
"(",
"payload",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"byte",
")",
"{",
"if",
"len",
"(",
"payload",
")",
"<",
"1",
"{",
"return",
"payload",
",",
"0",
"\n",
"}",
"\n\n",
"paddingLen",
":=",
"payload",
"[",
"... | // removePadding returns an unpadded slice, in constant time, which is a prefix
// of the input. It also returns a byte which is equal to 255 if the padding
// was valid and 0 otherwise. See RFC 2246, section 6.2.3.2 | [
"removePadding",
"returns",
"an",
"unpadded",
"slice",
"in",
"constant",
"time",
"which",
"is",
"a",
"prefix",
"of",
"the",
"input",
".",
"It",
"also",
"returns",
"a",
"byte",
"which",
"is",
"equal",
"to",
"255",
"if",
"the",
"padding",
"was",
"valid",
"... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/conn.go#L183-L216 |
161,344 | cloudflare/cfssl | scan/crypto/tls/conn.go | removePaddingSSL30 | func removePaddingSSL30(payload []byte) ([]byte, byte) {
if len(payload) < 1 {
return payload, 0
}
paddingLen := int(payload[len(payload)-1]) + 1
if paddingLen > len(payload) {
return payload, 0
}
return payload[:len(payload)-paddingLen], 255
} | go | func removePaddingSSL30(payload []byte) ([]byte, byte) {
if len(payload) < 1 {
return payload, 0
}
paddingLen := int(payload[len(payload)-1]) + 1
if paddingLen > len(payload) {
return payload, 0
}
return payload[:len(payload)-paddingLen], 255
} | [
"func",
"removePaddingSSL30",
"(",
"payload",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"byte",
")",
"{",
"if",
"len",
"(",
"payload",
")",
"<",
"1",
"{",
"return",
"payload",
",",
"0",
"\n",
"}",
"\n\n",
"paddingLen",
":=",
"int",
"(",
... | // removePaddingSSL30 is a replacement for removePadding in the case that the
// protocol version is SSLv3. In this version, the contents of the padding
// are random and cannot be checked. | [
"removePaddingSSL30",
"is",
"a",
"replacement",
"for",
"removePadding",
"in",
"the",
"case",
"that",
"the",
"protocol",
"version",
"is",
"SSLv3",
".",
"In",
"this",
"version",
"the",
"contents",
"of",
"the",
"padding",
"are",
"random",
"and",
"cannot",
"be",
... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/conn.go#L221-L232 |
161,345 | cloudflare/cfssl | scan/crypto/tls/conn.go | padToBlockSize | func padToBlockSize(payload []byte, blockSize int) (prefix, finalBlock []byte) {
overrun := len(payload) % blockSize
paddingLen := blockSize - overrun
prefix = payload[:len(payload)-overrun]
finalBlock = make([]byte, blockSize)
copy(finalBlock, payload[len(payload)-overrun:])
for i := overrun; i < blockSize; i++ ... | go | func padToBlockSize(payload []byte, blockSize int) (prefix, finalBlock []byte) {
overrun := len(payload) % blockSize
paddingLen := blockSize - overrun
prefix = payload[:len(payload)-overrun]
finalBlock = make([]byte, blockSize)
copy(finalBlock, payload[len(payload)-overrun:])
for i := overrun; i < blockSize; i++ ... | [
"func",
"padToBlockSize",
"(",
"payload",
"[",
"]",
"byte",
",",
"blockSize",
"int",
")",
"(",
"prefix",
",",
"finalBlock",
"[",
"]",
"byte",
")",
"{",
"overrun",
":=",
"len",
"(",
"payload",
")",
"%",
"blockSize",
"\n",
"paddingLen",
":=",
"blockSize",
... | // padToBlockSize calculates the needed padding block, if any, for a payload.
// On exit, prefix aliases payload and extends to the end of the last full
// block of payload. finalBlock is a fresh slice which contains the contents of
// any suffix of payload as well as the needed padding to make finalBlock a
// full blo... | [
"padToBlockSize",
"calculates",
"the",
"needed",
"padding",
"block",
"if",
"any",
"for",
"a",
"payload",
".",
"On",
"exit",
"prefix",
"aliases",
"payload",
"and",
"extends",
"to",
"the",
"end",
"of",
"the",
"last",
"full",
"block",
"of",
"payload",
".",
"f... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/conn.go#L349-L359 |
161,346 | cloudflare/cfssl | scan/crypto/tls/conn.go | encrypt | func (hc *halfConn) encrypt(b *block, explicitIVLen int) (bool, alert) {
// mac
if hc.mac != nil {
mac := hc.mac.MAC(hc.outDigestBuf, hc.seq[0:], b.data[:recordHeaderLen], b.data[recordHeaderLen+explicitIVLen:])
n := len(b.data)
b.resize(n + len(mac))
copy(b.data[n:], mac)
hc.outDigestBuf = mac
}
payloa... | go | func (hc *halfConn) encrypt(b *block, explicitIVLen int) (bool, alert) {
// mac
if hc.mac != nil {
mac := hc.mac.MAC(hc.outDigestBuf, hc.seq[0:], b.data[:recordHeaderLen], b.data[recordHeaderLen+explicitIVLen:])
n := len(b.data)
b.resize(n + len(mac))
copy(b.data[n:], mac)
hc.outDigestBuf = mac
}
payloa... | [
"func",
"(",
"hc",
"*",
"halfConn",
")",
"encrypt",
"(",
"b",
"*",
"block",
",",
"explicitIVLen",
"int",
")",
"(",
"bool",
",",
"alert",
")",
"{",
"// mac",
"if",
"hc",
".",
"mac",
"!=",
"nil",
"{",
"mac",
":=",
"hc",
".",
"mac",
".",
"MAC",
"(... | // encrypt encrypts and macs the data in b. | [
"encrypt",
"encrypts",
"and",
"macs",
"the",
"data",
"in",
"b",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/conn.go#L362-L415 |
161,347 | cloudflare/cfssl | scan/crypto/tls/conn.go | resize | func (b *block) resize(n int) {
if n > cap(b.data) {
b.reserve(n)
}
b.data = b.data[0:n]
} | go | func (b *block) resize(n int) {
if n > cap(b.data) {
b.reserve(n)
}
b.data = b.data[0:n]
} | [
"func",
"(",
"b",
"*",
"block",
")",
"resize",
"(",
"n",
"int",
")",
"{",
"if",
"n",
">",
"cap",
"(",
"b",
".",
"data",
")",
"{",
"b",
".",
"reserve",
"(",
"n",
")",
"\n",
"}",
"\n",
"b",
".",
"data",
"=",
"b",
".",
"data",
"[",
"0",
":... | // resize resizes block to be n bytes, growing if necessary. | [
"resize",
"resizes",
"block",
"to",
"be",
"n",
"bytes",
"growing",
"if",
"necessary",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/conn.go#L425-L430 |
161,348 | cloudflare/cfssl | scan/crypto/tls/conn.go | reserve | func (b *block) reserve(n int) {
if cap(b.data) >= n {
return
}
m := cap(b.data)
if m == 0 {
m = 1024
}
for m < n {
m *= 2
}
data := make([]byte, len(b.data), m)
copy(data, b.data)
b.data = data
} | go | func (b *block) reserve(n int) {
if cap(b.data) >= n {
return
}
m := cap(b.data)
if m == 0 {
m = 1024
}
for m < n {
m *= 2
}
data := make([]byte, len(b.data), m)
copy(data, b.data)
b.data = data
} | [
"func",
"(",
"b",
"*",
"block",
")",
"reserve",
"(",
"n",
"int",
")",
"{",
"if",
"cap",
"(",
"b",
".",
"data",
")",
">=",
"n",
"{",
"return",
"\n",
"}",
"\n",
"m",
":=",
"cap",
"(",
"b",
".",
"data",
")",
"\n",
"if",
"m",
"==",
"0",
"{",
... | // reserve makes sure that block contains a capacity of at least n bytes. | [
"reserve",
"makes",
"sure",
"that",
"block",
"contains",
"a",
"capacity",
"of",
"at",
"least",
"n",
"bytes",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/conn.go#L433-L447 |
161,349 | cloudflare/cfssl | scan/crypto/tls/conn.go | readFromUntil | func (b *block) readFromUntil(r io.Reader, n int) error {
// quick case
if len(b.data) >= n {
return nil
}
// read until have enough.
b.reserve(n)
for {
m, err := r.Read(b.data[len(b.data):cap(b.data)])
b.data = b.data[0 : len(b.data)+m]
if len(b.data) >= n {
// TODO(bradfitz,agl): slightly suspicious... | go | func (b *block) readFromUntil(r io.Reader, n int) error {
// quick case
if len(b.data) >= n {
return nil
}
// read until have enough.
b.reserve(n)
for {
m, err := r.Read(b.data[len(b.data):cap(b.data)])
b.data = b.data[0 : len(b.data)+m]
if len(b.data) >= n {
// TODO(bradfitz,agl): slightly suspicious... | [
"func",
"(",
"b",
"*",
"block",
")",
"readFromUntil",
"(",
"r",
"io",
".",
"Reader",
",",
"n",
"int",
")",
"error",
"{",
"// quick case",
"if",
"len",
"(",
"b",
".",
"data",
")",
">=",
"n",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// read until ha... | // readFromUntil reads from r into b until b contains at least n bytes
// or else returns an error. | [
"readFromUntil",
"reads",
"from",
"r",
"into",
"b",
"until",
"b",
"contains",
"at",
"least",
"n",
"bytes",
"or",
"else",
"returns",
"an",
"error",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/conn.go#L451-L472 |
161,350 | cloudflare/cfssl | scan/crypto/tls/conn.go | newBlock | func (hc *halfConn) newBlock() *block {
b := hc.bfree
if b == nil {
return new(block)
}
hc.bfree = b.link
b.link = nil
b.resize(0)
return b
} | go | func (hc *halfConn) newBlock() *block {
b := hc.bfree
if b == nil {
return new(block)
}
hc.bfree = b.link
b.link = nil
b.resize(0)
return b
} | [
"func",
"(",
"hc",
"*",
"halfConn",
")",
"newBlock",
"(",
")",
"*",
"block",
"{",
"b",
":=",
"hc",
".",
"bfree",
"\n",
"if",
"b",
"==",
"nil",
"{",
"return",
"new",
"(",
"block",
")",
"\n",
"}",
"\n",
"hc",
".",
"bfree",
"=",
"b",
".",
"link"... | // newBlock allocates a new block, from hc's free list if possible. | [
"newBlock",
"allocates",
"a",
"new",
"block",
"from",
"hc",
"s",
"free",
"list",
"if",
"possible",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/conn.go#L481-L490 |
161,351 | cloudflare/cfssl | scan/crypto/tls/conn.go | freeBlock | func (hc *halfConn) freeBlock(b *block) {
b.link = hc.bfree
hc.bfree = b
} | go | func (hc *halfConn) freeBlock(b *block) {
b.link = hc.bfree
hc.bfree = b
} | [
"func",
"(",
"hc",
"*",
"halfConn",
")",
"freeBlock",
"(",
"b",
"*",
"block",
")",
"{",
"b",
".",
"link",
"=",
"hc",
".",
"bfree",
"\n",
"hc",
".",
"bfree",
"=",
"b",
"\n",
"}"
] | // freeBlock returns a block to hc's free list.
// The protocol is such that each side only has a block or two on
// its free list at a time, so there's no need to worry about
// trimming the list, etc. | [
"freeBlock",
"returns",
"a",
"block",
"to",
"hc",
"s",
"free",
"list",
".",
"The",
"protocol",
"is",
"such",
"that",
"each",
"side",
"only",
"has",
"a",
"block",
"or",
"two",
"on",
"its",
"free",
"list",
"at",
"a",
"time",
"so",
"there",
"s",
"no",
... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/conn.go#L496-L499 |
161,352 | cloudflare/cfssl | scan/crypto/tls/conn.go | splitBlock | func (hc *halfConn) splitBlock(b *block, n int) (*block, *block) {
if len(b.data) <= n {
return b, nil
}
bb := hc.newBlock()
bb.resize(len(b.data) - n)
copy(bb.data, b.data[n:])
b.data = b.data[0:n]
return b, bb
} | go | func (hc *halfConn) splitBlock(b *block, n int) (*block, *block) {
if len(b.data) <= n {
return b, nil
}
bb := hc.newBlock()
bb.resize(len(b.data) - n)
copy(bb.data, b.data[n:])
b.data = b.data[0:n]
return b, bb
} | [
"func",
"(",
"hc",
"*",
"halfConn",
")",
"splitBlock",
"(",
"b",
"*",
"block",
",",
"n",
"int",
")",
"(",
"*",
"block",
",",
"*",
"block",
")",
"{",
"if",
"len",
"(",
"b",
".",
"data",
")",
"<=",
"n",
"{",
"return",
"b",
",",
"nil",
"\n",
"... | // splitBlock splits a block after the first n bytes,
// returning a block with those n bytes and a
// block with the remainder. the latter may be nil. | [
"splitBlock",
"splits",
"a",
"block",
"after",
"the",
"first",
"n",
"bytes",
"returning",
"a",
"block",
"with",
"those",
"n",
"bytes",
"and",
"a",
"block",
"with",
"the",
"remainder",
".",
"the",
"latter",
"may",
"be",
"nil",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/conn.go#L504-L513 |
161,353 | cloudflare/cfssl | scan/crypto/tls/conn.go | sendAlert | func (c *Conn) sendAlert(err alert) error {
c.out.Lock()
defer c.out.Unlock()
return c.sendAlertLocked(err)
} | go | func (c *Conn) sendAlert(err alert) error {
c.out.Lock()
defer c.out.Unlock()
return c.sendAlertLocked(err)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"sendAlert",
"(",
"err",
"alert",
")",
"error",
"{",
"c",
".",
"out",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"out",
".",
"Unlock",
"(",
")",
"\n",
"return",
"c",
".",
"sendAlertLocked",
"(",
"err",
"... | // sendAlert sends a TLS alert message.
// L < c.out.Mutex. | [
"sendAlert",
"sends",
"a",
"TLS",
"alert",
"message",
".",
"L",
"<",
"c",
".",
"out",
".",
"Mutex",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/conn.go#L707-L711 |
161,354 | cloudflare/cfssl | scan/crypto/tls/conn.go | writeRecord | func (c *Conn) writeRecord(typ recordType, data []byte) (n int, err error) {
b := c.out.newBlock()
for len(data) > 0 {
m := len(data)
if m > maxPlaintext {
m = maxPlaintext
}
explicitIVLen := 0
explicitIVIsSeq := false
var cbc cbcMode
if c.out.version >= VersionTLS11 {
var ok bool
if cbc, ok =... | go | func (c *Conn) writeRecord(typ recordType, data []byte) (n int, err error) {
b := c.out.newBlock()
for len(data) > 0 {
m := len(data)
if m > maxPlaintext {
m = maxPlaintext
}
explicitIVLen := 0
explicitIVIsSeq := false
var cbc cbcMode
if c.out.version >= VersionTLS11 {
var ok bool
if cbc, ok =... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"writeRecord",
"(",
"typ",
"recordType",
",",
"data",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"b",
":=",
"c",
".",
"out",
".",
"newBlock",
"(",
")",
"\n",
"for",
"len",
"(",
"... | // writeRecord writes a TLS record with the given type and payload
// to the connection and updates the record layer state.
// c.out.Mutex <= L. | [
"writeRecord",
"writes",
"a",
"TLS",
"record",
"with",
"the",
"given",
"type",
"and",
"payload",
"to",
"the",
"connection",
"and",
"updates",
"the",
"record",
"layer",
"state",
".",
"c",
".",
"out",
".",
"Mutex",
"<",
"=",
"L",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/conn.go#L716-L790 |
161,355 | cloudflare/cfssl | scan/crypto/tls/conn.go | readHandshake | func (c *Conn) readHandshake() (interface{}, error) {
for c.hand.Len() < 4 {
if err := c.in.err; err != nil {
return nil, err
}
if err := c.readRecord(recordTypeHandshake); err != nil {
return nil, err
}
}
data := c.hand.Bytes()
n := int(data[1])<<16 | int(data[2])<<8 | int(data[3])
if n > maxHandsh... | go | func (c *Conn) readHandshake() (interface{}, error) {
for c.hand.Len() < 4 {
if err := c.in.err; err != nil {
return nil, err
}
if err := c.readRecord(recordTypeHandshake); err != nil {
return nil, err
}
}
data := c.hand.Bytes()
n := int(data[1])<<16 | int(data[2])<<8 | int(data[3])
if n > maxHandsh... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"readHandshake",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"for",
"c",
".",
"hand",
".",
"Len",
"(",
")",
"<",
"4",
"{",
"if",
"err",
":=",
"c",
".",
"in",
".",
"err",
";",
"err",
"!="... | // readHandshake reads the next handshake message from
// the record layer.
// c.in.Mutex < L; c.out.Mutex < L. | [
"readHandshake",
"reads",
"the",
"next",
"handshake",
"message",
"from",
"the",
"record",
"layer",
".",
"c",
".",
"in",
".",
"Mutex",
"<",
"L",
";",
"c",
".",
"out",
".",
"Mutex",
"<",
"L",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/conn.go#L795-L862 |
161,356 | cloudflare/cfssl | scan/crypto/tls/conn.go | ConnectionState | func (c *Conn) ConnectionState() ConnectionState {
c.handshakeMutex.Lock()
defer c.handshakeMutex.Unlock()
var state ConnectionState
state.HandshakeComplete = c.handshakeComplete
if c.handshakeComplete {
state.Version = c.vers
state.NegotiatedProtocol = c.clientProtocol
state.DidResume = c.didResume
state... | go | func (c *Conn) ConnectionState() ConnectionState {
c.handshakeMutex.Lock()
defer c.handshakeMutex.Unlock()
var state ConnectionState
state.HandshakeComplete = c.handshakeComplete
if c.handshakeComplete {
state.Version = c.vers
state.NegotiatedProtocol = c.clientProtocol
state.DidResume = c.didResume
state... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"ConnectionState",
"(",
")",
"ConnectionState",
"{",
"c",
".",
"handshakeMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"handshakeMutex",
".",
"Unlock",
"(",
")",
"\n\n",
"var",
"state",
"ConnectionState",
"\n... | // ConnectionState returns basic TLS details about the connection. | [
"ConnectionState",
"returns",
"basic",
"TLS",
"details",
"about",
"the",
"connection",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/conn.go#L1041-L1064 |
161,357 | cloudflare/cfssl | scan/crypto/tls/conn.go | VerifyHostname | func (c *Conn) VerifyHostname(host string) error {
c.handshakeMutex.Lock()
defer c.handshakeMutex.Unlock()
if !c.isClient {
return errors.New("tls: VerifyHostname called on TLS server connection")
}
if !c.handshakeComplete {
return errors.New("tls: handshake has not yet been performed")
}
if len(c.verifiedCh... | go | func (c *Conn) VerifyHostname(host string) error {
c.handshakeMutex.Lock()
defer c.handshakeMutex.Unlock()
if !c.isClient {
return errors.New("tls: VerifyHostname called on TLS server connection")
}
if !c.handshakeComplete {
return errors.New("tls: handshake has not yet been performed")
}
if len(c.verifiedCh... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"VerifyHostname",
"(",
"host",
"string",
")",
"error",
"{",
"c",
".",
"handshakeMutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"handshakeMutex",
".",
"Unlock",
"(",
")",
"\n",
"if",
"!",
"c",
".",
"isCli... | // VerifyHostname checks that the peer certificate chain is valid for
// connecting to host. If so, it returns nil; if not, it returns an error
// describing the problem. | [
"VerifyHostname",
"checks",
"that",
"the",
"peer",
"certificate",
"chain",
"is",
"valid",
"for",
"connecting",
"to",
"host",
".",
"If",
"so",
"it",
"returns",
"nil",
";",
"if",
"not",
"it",
"returns",
"an",
"error",
"describing",
"the",
"problem",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/conn.go#L1078-L1091 |
161,358 | cloudflare/cfssl | cli/sign/sign.go | SignerFromConfigAndDB | func SignerFromConfigAndDB(c cli.Config, db *sqlx.DB) (signer.Signer, error) {
// If there is a config, use its signing policy. Otherwise create a default policy.
var policy *config.Signing
if c.CFG != nil {
policy = c.CFG.Signing
} else {
policy = &config.Signing{
Profiles: map[string]*config.SigningProfile... | go | func SignerFromConfigAndDB(c cli.Config, db *sqlx.DB) (signer.Signer, error) {
// If there is a config, use its signing policy. Otherwise create a default policy.
var policy *config.Signing
if c.CFG != nil {
policy = c.CFG.Signing
} else {
policy = &config.Signing{
Profiles: map[string]*config.SigningProfile... | [
"func",
"SignerFromConfigAndDB",
"(",
"c",
"cli",
".",
"Config",
",",
"db",
"*",
"sqlx",
".",
"DB",
")",
"(",
"signer",
".",
"Signer",
",",
"error",
")",
"{",
"// If there is a config, use its signing policy. Otherwise create a default policy.",
"var",
"policy",
"*"... | // SignerFromConfigAndDB takes the Config and creates the appropriate
// signer.Signer object with a specified db | [
"SignerFromConfigAndDB",
"takes",
"the",
"Config",
"and",
"creates",
"the",
"appropriate",
"signer",
".",
"Signer",
"object",
"with",
"a",
"specified",
"db"
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/cli/sign/sign.go#L43-L93 |
161,359 | cloudflare/cfssl | cli/sign/sign.go | SignerFromConfig | func SignerFromConfig(c cli.Config) (s signer.Signer, err error) {
var db *sqlx.DB
if c.DBConfigFile != "" {
db, err = dbconf.DBFromConfig(c.DBConfigFile)
if err != nil {
return nil, err
}
}
return SignerFromConfigAndDB(c, db)
} | go | func SignerFromConfig(c cli.Config) (s signer.Signer, err error) {
var db *sqlx.DB
if c.DBConfigFile != "" {
db, err = dbconf.DBFromConfig(c.DBConfigFile)
if err != nil {
return nil, err
}
}
return SignerFromConfigAndDB(c, db)
} | [
"func",
"SignerFromConfig",
"(",
"c",
"cli",
".",
"Config",
")",
"(",
"s",
"signer",
".",
"Signer",
",",
"err",
"error",
")",
"{",
"var",
"db",
"*",
"sqlx",
".",
"DB",
"\n",
"if",
"c",
".",
"DBConfigFile",
"!=",
"\"",
"\"",
"{",
"db",
",",
"err",... | // SignerFromConfig takes the Config and creates the appropriate
// signer.Signer object | [
"SignerFromConfig",
"takes",
"the",
"Config",
"and",
"creates",
"the",
"appropriate",
"signer",
".",
"Signer",
"object"
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/cli/sign/sign.go#L97-L106 |
161,360 | cloudflare/cfssl | scan/crypto/rsa/pss.go | VerifyPSS | func VerifyPSS(pub *PublicKey, hash crypto.Hash, hashed []byte, sig []byte, opts *PSSOptions) error {
return verifyPSS(pub, hash, hashed, sig, opts.saltLength())
} | go | func VerifyPSS(pub *PublicKey, hash crypto.Hash, hashed []byte, sig []byte, opts *PSSOptions) error {
return verifyPSS(pub, hash, hashed, sig, opts.saltLength())
} | [
"func",
"VerifyPSS",
"(",
"pub",
"*",
"PublicKey",
",",
"hash",
"crypto",
".",
"Hash",
",",
"hashed",
"[",
"]",
"byte",
",",
"sig",
"[",
"]",
"byte",
",",
"opts",
"*",
"PSSOptions",
")",
"error",
"{",
"return",
"verifyPSS",
"(",
"pub",
",",
"hash",
... | // VerifyPSS verifies a PSS signature.
// hashed is the result of hashing the input message using the given hash
// function and sig is the signature. A valid signature is indicated by
// returning a nil error. The opts argument may be nil, in which case sensible
// defaults are used. | [
"VerifyPSS",
"verifies",
"a",
"PSS",
"signature",
".",
"hashed",
"is",
"the",
"result",
"of",
"hashing",
"the",
"input",
"message",
"using",
"the",
"given",
"hash",
"function",
"and",
"sig",
"is",
"the",
"signature",
".",
"A",
"valid",
"signature",
"is",
"... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/rsa/pss.go#L274-L276 |
161,361 | cloudflare/cfssl | scan/crypto/rsa/pss.go | verifyPSS | func verifyPSS(pub *PublicKey, hash crypto.Hash, hashed []byte, sig []byte, saltLen int) error {
nBits := pub.N.BitLen()
if len(sig) != (nBits+7)/8 {
return ErrVerification
}
s := new(big.Int).SetBytes(sig)
m := encrypt(new(big.Int), pub, s)
emBits := nBits - 1
emLen := (emBits + 7) / 8
if emLen < len(m.Bytes... | go | func verifyPSS(pub *PublicKey, hash crypto.Hash, hashed []byte, sig []byte, saltLen int) error {
nBits := pub.N.BitLen()
if len(sig) != (nBits+7)/8 {
return ErrVerification
}
s := new(big.Int).SetBytes(sig)
m := encrypt(new(big.Int), pub, s)
emBits := nBits - 1
emLen := (emBits + 7) / 8
if emLen < len(m.Bytes... | [
"func",
"verifyPSS",
"(",
"pub",
"*",
"PublicKey",
",",
"hash",
"crypto",
".",
"Hash",
",",
"hashed",
"[",
"]",
"byte",
",",
"sig",
"[",
"]",
"byte",
",",
"saltLen",
"int",
")",
"error",
"{",
"nBits",
":=",
"pub",
".",
"N",
".",
"BitLen",
"(",
")... | // verifyPSS verifies a PSS signature with the given salt length. | [
"verifyPSS",
"verifies",
"a",
"PSS",
"signature",
"with",
"the",
"given",
"salt",
"length",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/rsa/pss.go#L279-L297 |
161,362 | cloudflare/cfssl | cli/ocspdump/ocspdump.go | ocspdumpMain | func ocspdumpMain(args []string, c cli.Config) error {
if c.DBConfigFile == "" {
return errors.New("need DB config file (provide with -db-config)")
}
db, err := dbconf.DBFromConfig(c.DBConfigFile)
if err != nil {
return err
}
dbAccessor := sql.NewAccessor(db)
records, err := dbAccessor.GetUnexpiredOCSPs()
... | go | func ocspdumpMain(args []string, c cli.Config) error {
if c.DBConfigFile == "" {
return errors.New("need DB config file (provide with -db-config)")
}
db, err := dbconf.DBFromConfig(c.DBConfigFile)
if err != nil {
return err
}
dbAccessor := sql.NewAccessor(db)
records, err := dbAccessor.GetUnexpiredOCSPs()
... | [
"func",
"ocspdumpMain",
"(",
"args",
"[",
"]",
"string",
",",
"c",
"cli",
".",
"Config",
")",
"error",
"{",
"if",
"c",
".",
"DBConfigFile",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"db",
",",... | // ocspdumpMain is the main CLI of OCSP dump functionality. | [
"ocspdumpMain",
"is",
"the",
"main",
"CLI",
"of",
"OCSP",
"dump",
"functionality",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/cli/ocspdump/ocspdump.go#L28-L47 |
161,363 | cloudflare/cfssl | certdb/sql/database_accessor.go | InsertCertificate | func (d *Accessor) InsertCertificate(cr certdb.CertificateRecord) error {
err := d.checkDB()
if err != nil {
return err
}
res, err := d.db.NamedExec(insertSQL, &certdb.CertificateRecord{
Serial: cr.Serial,
AKI: cr.AKI,
CALabel: cr.CALabel,
Status: cr.Status,
Reason: cr.Reason,
Expiry... | go | func (d *Accessor) InsertCertificate(cr certdb.CertificateRecord) error {
err := d.checkDB()
if err != nil {
return err
}
res, err := d.db.NamedExec(insertSQL, &certdb.CertificateRecord{
Serial: cr.Serial,
AKI: cr.AKI,
CALabel: cr.CALabel,
Status: cr.Status,
Reason: cr.Reason,
Expiry... | [
"func",
"(",
"d",
"*",
"Accessor",
")",
"InsertCertificate",
"(",
"cr",
"certdb",
".",
"CertificateRecord",
")",
"error",
"{",
"err",
":=",
"d",
".",
"checkDB",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"res",... | // InsertCertificate puts a certdb.CertificateRecord into db. | [
"InsertCertificate",
"puts",
"a",
"certdb",
".",
"CertificateRecord",
"into",
"db",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/certdb/sql/database_accessor.go#L96-L127 |
161,364 | cloudflare/cfssl | certdb/sql/database_accessor.go | GetCertificate | func (d *Accessor) GetCertificate(serial, aki string) (crs []certdb.CertificateRecord, err error) {
err = d.checkDB()
if err != nil {
return nil, err
}
err = d.db.Select(&crs, fmt.Sprintf(d.db.Rebind(selectSQL), sqlstruct.Columns(certdb.CertificateRecord{})), serial, aki)
if err != nil {
return nil, wrapSQLEr... | go | func (d *Accessor) GetCertificate(serial, aki string) (crs []certdb.CertificateRecord, err error) {
err = d.checkDB()
if err != nil {
return nil, err
}
err = d.db.Select(&crs, fmt.Sprintf(d.db.Rebind(selectSQL), sqlstruct.Columns(certdb.CertificateRecord{})), serial, aki)
if err != nil {
return nil, wrapSQLEr... | [
"func",
"(",
"d",
"*",
"Accessor",
")",
"GetCertificate",
"(",
"serial",
",",
"aki",
"string",
")",
"(",
"crs",
"[",
"]",
"certdb",
".",
"CertificateRecord",
",",
"err",
"error",
")",
"{",
"err",
"=",
"d",
".",
"checkDB",
"(",
")",
"\n",
"if",
"err... | // GetCertificate gets a certdb.CertificateRecord indexed by serial. | [
"GetCertificate",
"gets",
"a",
"certdb",
".",
"CertificateRecord",
"indexed",
"by",
"serial",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/certdb/sql/database_accessor.go#L130-L142 |
161,365 | cloudflare/cfssl | certdb/sql/database_accessor.go | GetUnexpiredCertificates | func (d *Accessor) GetUnexpiredCertificates() (crs []certdb.CertificateRecord, err error) {
err = d.checkDB()
if err != nil {
return nil, err
}
err = d.db.Select(&crs, fmt.Sprintf(d.db.Rebind(selectAllUnexpiredSQL), sqlstruct.Columns(certdb.CertificateRecord{})))
if err != nil {
return nil, wrapSQLError(err)
... | go | func (d *Accessor) GetUnexpiredCertificates() (crs []certdb.CertificateRecord, err error) {
err = d.checkDB()
if err != nil {
return nil, err
}
err = d.db.Select(&crs, fmt.Sprintf(d.db.Rebind(selectAllUnexpiredSQL), sqlstruct.Columns(certdb.CertificateRecord{})))
if err != nil {
return nil, wrapSQLError(err)
... | [
"func",
"(",
"d",
"*",
"Accessor",
")",
"GetUnexpiredCertificates",
"(",
")",
"(",
"crs",
"[",
"]",
"certdb",
".",
"CertificateRecord",
",",
"err",
"error",
")",
"{",
"err",
"=",
"d",
".",
"checkDB",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"... | // GetUnexpiredCertificates gets all unexpired certificate from db. | [
"GetUnexpiredCertificates",
"gets",
"all",
"unexpired",
"certificate",
"from",
"db",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/certdb/sql/database_accessor.go#L145-L157 |
161,366 | cloudflare/cfssl | certdb/sql/database_accessor.go | RevokeCertificate | func (d *Accessor) RevokeCertificate(serial, aki string, reasonCode int) error {
err := d.checkDB()
if err != nil {
return err
}
result, err := d.db.NamedExec(updateRevokeSQL, &certdb.CertificateRecord{
AKI: aki,
Reason: reasonCode,
Serial: serial,
})
if err != nil {
return wrapSQLError(err)
}
nu... | go | func (d *Accessor) RevokeCertificate(serial, aki string, reasonCode int) error {
err := d.checkDB()
if err != nil {
return err
}
result, err := d.db.NamedExec(updateRevokeSQL, &certdb.CertificateRecord{
AKI: aki,
Reason: reasonCode,
Serial: serial,
})
if err != nil {
return wrapSQLError(err)
}
nu... | [
"func",
"(",
"d",
"*",
"Accessor",
")",
"RevokeCertificate",
"(",
"serial",
",",
"aki",
"string",
",",
"reasonCode",
"int",
")",
"error",
"{",
"err",
":=",
"d",
".",
"checkDB",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"... | // RevokeCertificate updates a certificate with a given serial number and marks it revoked. | [
"RevokeCertificate",
"updates",
"a",
"certificate",
"with",
"a",
"given",
"serial",
"number",
"and",
"marks",
"it",
"revoked",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/certdb/sql/database_accessor.go#L190-L216 |
161,367 | cloudflare/cfssl | certdb/sql/database_accessor.go | InsertOCSP | func (d *Accessor) InsertOCSP(rr certdb.OCSPRecord) error {
err := d.checkDB()
if err != nil {
return err
}
result, err := d.db.NamedExec(insertOCSPSQL, &certdb.OCSPRecord{
AKI: rr.AKI,
Body: rr.Body,
Expiry: rr.Expiry.UTC(),
Serial: rr.Serial,
})
if err != nil {
return wrapSQLError(err)
}
nu... | go | func (d *Accessor) InsertOCSP(rr certdb.OCSPRecord) error {
err := d.checkDB()
if err != nil {
return err
}
result, err := d.db.NamedExec(insertOCSPSQL, &certdb.OCSPRecord{
AKI: rr.AKI,
Body: rr.Body,
Expiry: rr.Expiry.UTC(),
Serial: rr.Serial,
})
if err != nil {
return wrapSQLError(err)
}
nu... | [
"func",
"(",
"d",
"*",
"Accessor",
")",
"InsertOCSP",
"(",
"rr",
"certdb",
".",
"OCSPRecord",
")",
"error",
"{",
"err",
":=",
"d",
".",
"checkDB",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"result",
",",
"... | // InsertOCSP puts a new certdb.OCSPRecord into the db. | [
"InsertOCSP",
"puts",
"a",
"new",
"certdb",
".",
"OCSPRecord",
"into",
"the",
"db",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/certdb/sql/database_accessor.go#L219-L246 |
161,368 | cloudflare/cfssl | certdb/sql/database_accessor.go | GetOCSP | func (d *Accessor) GetOCSP(serial, aki string) (ors []certdb.OCSPRecord, err error) {
err = d.checkDB()
if err != nil {
return nil, err
}
err = d.db.Select(&ors, fmt.Sprintf(d.db.Rebind(selectOCSPSQL), sqlstruct.Columns(certdb.OCSPRecord{})), serial, aki)
if err != nil {
return nil, wrapSQLError(err)
}
ret... | go | func (d *Accessor) GetOCSP(serial, aki string) (ors []certdb.OCSPRecord, err error) {
err = d.checkDB()
if err != nil {
return nil, err
}
err = d.db.Select(&ors, fmt.Sprintf(d.db.Rebind(selectOCSPSQL), sqlstruct.Columns(certdb.OCSPRecord{})), serial, aki)
if err != nil {
return nil, wrapSQLError(err)
}
ret... | [
"func",
"(",
"d",
"*",
"Accessor",
")",
"GetOCSP",
"(",
"serial",
",",
"aki",
"string",
")",
"(",
"ors",
"[",
"]",
"certdb",
".",
"OCSPRecord",
",",
"err",
"error",
")",
"{",
"err",
"=",
"d",
".",
"checkDB",
"(",
")",
"\n",
"if",
"err",
"!=",
"... | // GetOCSP retrieves a certdb.OCSPRecord from db by serial. | [
"GetOCSP",
"retrieves",
"a",
"certdb",
".",
"OCSPRecord",
"from",
"db",
"by",
"serial",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/certdb/sql/database_accessor.go#L249-L261 |
161,369 | cloudflare/cfssl | certdb/sql/database_accessor.go | GetUnexpiredOCSPs | func (d *Accessor) GetUnexpiredOCSPs() (ors []certdb.OCSPRecord, err error) {
err = d.checkDB()
if err != nil {
return nil, err
}
err = d.db.Select(&ors, fmt.Sprintf(d.db.Rebind(selectAllUnexpiredOCSPSQL), sqlstruct.Columns(certdb.OCSPRecord{})))
if err != nil {
return nil, wrapSQLError(err)
}
return ors, ... | go | func (d *Accessor) GetUnexpiredOCSPs() (ors []certdb.OCSPRecord, err error) {
err = d.checkDB()
if err != nil {
return nil, err
}
err = d.db.Select(&ors, fmt.Sprintf(d.db.Rebind(selectAllUnexpiredOCSPSQL), sqlstruct.Columns(certdb.OCSPRecord{})))
if err != nil {
return nil, wrapSQLError(err)
}
return ors, ... | [
"func",
"(",
"d",
"*",
"Accessor",
")",
"GetUnexpiredOCSPs",
"(",
")",
"(",
"ors",
"[",
"]",
"certdb",
".",
"OCSPRecord",
",",
"err",
"error",
")",
"{",
"err",
"=",
"d",
".",
"checkDB",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ni... | // GetUnexpiredOCSPs retrieves all unexpired certdb.OCSPRecord from db. | [
"GetUnexpiredOCSPs",
"retrieves",
"all",
"unexpired",
"certdb",
".",
"OCSPRecord",
"from",
"db",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/certdb/sql/database_accessor.go#L264-L276 |
161,370 | cloudflare/cfssl | certdb/sql/database_accessor.go | UpdateOCSP | func (d *Accessor) UpdateOCSP(serial, aki, body string, expiry time.Time) error {
err := d.checkDB()
if err != nil {
return err
}
result, err := d.db.NamedExec(updateOCSPSQL, &certdb.OCSPRecord{
AKI: aki,
Body: body,
Expiry: expiry.UTC(),
Serial: serial,
})
if err != nil {
return wrapSQLError(er... | go | func (d *Accessor) UpdateOCSP(serial, aki, body string, expiry time.Time) error {
err := d.checkDB()
if err != nil {
return err
}
result, err := d.db.NamedExec(updateOCSPSQL, &certdb.OCSPRecord{
AKI: aki,
Body: body,
Expiry: expiry.UTC(),
Serial: serial,
})
if err != nil {
return wrapSQLError(er... | [
"func",
"(",
"d",
"*",
"Accessor",
")",
"UpdateOCSP",
"(",
"serial",
",",
"aki",
",",
"body",
"string",
",",
"expiry",
"time",
".",
"Time",
")",
"error",
"{",
"err",
":=",
"d",
".",
"checkDB",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retur... | // UpdateOCSP updates a ocsp response record with a given serial number. | [
"UpdateOCSP",
"updates",
"a",
"ocsp",
"response",
"record",
"with",
"a",
"given",
"serial",
"number",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/certdb/sql/database_accessor.go#L279-L306 |
161,371 | cloudflare/cfssl | cli/certinfo/certinfo.go | certinfoMain | func certinfoMain(args []string, c cli.Config) (err error) {
var cert *certinfo.Certificate
var csr *x509.CertificateRequest
if c.CertFile != "" {
if c.CertFile == "-" {
var certPEM []byte
if certPEM, err = cli.ReadStdin(c.CertFile); err != nil {
return
}
if cert, err = certinfo.ParseCertificateP... | go | func certinfoMain(args []string, c cli.Config) (err error) {
var cert *certinfo.Certificate
var csr *x509.CertificateRequest
if c.CertFile != "" {
if c.CertFile == "-" {
var certPEM []byte
if certPEM, err = cli.ReadStdin(c.CertFile); err != nil {
return
}
if cert, err = certinfo.ParseCertificateP... | [
"func",
"certinfoMain",
"(",
"args",
"[",
"]",
"string",
",",
"c",
"cli",
".",
"Config",
")",
"(",
"err",
"error",
")",
"{",
"var",
"cert",
"*",
"certinfo",
".",
"Certificate",
"\n",
"var",
"csr",
"*",
"x509",
".",
"CertificateRequest",
"\n\n",
"if",
... | // certinfoMain is the main CLI of certinfo functionality | [
"certinfoMain",
"is",
"the",
"main",
"CLI",
"of",
"certinfo",
"functionality"
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/cli/certinfo/certinfo.go#L37-L108 |
161,372 | cloudflare/cfssl | config/config.go | UnmarshalJSON | func (oid *OID) UnmarshalJSON(data []byte) (err error) {
if data[0] != '"' || data[len(data)-1] != '"' {
return errors.New("OID JSON string not wrapped in quotes." + string(data))
}
data = data[1 : len(data)-1]
parsedOid, err := parseObjectIdentifier(string(data))
if err != nil {
return err
}
*oid = OID(pars... | go | func (oid *OID) UnmarshalJSON(data []byte) (err error) {
if data[0] != '"' || data[len(data)-1] != '"' {
return errors.New("OID JSON string not wrapped in quotes." + string(data))
}
data = data[1 : len(data)-1]
parsedOid, err := parseObjectIdentifier(string(data))
if err != nil {
return err
}
*oid = OID(pars... | [
"func",
"(",
"oid",
"*",
"OID",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"err",
"error",
")",
"{",
"if",
"data",
"[",
"0",
"]",
"!=",
"'\"'",
"||",
"data",
"[",
"len",
"(",
"data",
")",
"-",
"1",
"]",
"!=",
"'\"'",
"{",
... | // UnmarshalJSON unmarshals a JSON string into an OID. | [
"UnmarshalJSON",
"unmarshals",
"a",
"JSON",
"string",
"into",
"an",
"OID",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/config/config.go#L108-L119 |
161,373 | cloudflare/cfssl | config/config.go | MarshalJSON | func (oid OID) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%v"`, asn1.ObjectIdentifier(oid))), nil
} | go | func (oid OID) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%v"`, asn1.ObjectIdentifier(oid))), nil
} | [
"func",
"(",
"oid",
"OID",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"`\"%v\"`",
",",
"asn1",
".",
"ObjectIdentifier",
"(",
"oid",
")",
")",
")",
",",... | // MarshalJSON marshals an oid into a JSON string. | [
"MarshalJSON",
"marshals",
"an",
"oid",
"into",
"a",
"JSON",
"string",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/config/config.go#L122-L124 |
161,374 | cloudflare/cfssl | config/config.go | SetClientCertKeyPairFromFile | func (p *Signing) SetClientCertKeyPairFromFile(certFile string, keyFile string) error {
if certFile != "" && keyFile != "" {
cert, err := helpers.LoadClientCertificate(certFile, keyFile)
if err != nil {
return err
}
for _, profile := range p.Profiles {
profile.ClientCert = cert
}
p.Default.ClientCert... | go | func (p *Signing) SetClientCertKeyPairFromFile(certFile string, keyFile string) error {
if certFile != "" && keyFile != "" {
cert, err := helpers.LoadClientCertificate(certFile, keyFile)
if err != nil {
return err
}
for _, profile := range p.Profiles {
profile.ClientCert = cert
}
p.Default.ClientCert... | [
"func",
"(",
"p",
"*",
"Signing",
")",
"SetClientCertKeyPairFromFile",
"(",
"certFile",
"string",
",",
"keyFile",
"string",
")",
"error",
"{",
"if",
"certFile",
"!=",
"\"",
"\"",
"&&",
"keyFile",
"!=",
"\"",
"\"",
"{",
"cert",
",",
"err",
":=",
"helpers"... | // SetClientCertKeyPairFromFile updates the properties to set client certificates for mutual
// authenticated TLS remote requests | [
"SetClientCertKeyPairFromFile",
"updates",
"the",
"properties",
"to",
"set",
"client",
"certificates",
"for",
"mutual",
"authenticated",
"TLS",
"remote",
"requests"
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/config/config.go#L320-L332 |
161,375 | cloudflare/cfssl | config/config.go | SetRemoteCAsFromFile | func (p *Signing) SetRemoteCAsFromFile(caFile string) error {
if caFile != "" {
remoteCAs, err := helpers.LoadPEMCertPool(caFile)
if err != nil {
return err
}
p.SetRemoteCAs(remoteCAs)
}
return nil
} | go | func (p *Signing) SetRemoteCAsFromFile(caFile string) error {
if caFile != "" {
remoteCAs, err := helpers.LoadPEMCertPool(caFile)
if err != nil {
return err
}
p.SetRemoteCAs(remoteCAs)
}
return nil
} | [
"func",
"(",
"p",
"*",
"Signing",
")",
"SetRemoteCAsFromFile",
"(",
"caFile",
"string",
")",
"error",
"{",
"if",
"caFile",
"!=",
"\"",
"\"",
"{",
"remoteCAs",
",",
"err",
":=",
"helpers",
".",
"LoadPEMCertPool",
"(",
"caFile",
")",
"\n",
"if",
"err",
"... | // SetRemoteCAsFromFile reads root CAs from file and updates the properties to set remote CAs for TLS
// remote requests | [
"SetRemoteCAsFromFile",
"reads",
"root",
"CAs",
"from",
"file",
"and",
"updates",
"the",
"properties",
"to",
"set",
"remote",
"CAs",
"for",
"TLS",
"remote",
"requests"
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/config/config.go#L336-L345 |
161,376 | cloudflare/cfssl | config/config.go | SetRemoteCAs | func (p *Signing) SetRemoteCAs(remoteCAs *x509.CertPool) {
for _, profile := range p.Profiles {
profile.RemoteCAs = remoteCAs
}
p.Default.RemoteCAs = remoteCAs
} | go | func (p *Signing) SetRemoteCAs(remoteCAs *x509.CertPool) {
for _, profile := range p.Profiles {
profile.RemoteCAs = remoteCAs
}
p.Default.RemoteCAs = remoteCAs
} | [
"func",
"(",
"p",
"*",
"Signing",
")",
"SetRemoteCAs",
"(",
"remoteCAs",
"*",
"x509",
".",
"CertPool",
")",
"{",
"for",
"_",
",",
"profile",
":=",
"range",
"p",
".",
"Profiles",
"{",
"profile",
".",
"RemoteCAs",
"=",
"remoteCAs",
"\n",
"}",
"\n",
"p"... | // SetRemoteCAs updates the properties to set remote CAs for TLS
// remote requests | [
"SetRemoteCAs",
"updates",
"the",
"properties",
"to",
"set",
"remote",
"CAs",
"for",
"TLS",
"remote",
"requests"
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/config/config.go#L349-L354 |
161,377 | cloudflare/cfssl | config/config.go | NeedsRemoteSigner | func (p *Signing) NeedsRemoteSigner() bool {
for _, profile := range p.Profiles {
if profile.RemoteServer != "" {
return true
}
}
if p.Default.RemoteServer != "" {
return true
}
return false
} | go | func (p *Signing) NeedsRemoteSigner() bool {
for _, profile := range p.Profiles {
if profile.RemoteServer != "" {
return true
}
}
if p.Default.RemoteServer != "" {
return true
}
return false
} | [
"func",
"(",
"p",
"*",
"Signing",
")",
"NeedsRemoteSigner",
"(",
")",
"bool",
"{",
"for",
"_",
",",
"profile",
":=",
"range",
"p",
".",
"Profiles",
"{",
"if",
"profile",
".",
"RemoteServer",
"!=",
"\"",
"\"",
"{",
"return",
"true",
"\n",
"}",
"\n",
... | // NeedsRemoteSigner returns true if one of the profiles has a remote set | [
"NeedsRemoteSigner",
"returns",
"true",
"if",
"one",
"of",
"the",
"profiles",
"has",
"a",
"remote",
"set"
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/config/config.go#L357-L369 |
161,378 | cloudflare/cfssl | config/config.go | Usages | func (p *SigningProfile) Usages() (ku x509.KeyUsage, eku []x509.ExtKeyUsage, unk []string) {
for _, keyUse := range p.Usage {
if kuse, ok := KeyUsage[keyUse]; ok {
ku |= kuse
} else if ekuse, ok := ExtKeyUsage[keyUse]; ok {
eku = append(eku, ekuse)
} else {
unk = append(unk, keyUse)
}
}
return
} | go | func (p *SigningProfile) Usages() (ku x509.KeyUsage, eku []x509.ExtKeyUsage, unk []string) {
for _, keyUse := range p.Usage {
if kuse, ok := KeyUsage[keyUse]; ok {
ku |= kuse
} else if ekuse, ok := ExtKeyUsage[keyUse]; ok {
eku = append(eku, ekuse)
} else {
unk = append(unk, keyUse)
}
}
return
} | [
"func",
"(",
"p",
"*",
"SigningProfile",
")",
"Usages",
"(",
")",
"(",
"ku",
"x509",
".",
"KeyUsage",
",",
"eku",
"[",
"]",
"x509",
".",
"ExtKeyUsage",
",",
"unk",
"[",
"]",
"string",
")",
"{",
"for",
"_",
",",
"keyUse",
":=",
"range",
"p",
".",
... | // Usages parses the list of key uses in the profile, translating them
// to a list of X.509 key usages and extended key usages. The unknown
// uses are collected into a slice that is also returned. | [
"Usages",
"parses",
"the",
"list",
"of",
"key",
"uses",
"in",
"the",
"profile",
"translating",
"them",
"to",
"a",
"list",
"of",
"X",
".",
"509",
"key",
"usages",
"and",
"extended",
"key",
"usages",
".",
"The",
"unknown",
"uses",
"are",
"collected",
"into... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/config/config.go#L389-L400 |
161,379 | cloudflare/cfssl | config/config.go | hasLocalConfig | func (p *SigningProfile) hasLocalConfig() bool {
if p.Usage != nil ||
p.IssuerURL != nil ||
p.OCSP != "" ||
p.ExpiryString != "" ||
p.BackdateString != "" ||
p.CAConstraint.IsCA != false ||
!p.NotBefore.IsZero() ||
!p.NotAfter.IsZero() ||
p.NameWhitelistString != "" ||
len(p.CTLogServers) != 0 {
re... | go | func (p *SigningProfile) hasLocalConfig() bool {
if p.Usage != nil ||
p.IssuerURL != nil ||
p.OCSP != "" ||
p.ExpiryString != "" ||
p.BackdateString != "" ||
p.CAConstraint.IsCA != false ||
!p.NotBefore.IsZero() ||
!p.NotAfter.IsZero() ||
p.NameWhitelistString != "" ||
len(p.CTLogServers) != 0 {
re... | [
"func",
"(",
"p",
"*",
"SigningProfile",
")",
"hasLocalConfig",
"(",
")",
"bool",
"{",
"if",
"p",
".",
"Usage",
"!=",
"nil",
"||",
"p",
".",
"IssuerURL",
"!=",
"nil",
"||",
"p",
".",
"OCSP",
"!=",
"\"",
"\"",
"||",
"p",
".",
"ExpiryString",
"!=",
... | // This checks if the SigningProfile object contains configurations that are only effective with a local signer
// which has access to CA private key. | [
"This",
"checks",
"if",
"the",
"SigningProfile",
"object",
"contains",
"configurations",
"that",
"are",
"only",
"effective",
"with",
"a",
"local",
"signer",
"which",
"has",
"access",
"to",
"CA",
"private",
"key",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/config/config.go#L470-L484 |
161,380 | cloudflare/cfssl | config/config.go | warnSkippedSettings | func (p *Signing) warnSkippedSettings() {
const warningMessage = `The configuration value by "usages", "issuer_urls", "ocsp_url", "crl_url", "ca_constraint", "expiry", "backdate", "not_before", "not_after", "cert_store" and "ct_log_servers" are skipped`
if p == nil {
return
}
if (p.Default.RemoteName != "" || p.... | go | func (p *Signing) warnSkippedSettings() {
const warningMessage = `The configuration value by "usages", "issuer_urls", "ocsp_url", "crl_url", "ca_constraint", "expiry", "backdate", "not_before", "not_after", "cert_store" and "ct_log_servers" are skipped`
if p == nil {
return
}
if (p.Default.RemoteName != "" || p.... | [
"func",
"(",
"p",
"*",
"Signing",
")",
"warnSkippedSettings",
"(",
")",
"{",
"const",
"warningMessage",
"=",
"`The configuration value by \"usages\", \"issuer_urls\", \"ocsp_url\", \"crl_url\", \"ca_constraint\", \"expiry\", \"backdate\", \"not_before\", \"not_after\", \"cert_store\" and \... | // warnSkippedSettings prints a log warning message about skipped settings
// in a SigningProfile, usually due to remote signer. | [
"warnSkippedSettings",
"prints",
"a",
"log",
"warning",
"message",
"about",
"skipped",
"settings",
"in",
"a",
"SigningProfile",
"usually",
"due",
"to",
"remote",
"signer",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/config/config.go#L488-L503 |
161,381 | cloudflare/cfssl | config/config.go | Valid | func (p *Signing) Valid() bool {
if p == nil {
return false
}
log.Debugf("validating configuration")
if !p.Default.validProfile(true) {
log.Debugf("default profile is invalid")
return false
}
for _, sp := range p.Profiles {
if !sp.validProfile(false) {
log.Debugf("invalid profile")
return false
... | go | func (p *Signing) Valid() bool {
if p == nil {
return false
}
log.Debugf("validating configuration")
if !p.Default.validProfile(true) {
log.Debugf("default profile is invalid")
return false
}
for _, sp := range p.Profiles {
if !sp.validProfile(false) {
log.Debugf("invalid profile")
return false
... | [
"func",
"(",
"p",
"*",
"Signing",
")",
"Valid",
"(",
")",
"bool",
"{",
"if",
"p",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
")",
"\n",
"if",
"!",
"p",
".",
"Default",
".",
"validProfile",
"("... | // Valid checks the signature policies, ensuring they are valid
// policies. A policy is valid if it has defined at least key usages
// to be used, and a valid default profile has defined at least a
// default expiration. | [
"Valid",
"checks",
"the",
"signature",
"policies",
"ensuring",
"they",
"are",
"valid",
"policies",
".",
"A",
"policy",
"is",
"valid",
"if",
"it",
"has",
"defined",
"at",
"least",
"key",
"usages",
"to",
"be",
"used",
"and",
"a",
"valid",
"default",
"profile... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/config/config.go#L529-L550 |
161,382 | cloudflare/cfssl | config/config.go | DefaultConfig | func DefaultConfig() *SigningProfile {
d := helpers.OneYear
return &SigningProfile{
Usage: []string{"signing", "key encipherment", "server auth", "client auth"},
Expiry: d,
ExpiryString: "8760h",
}
} | go | func DefaultConfig() *SigningProfile {
d := helpers.OneYear
return &SigningProfile{
Usage: []string{"signing", "key encipherment", "server auth", "client auth"},
Expiry: d,
ExpiryString: "8760h",
}
} | [
"func",
"DefaultConfig",
"(",
")",
"*",
"SigningProfile",
"{",
"d",
":=",
"helpers",
".",
"OneYear",
"\n",
"return",
"&",
"SigningProfile",
"{",
"Usage",
":",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"... | // DefaultConfig returns a default configuration specifying basic key
// usage and a 1 year expiration time. The key usages chosen are
// signing, key encipherment, client auth and server auth. | [
"DefaultConfig",
"returns",
"a",
"default",
"configuration",
"specifying",
"basic",
"key",
"usage",
"and",
"a",
"1",
"year",
"expiration",
"time",
".",
"The",
"key",
"usages",
"chosen",
"are",
"signing",
"key",
"encipherment",
"client",
"auth",
"and",
"server",
... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/config/config.go#L599-L606 |
161,383 | cloudflare/cfssl | config/config.go | LoadFile | func LoadFile(path string) (*Config, error) {
log.Debugf("loading configuration file from %s", path)
if path == "" {
return nil, cferr.Wrap(cferr.PolicyError, cferr.InvalidPolicy, errors.New("invalid path"))
}
body, err := ioutil.ReadFile(path)
if err != nil {
return nil, cferr.Wrap(cferr.PolicyError, cferr.I... | go | func LoadFile(path string) (*Config, error) {
log.Debugf("loading configuration file from %s", path)
if path == "" {
return nil, cferr.Wrap(cferr.PolicyError, cferr.InvalidPolicy, errors.New("invalid path"))
}
body, err := ioutil.ReadFile(path)
if err != nil {
return nil, cferr.Wrap(cferr.PolicyError, cferr.I... | [
"func",
"LoadFile",
"(",
"path",
"string",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"path",
")",
"\n",
"if",
"path",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"cferr",
".",
"Wrap",
"(",
"cf... | // LoadFile attempts to load the configuration file stored at the path
// and returns the configuration. On error, it returns nil. | [
"LoadFile",
"attempts",
"to",
"load",
"the",
"configuration",
"file",
"stored",
"at",
"the",
"path",
"and",
"returns",
"the",
"configuration",
".",
"On",
"error",
"it",
"returns",
"nil",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/config/config.go#L610-L622 |
161,384 | cloudflare/cfssl | config/config.go | LoadConfig | func LoadConfig(config []byte) (*Config, error) {
var cfg = &Config{}
err := json.Unmarshal(config, &cfg)
if err != nil {
return nil, cferr.Wrap(cferr.PolicyError, cferr.InvalidPolicy,
errors.New("failed to unmarshal configuration: "+err.Error()))
}
if cfg.Signing == nil {
return nil, errors.New("No \"sign... | go | func LoadConfig(config []byte) (*Config, error) {
var cfg = &Config{}
err := json.Unmarshal(config, &cfg)
if err != nil {
return nil, cferr.Wrap(cferr.PolicyError, cferr.InvalidPolicy,
errors.New("failed to unmarshal configuration: "+err.Error()))
}
if cfg.Signing == nil {
return nil, errors.New("No \"sign... | [
"func",
"LoadConfig",
"(",
"config",
"[",
"]",
"byte",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"var",
"cfg",
"=",
"&",
"Config",
"{",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"config",
",",
"&",
"cfg",
")",
"\n",
"if",
"e... | // LoadConfig attempts to load the configuration from a byte slice.
// On error, it returns nil. | [
"LoadConfig",
"attempts",
"to",
"load",
"the",
"configuration",
"from",
"a",
"byte",
"slice",
".",
"On",
"error",
"it",
"returns",
"nil",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/config/config.go#L626-L659 |
161,385 | cloudflare/cfssl | transport/client.go | TLSClientAuthClientConfig | func (tr *Transport) TLSClientAuthClientConfig(host string) (*tls.Config, error) {
cert, err := tr.getCertificate()
if err != nil {
return nil, err
}
return &tls.Config{
Certificates: []tls.Certificate{cert},
RootCAs: tr.TrustStore.Pool(),
ServerName: host,
CipherSuites: core.CipherSuites,
MinVe... | go | func (tr *Transport) TLSClientAuthClientConfig(host string) (*tls.Config, error) {
cert, err := tr.getCertificate()
if err != nil {
return nil, err
}
return &tls.Config{
Certificates: []tls.Certificate{cert},
RootCAs: tr.TrustStore.Pool(),
ServerName: host,
CipherSuites: core.CipherSuites,
MinVe... | [
"func",
"(",
"tr",
"*",
"Transport",
")",
"TLSClientAuthClientConfig",
"(",
"host",
"string",
")",
"(",
"*",
"tls",
".",
"Config",
",",
"error",
")",
"{",
"cert",
",",
"err",
":=",
"tr",
".",
"getCertificate",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil"... | // TLSClientAuthClientConfig returns a new client authentication TLS
// configuration that can be used for a client using client auth
// connecting to the named host. | [
"TLSClientAuthClientConfig",
"returns",
"a",
"new",
"client",
"authentication",
"TLS",
"configuration",
"that",
"can",
"be",
"used",
"for",
"a",
"client",
"using",
"client",
"auth",
"connecting",
"to",
"the",
"named",
"host",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/transport/client.go#L85-L99 |
161,386 | cloudflare/cfssl | transport/client.go | TLSClientAuthServerConfig | func (tr *Transport) TLSClientAuthServerConfig() (*tls.Config, error) {
cert, err := tr.getCertificate()
if err != nil {
return nil, err
}
return &tls.Config{
Certificates: []tls.Certificate{cert},
RootCAs: tr.TrustStore.Pool(),
ClientCAs: tr.ClientTrustStore.Pool(),
ClientAuth: tls.RequireAndV... | go | func (tr *Transport) TLSClientAuthServerConfig() (*tls.Config, error) {
cert, err := tr.getCertificate()
if err != nil {
return nil, err
}
return &tls.Config{
Certificates: []tls.Certificate{cert},
RootCAs: tr.TrustStore.Pool(),
ClientCAs: tr.ClientTrustStore.Pool(),
ClientAuth: tls.RequireAndV... | [
"func",
"(",
"tr",
"*",
"Transport",
")",
"TLSClientAuthServerConfig",
"(",
")",
"(",
"*",
"tls",
".",
"Config",
",",
"error",
")",
"{",
"cert",
",",
"err",
":=",
"tr",
".",
"getCertificate",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // TLSClientAuthServerConfig returns a new client authentication TLS
// configuration for servers expecting mutually authenticated
// clients. The clientAuth parameter should contain the root pool used
// to authenticate clients. | [
"TLSClientAuthServerConfig",
"returns",
"a",
"new",
"client",
"authentication",
"TLS",
"configuration",
"for",
"servers",
"expecting",
"mutually",
"authenticated",
"clients",
".",
"The",
"clientAuth",
"parameter",
"should",
"contain",
"the",
"root",
"pool",
"used",
"t... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/transport/client.go#L105-L119 |
161,387 | cloudflare/cfssl | transport/client.go | TLSServerConfig | func (tr *Transport) TLSServerConfig() (*tls.Config, error) {
cert, err := tr.getCertificate()
if err != nil {
return nil, err
}
return &tls.Config{
Certificates: []tls.Certificate{cert},
CipherSuites: core.CipherSuites,
MinVersion: tls.VersionTLS12,
}, nil
} | go | func (tr *Transport) TLSServerConfig() (*tls.Config, error) {
cert, err := tr.getCertificate()
if err != nil {
return nil, err
}
return &tls.Config{
Certificates: []tls.Certificate{cert},
CipherSuites: core.CipherSuites,
MinVersion: tls.VersionTLS12,
}, nil
} | [
"func",
"(",
"tr",
"*",
"Transport",
")",
"TLSServerConfig",
"(",
")",
"(",
"*",
"tls",
".",
"Config",
",",
"error",
")",
"{",
"cert",
",",
"err",
":=",
"tr",
".",
"getCertificate",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
... | // TLSServerConfig is a general server configuration that should be
// used for non-client authentication purposes, such as HTTPS. | [
"TLSServerConfig",
"is",
"a",
"general",
"server",
"configuration",
"that",
"should",
"be",
"used",
"for",
"non",
"-",
"client",
"authentication",
"purposes",
"such",
"as",
"HTTPS",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/transport/client.go#L123-L134 |
161,388 | cloudflare/cfssl | transport/client.go | New | func New(before time.Duration, identity *core.Identity) (*Transport, error) {
var tr = &Transport{
Before: before,
Identity: identity,
Backoff: &backoff.Backoff{},
}
store, err := roots.New(identity.Roots)
if err != nil {
return nil, err
}
tr.TrustStore = store
if len(identity.ClientRoots) > 0 {
s... | go | func New(before time.Duration, identity *core.Identity) (*Transport, error) {
var tr = &Transport{
Before: before,
Identity: identity,
Backoff: &backoff.Backoff{},
}
store, err := roots.New(identity.Roots)
if err != nil {
return nil, err
}
tr.TrustStore = store
if len(identity.ClientRoots) > 0 {
s... | [
"func",
"New",
"(",
"before",
"time",
".",
"Duration",
",",
"identity",
"*",
"core",
".",
"Identity",
")",
"(",
"*",
"Transport",
",",
"error",
")",
"{",
"var",
"tr",
"=",
"&",
"Transport",
"{",
"Before",
":",
"before",
",",
"Identity",
":",
"identit... | // New builds a new transport from an identity and a before time. The
// before time tells the transport how long before the certificate
// expires to start attempting to update when auto-updating. If before
// is longer than the certificate's lifetime, every update check will
// trigger a new certificate to be generat... | [
"New",
"builds",
"a",
"new",
"transport",
"from",
"an",
"identity",
"and",
"a",
"before",
"time",
".",
"The",
"before",
"time",
"tells",
"the",
"transport",
"how",
"long",
"before",
"the",
"certificate",
"expires",
"to",
"start",
"attempting",
"to",
"update"... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/transport/client.go#L141-L173 |
161,389 | cloudflare/cfssl | transport/client.go | Lifespan | func (tr *Transport) Lifespan() time.Duration {
cert := tr.Provider.Certificate()
if cert == nil {
return 0
}
now := time.Now()
if now.After(cert.NotAfter) {
return 0
}
now = now.Add(tr.Before)
ls := cert.NotAfter.Sub(now)
log.Debugf(" LIFESPAN:\t%s", ls)
if ls < 0 {
return 0
}
return ls
} | go | func (tr *Transport) Lifespan() time.Duration {
cert := tr.Provider.Certificate()
if cert == nil {
return 0
}
now := time.Now()
if now.After(cert.NotAfter) {
return 0
}
now = now.Add(tr.Before)
ls := cert.NotAfter.Sub(now)
log.Debugf(" LIFESPAN:\t%s", ls)
if ls < 0 {
return 0
}
return ls
} | [
"func",
"(",
"tr",
"*",
"Transport",
")",
"Lifespan",
"(",
")",
"time",
".",
"Duration",
"{",
"cert",
":=",
"tr",
".",
"Provider",
".",
"Certificate",
"(",
")",
"\n",
"if",
"cert",
"==",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"now",
":=",
... | // Lifespan returns how much time is left before the transport's
// certificate expires, or 0 if the certificate is not present or
// expired. | [
"Lifespan",
"returns",
"how",
"much",
"time",
"is",
"left",
"before",
"the",
"transport",
"s",
"certificate",
"expires",
"or",
"0",
"if",
"the",
"certificate",
"is",
"not",
"present",
"or",
"expired",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/transport/client.go#L178-L196 |
161,390 | cloudflare/cfssl | transport/client.go | Dial | func Dial(address string, tr *Transport) (*tls.Conn, error) {
host, _, err := net.SplitHostPort(address)
if err != nil {
// Assume address is a hostname, and that it should
// use the HTTPS port number.
host = address
address = net.JoinHostPort(address, "443")
}
cfg, err := tr.TLSClientAuthClientConfig(hos... | go | func Dial(address string, tr *Transport) (*tls.Conn, error) {
host, _, err := net.SplitHostPort(address)
if err != nil {
// Assume address is a hostname, and that it should
// use the HTTPS port number.
host = address
address = net.JoinHostPort(address, "443")
}
cfg, err := tr.TLSClientAuthClientConfig(hos... | [
"func",
"Dial",
"(",
"address",
"string",
",",
"tr",
"*",
"Transport",
")",
"(",
"*",
"tls",
".",
"Conn",
",",
"error",
")",
"{",
"host",
",",
"_",
",",
"err",
":=",
"net",
".",
"SplitHostPort",
"(",
"address",
")",
"\n",
"if",
"err",
"!=",
"nil"... | // Dial initiates a TLS connection to an outbound server. It returns a
// TLS connection to the server. | [
"Dial",
"initiates",
"a",
"TLS",
"connection",
"to",
"an",
"outbound",
"server",
".",
"It",
"returns",
"a",
"TLS",
"connection",
"to",
"the",
"server",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/transport/client.go#L289-L323 |
161,391 | cloudflare/cfssl | scan/tls_session.go | sessionResumeScan | func sessionResumeScan(addr, hostname string) (grade Grade, output Output, err error) {
config := defaultTLSConfig(hostname)
config.ClientSessionCache = tls.NewLRUClientSessionCache(1)
conn, err := tls.DialWithDialer(Dialer, Network, addr, config)
if err != nil {
return
}
if err = conn.Close(); err != nil {
... | go | func sessionResumeScan(addr, hostname string) (grade Grade, output Output, err error) {
config := defaultTLSConfig(hostname)
config.ClientSessionCache = tls.NewLRUClientSessionCache(1)
conn, err := tls.DialWithDialer(Dialer, Network, addr, config)
if err != nil {
return
}
if err = conn.Close(); err != nil {
... | [
"func",
"sessionResumeScan",
"(",
"addr",
",",
"hostname",
"string",
")",
"(",
"grade",
"Grade",
",",
"output",
"Output",
",",
"err",
"error",
")",
"{",
"config",
":=",
"defaultTLSConfig",
"(",
"hostname",
")",
"\n",
"config",
".",
"ClientSessionCache",
"=",... | // SessionResumeScan tests that host is able to resume sessions across all addresses. | [
"SessionResumeScan",
"tests",
"that",
"host",
"is",
"able",
"to",
"resume",
"sessions",
"across",
"all",
"addresses",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/tls_session.go#L18-L42 |
161,392 | cloudflare/cfssl | cli/ocspsign/ocspsign.go | ocspSignerMain | func ocspSignerMain(args []string, c cli.Config) (err error) {
// Read the cert to be revoked from file
certBytes, err := ioutil.ReadFile(c.CertFile)
if err != nil {
log.Critical("Unable to read certificate: ", err)
return
}
cert, err := helpers.ParseCertificatePEM(certBytes)
if err != nil {
log.Critical("U... | go | func ocspSignerMain(args []string, c cli.Config) (err error) {
// Read the cert to be revoked from file
certBytes, err := ioutil.ReadFile(c.CertFile)
if err != nil {
log.Critical("Unable to read certificate: ", err)
return
}
cert, err := helpers.ParseCertificatePEM(certBytes)
if err != nil {
log.Critical("U... | [
"func",
"ocspSignerMain",
"(",
"args",
"[",
"]",
"string",
",",
"c",
"cli",
".",
"Config",
")",
"(",
"err",
"error",
")",
"{",
"// Read the cert to be revoked from file",
"certBytes",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"c",
".",
"CertFile",
... | // ocspSignerMain is the main CLI of OCSP signer functionality. | [
"ocspSignerMain",
"is",
"the",
"main",
"CLI",
"of",
"OCSP",
"signer",
"functionality",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/cli/ocspsign/ocspsign.go#L28-L79 |
161,393 | cloudflare/cfssl | cli/ocspsign/ocspsign.go | SignerFromConfig | func SignerFromConfig(c cli.Config) (ocsp.Signer, error) {
//if this is called from serve then we need to use the specific responder key file
//fallback to key for backwards-compatibility
k := c.ResponderKeyFile
if k == "" {
k = c.KeyFile
}
return ocsp.NewSignerFromFile(c.CAFile, c.ResponderFile, k, time.Durati... | go | func SignerFromConfig(c cli.Config) (ocsp.Signer, error) {
//if this is called from serve then we need to use the specific responder key file
//fallback to key for backwards-compatibility
k := c.ResponderKeyFile
if k == "" {
k = c.KeyFile
}
return ocsp.NewSignerFromFile(c.CAFile, c.ResponderFile, k, time.Durati... | [
"func",
"SignerFromConfig",
"(",
"c",
"cli",
".",
"Config",
")",
"(",
"ocsp",
".",
"Signer",
",",
"error",
")",
"{",
"//if this is called from serve then we need to use the specific responder key file",
"//fallback to key for backwards-compatibility",
"k",
":=",
"c",
".",
... | // SignerFromConfig creates a signer from a cli.Config as a helper for cli and serve | [
"SignerFromConfig",
"creates",
"a",
"signer",
"from",
"a",
"cli",
".",
"Config",
"as",
"a",
"helper",
"for",
"cli",
"and",
"serve"
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/cli/ocspsign/ocspsign.go#L82-L90 |
161,394 | cloudflare/cfssl | whitelist/lookup.go | NetConnLookup | func NetConnLookup(conn net.Conn) (net.IP, error) {
if conn == nil {
return nil, errors.New("whitelist: no connection")
}
netAddr := conn.RemoteAddr()
if netAddr == nil {
return nil, errors.New("whitelist: no address returned")
}
addr, _, err := net.SplitHostPort(netAddr.String())
if err != nil {
return ... | go | func NetConnLookup(conn net.Conn) (net.IP, error) {
if conn == nil {
return nil, errors.New("whitelist: no connection")
}
netAddr := conn.RemoteAddr()
if netAddr == nil {
return nil, errors.New("whitelist: no address returned")
}
addr, _, err := net.SplitHostPort(netAddr.String())
if err != nil {
return ... | [
"func",
"NetConnLookup",
"(",
"conn",
"net",
".",
"Conn",
")",
"(",
"net",
".",
"IP",
",",
"error",
")",
"{",
"if",
"conn",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"netAddr",
":=",
... | // NetConnLookup extracts an IP from the remote address in the
// net.Conn. A single net.Conn should be passed to Address. | [
"NetConnLookup",
"extracts",
"an",
"IP",
"from",
"the",
"remote",
"address",
"in",
"the",
"net",
".",
"Conn",
".",
"A",
"single",
"net",
".",
"Conn",
"should",
"be",
"passed",
"to",
"Address",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/whitelist/lookup.go#L12-L29 |
161,395 | cloudflare/cfssl | whitelist/lookup.go | NewHandler | func NewHandler(allow, deny http.Handler, acl ACL) (http.Handler, error) {
if allow == nil {
return nil, errors.New("whitelist: allow cannot be nil")
}
if acl == nil {
return nil, errors.New("whitelist: ACL cannot be nil")
}
return &Handler{
allowHandler: allow,
denyHandler: deny,
whitelist: acl,
... | go | func NewHandler(allow, deny http.Handler, acl ACL) (http.Handler, error) {
if allow == nil {
return nil, errors.New("whitelist: allow cannot be nil")
}
if acl == nil {
return nil, errors.New("whitelist: ACL cannot be nil")
}
return &Handler{
allowHandler: allow,
denyHandler: deny,
whitelist: acl,
... | [
"func",
"NewHandler",
"(",
"allow",
",",
"deny",
"http",
".",
"Handler",
",",
"acl",
"ACL",
")",
"(",
"http",
".",
"Handler",
",",
"error",
")",
"{",
"if",
"allow",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")... | // NewHandler returns a new whitelisting-wrapped HTTP handler. The
// allow handler should contain a handler that will be called if the
// request is whitelisted; the deny handler should contain a handler
// that will be called in the request is not whitelisted. | [
"NewHandler",
"returns",
"a",
"new",
"whitelisting",
"-",
"wrapped",
"HTTP",
"handler",
".",
"The",
"allow",
"handler",
"should",
"contain",
"a",
"handler",
"that",
"will",
"be",
"called",
"if",
"the",
"request",
"is",
"whitelisted",
";",
"the",
"deny",
"han... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/whitelist/lookup.go#L59-L73 |
161,396 | cloudflare/cfssl | whitelist/lookup.go | ServeHTTP | func (h *Handler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
ip, err := HTTPRequestLookup(req)
if err != nil {
log.Printf("failed to lookup request address: %v", err)
status := http.StatusInternalServerError
http.Error(w, http.StatusText(status), status)
return
}
if h.whitelist.Permitted(ip) {
... | go | func (h *Handler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
ip, err := HTTPRequestLookup(req)
if err != nil {
log.Printf("failed to lookup request address: %v", err)
status := http.StatusInternalServerError
http.Error(w, http.StatusText(status), status)
return
}
if h.whitelist.Permitted(ip) {
... | [
"func",
"(",
"h",
"*",
"Handler",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"ip",
",",
"err",
":=",
"HTTPRequestLookup",
"(",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log"... | // ServeHTTP wraps the request in a whitelist check. | [
"ServeHTTP",
"wraps",
"the",
"request",
"in",
"a",
"whitelist",
"check",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/whitelist/lookup.go#L76-L95 |
161,397 | cloudflare/cfssl | whitelist/lookup.go | NewHandlerFunc | func NewHandlerFunc(allow, deny func(http.ResponseWriter, *http.Request), acl ACL) (*HandlerFunc, error) {
if allow == nil {
return nil, errors.New("whitelist: allow cannot be nil")
}
if acl == nil {
return nil, errors.New("whitelist: ACL cannot be nil")
}
return &HandlerFunc{
allow: allow,
deny: ... | go | func NewHandlerFunc(allow, deny func(http.ResponseWriter, *http.Request), acl ACL) (*HandlerFunc, error) {
if allow == nil {
return nil, errors.New("whitelist: allow cannot be nil")
}
if acl == nil {
return nil, errors.New("whitelist: ACL cannot be nil")
}
return &HandlerFunc{
allow: allow,
deny: ... | [
"func",
"NewHandlerFunc",
"(",
"allow",
",",
"deny",
"func",
"(",
"http",
".",
"ResponseWriter",
",",
"*",
"http",
".",
"Request",
")",
",",
"acl",
"ACL",
")",
"(",
"*",
"HandlerFunc",
",",
"error",
")",
"{",
"if",
"allow",
"==",
"nil",
"{",
"return"... | // NewHandlerFunc returns a new basic whitelisting handler. | [
"NewHandlerFunc",
"returns",
"a",
"new",
"basic",
"whitelisting",
"handler",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/whitelist/lookup.go#L107-L121 |
161,398 | cloudflare/cfssl | whitelist/lookup.go | ServeHTTP | func (h *HandlerFunc) ServeHTTP(w http.ResponseWriter, req *http.Request) {
ip, err := HTTPRequestLookup(req)
if err != nil {
log.Printf("failed to lookup request address: %v", err)
status := http.StatusInternalServerError
http.Error(w, http.StatusText(status), status)
return
}
if h.whitelist.Permitted(ip)... | go | func (h *HandlerFunc) ServeHTTP(w http.ResponseWriter, req *http.Request) {
ip, err := HTTPRequestLookup(req)
if err != nil {
log.Printf("failed to lookup request address: %v", err)
status := http.StatusInternalServerError
http.Error(w, http.StatusText(status), status)
return
}
if h.whitelist.Permitted(ip)... | [
"func",
"(",
"h",
"*",
"HandlerFunc",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"ip",
",",
"err",
":=",
"HTTPRequestLookup",
"(",
"req",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"... | // ServeHTTP checks the incoming request to see whether it is permitted,
// and calls the appropriate handle function. | [
"ServeHTTP",
"checks",
"the",
"incoming",
"request",
"to",
"see",
"whether",
"it",
"is",
"permitted",
"and",
"calls",
"the",
"appropriate",
"handle",
"function",
"."
] | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/whitelist/lookup.go#L125-L144 |
161,399 | cloudflare/cfssl | scan/crypto/tls/common.go | ticketKeyFromBytes | func ticketKeyFromBytes(b [32]byte) (key ticketKey) {
hashed := sha512.Sum512(b[:])
copy(key.keyName[:], hashed[:ticketKeyNameLen])
copy(key.aesKey[:], hashed[ticketKeyNameLen:ticketKeyNameLen+16])
copy(key.hmacKey[:], hashed[ticketKeyNameLen+16:ticketKeyNameLen+32])
return key
} | go | func ticketKeyFromBytes(b [32]byte) (key ticketKey) {
hashed := sha512.Sum512(b[:])
copy(key.keyName[:], hashed[:ticketKeyNameLen])
copy(key.aesKey[:], hashed[ticketKeyNameLen:ticketKeyNameLen+16])
copy(key.hmacKey[:], hashed[ticketKeyNameLen+16:ticketKeyNameLen+32])
return key
} | [
"func",
"ticketKeyFromBytes",
"(",
"b",
"[",
"32",
"]",
"byte",
")",
"(",
"key",
"ticketKey",
")",
"{",
"hashed",
":=",
"sha512",
".",
"Sum512",
"(",
"b",
"[",
":",
"]",
")",
"\n",
"copy",
"(",
"key",
".",
"keyName",
"[",
":",
"]",
",",
"hashed",... | // ticketKeyFromBytes converts from the external representation of a session
// ticket key to a ticketKey. Externally, session ticket keys are 32 random
// bytes and this function expands that into sufficient name and key material. | [
"ticketKeyFromBytes",
"converts",
"from",
"the",
"external",
"representation",
"of",
"a",
"session",
"ticket",
"key",
"to",
"a",
"ticketKey",
".",
"Externally",
"session",
"ticket",
"keys",
"are",
"32",
"random",
"bytes",
"and",
"this",
"function",
"expands",
"t... | 768cd563887febaad559b511aaa5964823ccb4ab | https://github.com/cloudflare/cfssl/blob/768cd563887febaad559b511aaa5964823ccb4ab/scan/crypto/tls/common.go#L379-L385 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.