1package s3crypto
2
3// Padder handles padding of crypto data
4type Padder interface {
5	// Pad will pad the byte array.
6	// The second parameter is NOT how many
7	// bytes to pad by, but how many bytes
8	// have been read prior to the padding.
9	// This allows for streamable padding.
10	Pad([]byte, int) ([]byte, error)
11	// Unpad will unpad the byte bytes. Unpad
12	// methods must be constant time.
13	Unpad([]byte) ([]byte, error)
14	// Name returns the name of the padder.
15	// This is used when decrypting on
16	// instantiating new padders.
17	Name() string
18}
19
20// NoPadder does not pad anything
21var NoPadder = Padder(noPadder{})
22
23type noPadder struct{}
24
25func (padder noPadder) Pad(b []byte, n int) ([]byte, error) {
26	return b, nil
27}
28
29func (padder noPadder) Unpad(b []byte) ([]byte, error) {
30	return b, nil
31}
32
33func (padder noPadder) Name() string {
34	return "NoPadding"
35}
36