MCPcopy Create free account
hub / github.com/SenseUnit/dumbproxy / parseSerialBytes

Function parseSerialBytes

auth/cert.go:244–261  ·  view source on GitHub ↗
(serial []byte)

Source from the content-addressed store, hash-verified

242}
243
244func parseSerialBytes(serial []byte) ([]byte, error) {
245 res := make([]byte, (len(serial)+2)/3)
246
247 var i int
248 for ; i < len(res) && i*3+1 < len(serial); i++ {
249 if _, err := hex.Decode(res[i:i+1], serial[i*3:i*3+2]); err != nil {
250 return nil, fmt.Errorf("parseSerialBytes() failed: %w", err)
251 }
252 if i*3+2 < len(serial) && serial[i*3+2] != ':' {
253 return nil, errors.New("missing colon delimiter")
254 }
255 }
256 if i < len(res) {
257 return nil, errors.New("incomplete serial number string")
258 }
259
260 return res, nil
261}

Callers 2

TestParseSerialBytesFunction · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by 1

TestParseSerialBytesFunction · 0.68