MCPcopy
hub / github.com/smallstep/cli / newScryptParams

Function newScryptParams

internal/kdf/scrypt.go:42–62  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

40}
41
42func newScryptParams(s string) (*scryptParam, error) {
43 params := phcParamsToMap(s)
44 ln, err := phcAtoi(params["ln"], 16)
45 if err != nil || ln < 1 || ln > ScryptMaxCost {
46 return nil, errors.Errorf("invalid scrypt parameter ln=%s", params["ln"])
47 }
48 r, err := phcAtoi(params["r"], 8)
49 if err != nil || r < 1 || r > ScryptMaxBlockSize {
50 return nil, errors.Errorf("invalid scrypt parameter r=%s", params["r"])
51 }
52 p, err := phcAtoi(params["p"], 1)
53 if err != nil || p < 1 || p > ScryptMaxParallelism {
54 return nil, errors.Errorf("invalid scrypt parameter p=%s", params["p"])
55 }
56
57 return &scryptParam{
58 N: int(math.Pow(2, float64(ln))),
59 r: r,
60 p: p,
61 }, nil
62}
63
64func (s *scryptParam) getParams() string {
65 return fmt.Sprintf("ln=%d,r=%d,p=%d", int(math.Log2(float64(s.N))), s.r, s.p)

Callers 1

CompareFunction · 0.85

Calls 2

phcParamsToMapFunction · 0.85
phcAtoiFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…