mirror of
https://github.com/containers/skopeo.git
synced 2025-09-22 18:37:21 +00:00
Image encryption/decryption support in skopeo
Signed-off-by: Harshal Patil <harshal.patil@in.ibm.com> Signed-off-by: Brandon Lum <lumjjb@gmail.com>
This commit is contained in:
43
vendor/github.com/klauspost/compress/zstd/fse_encoder.go
generated
vendored
43
vendor/github.com/klauspost/compress/zstd/fse_encoder.go
generated
vendored
@@ -502,21 +502,6 @@ func (s *fseEncoder) validateNorm() (err error) {
|
||||
// writeCount will write the normalized histogram count to header.
|
||||
// This is read back by readNCount.
|
||||
func (s *fseEncoder) writeCount(out []byte) ([]byte, error) {
|
||||
var (
|
||||
tableLog = s.actualTableLog
|
||||
tableSize = 1 << tableLog
|
||||
previous0 bool
|
||||
charnum uint16
|
||||
|
||||
maxHeaderSize = ((int(s.symbolLen) * int(tableLog)) >> 3) + 3
|
||||
|
||||
// Write Table Size
|
||||
bitStream = uint32(tableLog - minEncTablelog)
|
||||
bitCount = uint(4)
|
||||
remaining = int16(tableSize + 1) /* +1 for extra accuracy */
|
||||
threshold = int16(tableSize)
|
||||
nbBits = uint(tableLog + 1)
|
||||
)
|
||||
if s.useRLE {
|
||||
return append(out, s.rleVal), nil
|
||||
}
|
||||
@@ -524,7 +509,28 @@ func (s *fseEncoder) writeCount(out []byte) ([]byte, error) {
|
||||
// Never write predefined.
|
||||
return out, nil
|
||||
}
|
||||
outP := len(out)
|
||||
|
||||
var (
|
||||
tableLog = s.actualTableLog
|
||||
tableSize = 1 << tableLog
|
||||
previous0 bool
|
||||
charnum uint16
|
||||
|
||||
// maximum header size plus 2 extra bytes for final output if bitCount == 0.
|
||||
maxHeaderSize = ((int(s.symbolLen) * int(tableLog)) >> 3) + 3 + 2
|
||||
|
||||
// Write Table Size
|
||||
bitStream = uint32(tableLog - minEncTablelog)
|
||||
bitCount = uint(4)
|
||||
remaining = int16(tableSize + 1) /* +1 for extra accuracy */
|
||||
threshold = int16(tableSize)
|
||||
nbBits = uint(tableLog + 1)
|
||||
outP = len(out)
|
||||
)
|
||||
if cap(out) < outP+maxHeaderSize {
|
||||
out = append(out, make([]byte, maxHeaderSize*3)...)
|
||||
out = out[:len(out)-maxHeaderSize*3]
|
||||
}
|
||||
out = out[:outP+maxHeaderSize]
|
||||
|
||||
// stops at 1
|
||||
@@ -594,11 +600,14 @@ func (s *fseEncoder) writeCount(out []byte) ([]byte, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if outP+2 > len(out) {
|
||||
return nil, fmt.Errorf("internal error: %d > %d, maxheader: %d, sl: %d, tl: %d, normcount: %v", outP+2, len(out), maxHeaderSize, s.symbolLen, int(tableLog), s.norm[:s.symbolLen])
|
||||
}
|
||||
out[outP] = byte(bitStream)
|
||||
out[outP+1] = byte(bitStream >> 8)
|
||||
outP += int((bitCount + 7) / 8)
|
||||
|
||||
if uint16(charnum) > s.symbolLen {
|
||||
if charnum > s.symbolLen {
|
||||
return nil, errors.New("internal error: charnum > s.symbolLen")
|
||||
}
|
||||
return out[:outP], nil
|
||||
|
Reference in New Issue
Block a user